Changing habits is a hard thing, especially if we are trying to change it for something which looks more complex but change is also inevitable for a developer if they want to adapt evolving environment. As a developer who wants to do things in the right way ABAP objects is introduced more than a decade ago but there are still some practical difficulties (or not ) to use it in our all daily work which can be found in several blogs like this or this. But In my opinion there are more positives than negatives Which I will try to explain.
Using below explained three methods, We will not only replace our way of working with object oriented equivalent which has some other advantages which will also be explained below, but also get more and more familiar with ABAP objects so we can use other fundamental object orientation approaches like inheritance and encapsulation.
- Use local classes for internal modularization
When you check F1 help for ABAP for a subroutine you will face the ugly truth that perform statement is obsolete where you can use some other little ugly features like tables statement. Even if you don’t have any intention to improve your knowledge on the subject, using local classes and methods in executable programs for modularization is the only valid way since 2011.
Luckily using methods for modularization is not the only advantage, There is more strict syntax check while using classes where we can not use things that are obsolete ( like header line for internal tables, range statement etc) , by just using methods we will automatically avoid them, Anything obsolete is obsolete for a reason and we should never use them, but if you keep developing procedural way and do not read ABAP news or documentation and do not use quality check tools you may not even be aware that commands that you use is obsolete, you will avoid this just using methods instead of subroutines.
You can find a simple example at the end of my blog, ( or just search for using methods for modularization in SCN ).
- Using global classes instead of function modules
It is almost the same approach with local class, to replace function modules,you can crate a global class and depending on your case create static or instance methods for modularization. As far as I know there is no class alternative for RFC and Update modules so, to use Remote function calls it is still necessary to create function modules .
If you start above approach for modularization first of all you will get familiar with OO aproach and its syntax standards, and start to have well structured reusable developments if you also follow good modularization standards as its suggested in ABAP help documents. Having this well-structured programs with reusable components will help you a lot in your Object Oriented programming journey if you wish to proceed further that way.
SALV ( Global class CL_SALV_TABLE for example is different approach to have same ALV output SALV) which came with software component 640 is better than previous ALV tools and designed really with OO approach. By analyzing how it is created and using it we can get the idea how our developments should be like if we are really developing something object oriented.
All different attributes are created in separate class, for example if you need to change a column or use events you need to reference relevant class cl_salv_columns_table or cl_salv_events_table. We wouldn’t be just using this also we should analyze and use its model. After you get familiar with it, you will see that it is the simplest of all ALV tools. To find all kinds of SALV examples just search “SALV_DEMO*” programs via SE38.
Above three practice can be good starting point for people who want to deal with daily programming tasks in object oriented way and next step should be improving modularization approach. When you had experience on all above and focus on having well structured, reusable, single purpose method’s in your developments. It will be easier for you to go one step forward to make complete OO design.
Example ( Using local class for modularization).
Use of methods