Get Example source ABAP code based on a different SAP table
ID PRIVATE • PRIVATE SECTION ABAP Statement
PRIVATE SECTION>
ABAP_SYNTAX PRIVATE SECTION.>
What does it do? This statement can only be used in the declaration part> of a class and defines the private visibility section> of the class class>. All components of the class that are declared in the area after the statement PRIVATE SECTION> can only be addressed in the class itself and in its friends>.
Latest notes:
The class is the smallest encapsulation unit in ABAP Objects. Therefore, a method can use all private components of all instances of the same class, apart from the private components of its own class. An exception to this rule are subclasses that cannot access the private components of superclasses if they are not their friends>.
The declaration of attributes in the private section does not prevent methods of the class from passing references > to these attributes to the outside in the form of reference variables> or field symbols>, which makes the attributes visible and modifiable outside the private section.
Private components declared in a class but not used statically there produce a warning in the extended program check. NON_V5_HINTS ABAP_HINT_END BEGIN_SECTION SAP_INTERNAL_HINT Unfortunately, local classes of a class pool can access certain private components of the class pool's global class without being friends, e.g. user-defined structures or data objects typed with dictionary types. See SAP Note 2984450. END_SECTION SAP_INTERNAL_HINT
ABAP_EXAMPLE_VX5 Declaration of a private constant const> in a class cls1> and uses it as a start value of a public attribute of a friend cls2 >. ABEXA 00500 ABAP_EXAMPLE_END