Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  CLASS →  CLASS - DEFINITION 

PUBLIC SECTION

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


PUBLIC SECTION. 

Effect

This statement can only be used in the declaration part of a class. It defines the public visibility section of the class class. All components of the class that are declared after the statement PUBLIC SECTION are accessible from outside the class, in their subclasses, and in the class itself as long as this permitted by the package concept. Public methods in particular can be redefined in subclasses.


Example

Declares a public constant const and accesses it from outside of the class.

CLASS cls DEFINITION. 
  PUBLIC SECTION. 
    CONSTANTS const TYPE string VALUE `I'm public`. 
ENDCLASS. 

START-OF-SELECTION. 
  cl_demo_output=>display( cls=>const ).