I know, it's a silly example, maybe is one of the most simple examples ever, however is also an easy way to explain classes and what could be achieved. My goal is to show most of the code that is used to define and implement classes.

Classes in ABAP are coded in two steps: first of all you code the definition part and then the implementation part.

The definition part, as you may imagine, is the place where you define all the data and methods that are going to be used in the class. Here you must specify the public, private and protected sections also they have to be placed in the order you see in the code otherwise you will a syntax error.

By definition classes can be defined as normal, abstract and inherited. For example:

For any given class is only necessary the following:


1
2
class myclass definition.
endclass.

For an abstract class the code is:

1
2
class myclass definition abstract.
endclass.

This kind of class cannot be instantiated.

And for an inherited class or subclass the code is:




Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com 



1
2
class myclass definition inheriting from abstractclass.
endclass.