Skip to Content

Three simple use of object oriented concepts in your daily work

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

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).



Global reference


Instance creation


Use of methods



You must be Logged on to comment or reply to a post.
  • , 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,”

    Definitely the case. Even new developments are using ON CHANGE. Or standard tables with header lines and binary search to read from them. It seems “around for over 15 years” is still to modern for some “programmers”.

    Of course, it’s still possible to program procedurally with methods and classes… to get all the advantages of OO development, you need to understand OO concepts. I did this by learning Java using the excellent “Head First” books.

    • Agreed in almost, but not quite, all respects.

      Having every developer switch to OO development would not neccessarily improve the results.

      OO lives on proper design – and dies on bad one. Knowing the code of several fellow developers, i’d prefer they continue procedural, just in case i’d be tasked with the maintenance of one of their programs.

      In procedural coding, some are able to keep a certain level of reasonable maintainability, even with massive code redundancy, forms whithout parameter (thanks to global data), pagelong if – elseif construction and, notabene tables with headerline. But force them to do the same in OO and you will turn away and weep silently.

      I don’t support sticking to the old ways, but for one or the other additional decade, until the last dinosaur has retired, we will have to make do with whatever developers we got. After all, you can’t just unemploy them all at once, just because they’re not on the edge of technology.

      Have a look around in this forum and you will notice, that even now, new dinosaurs are still hatched, sticking to the old ways and even worse, passing them down to next generation.

      In my experience, developers who wrote neat code in the past, don’t have too much problems with the transition to OO. But those who can’t will only produce gibberish.

      There is no such thing as a global truth – pick out what works best for you.
      I say, leave the procedural for those who otherwise must despair. For the rest of us – go for it. Keep learning.

      Best regards – Jörg

      • until the last dinosaur has retired”

        It will never happen. As I said: Even new developments are using ON CHANGE. Or standard tables with header lines and binary search to read from them. It seems “around for over 15 years” is still to modern for some “programmers”.

      • I do agree that making people go OO without understanding OO design is a catastrophic.

        But the problem is that new people are being trained by the dinosaurs, for whom AiE is the devil. Asking for a programmer that knows OO ABAP is still something strange, and people behave as if I’m being elitist.

        And these dinosaurs will be replaced by the new dinosaur that they trained.

        PS: I learned OO for Objective-C and iOS ๐Ÿ™‚

        • Point taken.

          So here is my suggestion to SAP.

          Make the Syntax-Check and SLIN create flexible response.

          Meaning beeing mor lenient with older programs stricter for newer and finally inhibiting certain constructs for new objects.

          The basic idea is already used in the separation of OO and classic.

          Thus, even the hard headed would be motivated to either evolve or make themselves comfortable in maintenance for dinosaur programs.

          • Global variables are the bane of my existence, but they are required for SE51 programs, which are the worse kind of programming I’ve ever seen in my life. Block them and you have a riot ! ๐Ÿ™‚

            It must be hell to maintain some SAP transactions…

          • Have you ever seen a road train going at full speed?

            Well, this is about how agile the it-infrastructure of a large company is, and about how fast they can or will change course.

            That is, i’m looking forward to at least another decade whithout beeing able to use ABAP in Eclipse ๐Ÿ™

          • What’s the difference between <insert your company here> and Jurassic Park? One is a dreamland full of old dinosaurs. The other is a film by Steven Spielberg.

            One of my clients is the HR IT of a very large multinational. They’re on 7.4 already. They’ve built an entire object oriented framework which is used for all reporting needs. Fast and responsive is possible even with the biggest company… when the business want the latest toys.

            I must get around to installing AiE.

          • I do mostly implementations and then go to the next one, so lately I have only used 7.4 systems, but the reason I don’t use AiE all the time is that SAP Logon uses the SAP Router to login even without VPN, while AiE uses HTTP and doesn’t work without them….

            I can connect the VPN, but …. I prefer having internet available ๐Ÿ™‚

        • Asking for a programmer that knows OO ABAP is still something strange, and people behave as if I’m being elitist.

          Or being a developer that tries to use OO instead of procedural development can be a pain too when the customer (or responsible or whoever got the last word) do not thrust “all these new techies” and prefer to stick in his/her comfort zone full of standard tables, select…endselect and so on.

      •                             Jörg Wulf wrote:

        OO lives on proper design – and dies on bad one. Knowing the code of several fellow developers, i’d prefer they continue procedural, just in case i’d be tasked with the maintenance of one of their programs.

        Exactly. Just last year I had to make some changes in what could’ve been a simple ALV report but instead was done as something the author probably thought was OOP. It was not in any way better than a decent procedural program.

        But I do applaud to the author’s effort in sharing simple and practical advice. It certainly does more good than just waving flags from a high horse. I remember very well when I first read this blog and thought “hey, I can do even more and better stuff easier with this class than with the good old function module – sign me up!”. That’s how you get people to adopt (coming from a dinosaur ๐Ÿ™‚ ).

  • Few days ago I’ve run into a joke.

    Some of the questions for interviewing a programmer:

    1. Have you ever simulated (or faked – dunno what’s more precise) OOP?

    2. Have you ever been held liable for storing data in global variables?

    3. How often do you say “Oh, please!” to your code?

    4. Can you draw an analogy between a 5-year project and proctology?

    6. Xbox, PlayStation or Terminal – what’s your console?

    7. 2048 or Solitaire? Where you’re more successful?

    8. Write a simple operating system. Confine yourself to 140 characters.

    9. Where do you see your code in 5 years?

    10. You got a pencil, a canvas and a drawing easel. Write a compilator.

    What’s the point of this comment? Well, just relax, have fun and use OOP ๐Ÿ™‚

  • I’ve had a very nice experience putting the model/view/controller concept in action in ‘old school’ ABAP.

    We created a base ‘view’ class around CL_GUI_ALV_GRID (the grid is an attribute of our base class). For all the different views (alv grids) we needed, we have subclassed  that base class to implement specific layouts, titles, editable, drag/drop, etc…

    For the model, we’ve created a model interface. Our model classes implement this interface. Each model class has a data table of whatever kind it needs and each model class implements its own ‘select_from_database’ method to pull the data it will work with. The nice thing now is that our base view class can be passed this model and so the model can share its table with the grid directly (i.e. there is only 1 table in memory). The view class calls the ‘refresh’ method of the model as and when needed.

    We’ve also got instances where one model feeds data into another model. This can be done very elegantly.

    For the controller layer, we simply use SE38 /SE37. These usually just have a model and a view object at the top and the usual dynpros with PBO and PAI. But they are very simple because all the hard work is done in the model and the view classes.

    Does anyone recognise this as something they’ve used?

    Happy to post the code if anyone is interested.

    • I’ve done something similar. All the work of the dynpro is handled by the view class. When I switched from a SALV table to standard ALV, I just had to adjust the view class and nothing else.

      The dynpro’s only global data are OKCODE and a reference to the view class.

    • Sounds interesting. I’d also like to see the code if possible, please.

      I like the “interface” based approach you used for the model, because that really helps a lot when you go for unit testing. I’m just wondering why the ‘view’ class has a select_from_database method. I’d expect a view to handle data without being tied up to certain data access method to provide SOC.



    • Nice design Jurgen!

      I have done something similiar for a big project but with a difference. The model(s) I have created take advantage of ABAP Persistent classes, so we had one more level of abstraction from the database, and no need to code the access to the database layer since it was done by our persistent classes.

      The presentation layer was done with Web Dynpros and it was amazing to see the reaction of the business people when changes arrive. With a proper architecture, reaction to change is quick and eficient, which is not possible(or simple too complex) to achieve with procedural paradigm.



  • Hi Gungor,

    Great blog I really like this. I did not know subroutines were classed as obsolete, probably because the extended program check does not flag them as such. I don’t spend much time coding these days, as it is spent working with PI, but when I do it is OO methods that I use. At first I struggled with what to do with globals but learnt how to move them into class definitions. It is a struggle at first but once you get started it starts to flow and then you can reuse the same concepts with every new program you write.


  • I am working on a project where a company bought another one. Both have SAP so this made us meet the SAP technical team on the other side.Their (spiritual) leader has introduced this approach. We are adopting it in our team as well. It is actually making us use more OO than before.

    Before we would say:”we should start developing in OO” but nobody moved. Just warming up on the sidelines.

    With the new approach, we take little steps and slowly get used to it.

    Overall OO proficiency is rising!

    You know who does not like it? Functional people. They can’t read the code anymore. ๐Ÿ˜‰

    • Funny, the functional people I work with tell me they read OO better then procedural because it’s related to business (objects).