How to convert an existing ABAP Report to OOPs ABAP?

My first OOPs Program

In the previous article ‘Just 4 Versions of the same program to learn OOPs ABAP‘ we saw how an ABAPer can evolve from the procedural programming to Object Oriented. In this post, we have added on the same program. Instead of just one PARAMETER in the selection screen, we have two SELECT OPTIONS. We have two RADIO BUTTONS which has to be handled and there would be two data fetching SELECTs.

Let us see the existing program which is present in the system. It takes transaction code or role as input and displays the classical report as output. If you scan through the below code, you would find that this is pure procedural language along with some old programming style (internal table with header lines and classical reporting).

Existing Report in traditional ABAP Procedural way

Let us execute the program and see the output.

ABAP Objects


SAP ABAP Technical

SAP ABAP for Beginners

The above program was developed in 2000 era. In 2016 you receive a Scope Change Request (SCR) to convert the existing report to OOPs ABAP Report. Lucky ABAPers, who are looking for opportunity to implement OOPs theoretical knowledge to actual practical use, would jump off the seat to accept this work. 🙂

Also Read: Back to Basic

I am sure, all of you know OOPs concepts and theories right from your school and college days where you learnt C, C++ or Java. But destiny made you work in procedural ABAP. Here, we would not speak about theory. Just look at the above code and start writing your own OOPs program which would do the same thing as the above report. Plan out how you would handle the INITIALIZATION. Do you need any global/public attributes (variables)? Can we reuse one object instance in another object? After all that is one core fundamentals of OOPs.

Try to write your own program whenever you have time. That is the best way and the only way to learn OOPs. After all, you all know theory. Hands On is what differs us from the crowd. 🙂

If you have read the previous post on OOPs ABAP, you already know that we have divided our report into three local classes (roughly to follow MVC – Model View Controller Architecture). Class 1 for Selection parameter, Class 2 for Data Fetching and Class 3 for Display.

Before we proceed, let me show you two code snippets.

What is the difference between method FACTORY and VALIDATE_INPUT  in the below OOPs Report?

Why is FACTORY method called using ‘=>’ but VALIDATE_INPUT using ‘->’ ?

You guessed it right. One is a STATIC method and another is INSTANCE method. STATIC is called using ‘=>’. You will know this only if you start coding. So log into your system as soon as you get time and try to call one STATIC and one INSTANCE method in a test program.

Read more: Static and Instance Method difference.

STATIC and INSTANCE Method Difference

Let us look another section of the program. Why is there no EXPORTING while creating object O_SELECTION, while O_FETCH and O_DISPLAY has EXPORTING parameters? Child’s play for experienced OOPs ABAPers. Please do not laugh at me if you think it is too silly. 🙂

Answer for the newbies. We always read in theory, CONSTRUCTOR method is called the moment we create the OBJECT instance. Class LCL_REPORT_FETCH and LCL_REPORT_DISPLAY both have CONSTRUCTOR method which needs some IMPORTING parameters. If you do not pass those parameters while creating the Object, your code will not be syntactically correct.

You need to log into SAP system now. Try the code yourself to see it. These are simple stuff which we cannot learn by reading PPTs and PDFs. We need to make our hands dirty.

Finally, why did we NOT default the public attribute (variable) of class LCL_REPORT_SELECTION at INITIALIZATION? Simple, users enter the selection screen options after INITIALIZATION is done. So AT SELECTION-SCREEN is the right place to capture the screen values. Too basic, but not sure why I felt like tell this too. 😛

Rest all code is pretty straight forward. Give special attention to the CONSTRUCTOR methods of FETCH and DISPLAY class. We have passed the whole object data of SELECTION class to FETCH object. Similarly, the complete data of FETCH object is passed to DISPLAY.

Put the breakpoint at both the CONSTRUCTOR methods. Execute the program and check that the SELECTION object and FETCH object during INITIALIZATION is blank in the two CONSTRUCTOR methods but the container is ready. When you use the other method for FETCH object, the SELECTION container which was blank in INITIALIZATION has data in the container. That is the beauty of OOPs. It is like Pointers in C. The address is populated with the actual data.

Also Read: 15 minutes Videos per session for ABAP OOPs Refresher

Check at initialization, the SELECTION object attributes are empty/blank. But the container is ready.



When the program goes to SELECTION SCREEN, we have logic in place to populate SELECTION object attributes. But we do not pass this attribute explicitly again to FETCH object. But, when we are in another method of FETCH, the SELECTION object attribute which was initialized in CONSTRUCTOR method of FETCH is already populated. This is one concept of OOPs which we have unknowingly used. You need to debug for more clarity.

i.e. the CONTAINER for FETCH which was created in the CONSTRUCTOR method of FETCH during CREATE OBJECT command is automatically populated as soon as the O_SELECTION OBJECT populates the data.

Pointers in SAP

Enough of trailers. Let us reveal the full movie. Please go through the code below. Try to debug every step and understand the concept. I am sure, this is not the best OOPs programming, but it should be sound enough for beginners like me.

Interested in HANA? Check, SAP HANA for Beginners from a Beginner.

I would like to call upon all experienced OOPs ABAPers and enthusiast to point out the issues in the below OOPs Report. Please reveal, how we could have made the Report better in OOPs. Please leave your suggestions so that our freshers in OOPs ABAP could learn from your experience and knowledge.

Same Report in OOPs ABAP.

Needless to say, the output would be same. We are displaying an ALV report instead of classical report.

Object Oriented Programming

OOPs Report

OOPs for Freshers


We cannot change any habit overnight. Similarly, an ABAPer who is accustomed to procedural language may not be comfortable with OOPs ABAP in a day or two. It is a continuous process of learning from the mistake and improving oneself.

So do not wait further. Let your starting few OOPs programs be very basic. But let us make a habit to change from procedural to object oriented.

If you want to get such useful articles directly to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons and like us on facebook.

Do you have anything to add to this article? Have you faced any issue using OOPs? Do you want to share any real project requirement or solutions? Please do NOT hold back. Please leave your thoughts in the comment section.

We love to hear from you. Please provide your feedback (good and not so good). 🙂

Thank you very much for your time!!

Did you check our below popular Tutorials?

1. ABAP for SAP HANA Tutorials
2. ABAP Web Dynpro Tutorials
3. GOS Tutorial
4. OOPs ABAP Tutorial
5. HANA Tutorial
6. SAP Netweaver and OData Tutorial
7. SAP Adobe Form Tutorial
8. SAP Fiori Tutorial
9. SAPUI5 Tutorial



Leave a Reply to Deep Cancel reply

Please enter your comment!
Please enter your name here