Skip to Content
Technical Articles
Author's profile photo Shivani Sahu



I’m writing this blog to provide an overview of how to define the ABSTRACT CLASS in Local Class & Global

Class. Many beginner developers working in SAP ABAP OOPs, need to be familiar with OOPs concept. One of the concepts is ABSTRACT CLASS & METHOD is explained here.

Readers will be able to understand how to create Abstract Class in Global Class & Local Class as well.


Part 1 – Define Abstract Class in Global Class.

Part 2 – Define Abstract Class in Local Class.

In this blog post, I hope readers can learn:

  1. What is Abstract Class?
  2. Where to use Abstract Class?
  3. How to define abstract in SAP ABAP?


Abstract Class is a special type of class which has at least one abstract method. Abstract method is that method which has only definition, this means it does not contain implementation of the method Only a Declaration. We can create object of only subclass of Abstract Class.

Note: We cannot create object of Abstract Class.

Where Abstract Class Should be used?

  1. As Abstract Class is flexible in nature, so we can use to create multiple flavors of the object with some default operations.
  2. Abstract Class should be used for those classes which are closely related to each other.
  3. Abstract Class allows you to partially implement your class.

How to create Global Abstract Class?

Steps1:  Use Tcode SE24 to create Abstract Class. Enter the name of Abstract Class and click on Create button.

Step2: By default, Class will be selected. Press Enter/Green Button.

Step3: Enter the description of class. Make sure that Final checkbox should be unchecked.

Note: We cannot create object of Abstract Class, so we have to create subclass for this parent class. Final Class will not allow us to create the child class.

Step4: Save the Class in local object or if we have any particular package, then mention the package in Package field.

Step5: Create an instance method in Method tab. Keep your method as Public.

Step6: Define the parameters for your method.

As I want to display details like first name, second name, city, house number of customer w.r.t the customer number from table KNA1.

Step7: For creating any method as abstract: Click on Goto properties. A new pop up will open.

There you have to select Abstract checkbox and click on Change button.

Step8: Once you select the Abstract checkbox, one more popup will appear. Click on green button.

Step9: Once you click on green button, method will be set to Abstract method.

Step10: Now we have to create a child class for this Abstract class, so that we can write the logic for the method. Repeat Step 1, Step 2, Step 3 & Step 4 for creating a class.

Step11: Go to properties tab. Select Superclass option. Enter the name of abstract class in superclass field. Press enter key.

Note: As you press enter key, it will show the same method in method tab (which is present in Abstract class).

Step12: Still the Display Method is Abstract method. It means we cannot write the logic. For this we need to redefine the method. For redefining the method, select redefine tool.

Step13: Now we can write the logic.

Step14: Create a class in SE38 and call the method.

Parameters: p_kunnr type kunnr.
data: object1 type ref to zabstract_child_7.
data: lv_first_name type NAME1_GP,
    IV_CUST_NO     = P_KUNNR
    EV_CITY        = LV_CITY
      / 'CITY NAME:', LV_CITY,


In summary, developers can write more modular, flexible, and maintainable code by leveraging OOP concepts like abstract in SAP ABAP. Abstract Class is used to write different logic in different derived classes instead of making change in original class. If we make the changes in the original class, then it will affect all the programs where we had used that class. We can create different classes for each scenario but to achieve reusability feature of OOPs, then abstract class comes into action.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Ashutosh Tewari
      Ashutosh Tewari

      Very well done. Very much needed blog to explore and start. Great work. Looking forward to many more such blogs on this. 🙂

      Author's profile photo Neha Singh
      Neha Singh

      Thankyou! this will help every developer to understand and work on it. Great Work.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      CALL METHOD is very old fashioned. Nowadays

      object1->display( EXPORTING iv_cust_no    = p_kunner
                        IMPORTING ev_first_name = lv_first_name ... )

      is to be preferred. Also, please edit your blog so that the code is in a code block (like I've done above), using the {;} button. This way your examples can be copy pasted.

      What you have not done is explain under what circumstances you would want to use an abstract class.

      Your code won't work because you haven't instantiated object1. I would use

      DATA object1 TYPE REF TO zabstract_7.
      object1 = NEW zabstract_child_7( ).

      This also demonstrates one of the uses of an abstract class - you have multiple implementations of the method, but to use the methods, you don't need to know what the concrete type is.

      Finally, you've declared your variables with an L prefix, when in the context they're clearly global. 

      Author's profile photo Shivani Sahu
      Shivani Sahu
      Blog Post Author

      Hello Mathew,

      Thank you for your response and providing me the correct information. I've changed the mode of code.

      In the part of calling object, I've used 'Pattern' so that's why it is showing you in the old-fashioned form.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      You can get code completion of the modern form using Ctrl-Space. Also works in Eclipse.

      Another tip: instead of write, use CL_DEMO_OUTPUT. See any blog by Horst Keller for examples!

      Author's profile photo Prerna Pradeep Sahu
      Prerna Pradeep Sahu

      Much needed info & Amazing write-up!.