The public section is the place where you declare information that is visible outside the class, the data and method are exposed. The private section has members that are internal and can't be exposed outside the class even within subclasses. The protected section has information that is exposed or is visible only internally and along all the child classes.

In every section you can specify instance data and methods and also class data and methods. The diference between instance members and class members is that for the the first ones it is necessary to create the object (we'll get there soon) to use those members and in the second ones is not necessary the instantiation, we can use them directly from the class with a special sign  (=>) and for the other instance data and methods it is used the (->) sign.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class cl_animal definition abstract.
  public section.
    methods: constructor importing i_name type string, " Visible to everyone
             make_a_sound,
             my_name_is,
             get_type.

  protected section. " Visible only here and in child classes
    data p_class type string.

  private section. " Visible only internally
    data p_name type string.
endclass.
 
 
 
 
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com