Skip to Content

good/bad programming from OOPS perspective

Nov 27, 2017 at 09:22 AM


avatar image


If I have one INCLUDE for all CLASS DEFINITIONs and one for CLASS IMPELEMENTAION and invoking those class in the main program, will be considered as a bad programming approach from OOPS perspective ?


ZINCLUDE1."for all class definitions

ZINCLUDE2."for all class implementations

invoking those class and methods here in the ZPROG.


Defining all the class definition and implementations in ZPROG (without using INCLUDES) and then invoking them there itself.

Is having an INCLUDE comes under the purview of using OOPS in the first place or INCLUDES will be considered as Classical approach of programming.

Kindly opine.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Uwe Fetzer Nov 27, 2017 at 12:08 PM

The historic intention of Includes was

  1. prevent the editor from loading the whole source code because of a low network bandwith
  2. reusage of code

Regarding 1.) I think in this times we just can ignore this

Regarding 2.) the use of local classes in your Z-Report tells me, that you will never reuse your code

Conclusion: don't use Includes at all, there's really no need of them anymore.

Show 10 Share
10 |10000 characters needed characters left characters exceeded

If think there's also point 3. Includes can still be useful for organizing source code for a better readability. I like to see the main code immediately when I display the main include of the program.


The only "main code" in my programs nowadays is

NEW app( )->main( ).

Because we are not using any global variables anymore (of course ;-) ), the report always starts with the Class definitions (or selection screen).

To navigation to the statements (main method) we have the outline or quick-outline (<ctrl>-O).

So, I can't really agree that there is a point 3.


Maintainability can be a reason to split large programs.

If a developer wants to change a piece of code they will lock the entire report in a transport. If FOO classes are in include A, BAR classes in include B, and SALV classes in include C, then developers can lock, work on, and transport these independently.


Hmm, maybe the design of the report is wrong...(?)

If it's really such a large program, you should extract classes into global workbench classes.

Advantage: every method is locked separatley in a transport request.

In my opinion only the program logic (the "App", flow logic) should be a local class. Every business object should be a workbench class, although they are not used in other projects.


I guess it's a matter of approach. I prefer to keep things as local as makes sense. It only takes a couple of minutes to turn a local class into a global when it makes sense.

I agree with business objects, but I see little benefit in globalising internal classes just for the sake of program size. Typical examples of local stuff: MVC controllers, SALV views and support classes, and any report-specific functionality. This can grow quite big already. Sometimes I will group individual SALV controller and related view and support classes into their own includes.


Ok, than my question is: where do you see the advantage of an Include against a global class?

Show more comments

It is not only about reports but also about function groups that you still might use for technical reasons (update, classical screens).

Here all productive code should be implemented in local classes and these in their includes. It makes no sense to create global classes for the internals of function groups or other kinds of programs, especially since we don't have a package section.


My point was also an extra point to the historic reason.

Nowadays, if you have local classes, there might be many class definition lines before START-OF-SELECTION. NEW app( )->main( ). (or even many lines of selection screen as in Suhas example)

I still prefer to put these definition lines in one extra include, just to keep the main part immediately visible, but of course with only one line of code, then going to the end of the source is my first reflex. So, INCLUDE or not, it's not a big deal.


Bingo Uwe Fetzer :) Code snippet from my productive code

Maybe it's a good idea for me to switch to

NEW app->start_main( ).
Suhas Saha
Nov 27, 2017 at 09:41 AM

Hello Kiran,

As per the ATC/SCI/SLIN checks the class definition include [ (L)Z...Dnn ] should be defined in the TOP include of the program or function-pool. The implementation include [ (L)Z...Pnn ] should be part of the main program.

If you don't follow this structure, then you get a warning message from the checks.


Personally i don't follow this structure when defining reports. It's easier to have everything in one place & makes life easier when refactoring.

IMHO i don't relate using(or not using) includes to OOP. Infact a CLASS-POOL itself is structured in several includes!



Show 1 Share
10 |10000 characters needed characters left characters exceeded

Completely agree, I don't think SAP guidelines are appropriate in this instance.

There's a technical reason too: using Eclipse it's a pain to work with synchronization of definitions and code in separate units, so I gave up on that a long time ago. In my opinion it's better to group classes by function if anything.

Horst Keller
Nov 27, 2017 at 04:23 PM

We recommend to organize large programs in includes.

For class pools and function groups it is a must anyhow.

For reports, it is your decision, from which point on, it is better to create includes.

This is independent from ABAP objects.

For large local classes, it is not a bad idea to put declaration part and implementation part into different includes, where the declaration include then should be included in a top include.

But never, never, never reuse includes.

10 |10000 characters needed characters left characters exceeded