Local And Global Classes
Classes in ABAP can be either local or global.
Global classes are stored centrally and are contained in their own repository object called a class pool. A global class can serve as main program. Global classes can also contain logic to be reused by other ABAP programs, including other global classes.
Local classes are defined as part of an ABAP program, for example a global class. You can use them only in the program or class in which they are defined. Local classes are useful for entities or functions that you only need in a single program.
The ABAP syntax of both local and global classes is almost identical. In this course, you will be working with local classes in your global class. The global class with method if_oo_adt_classrun~main will only serve as a kind of main program.
Local Classes in Global Classes
As shown in the figure below, when you open a global class in ADT, the focus is on tab Global Class, first. Here you find the source code of the global class itself. To see or enter the source code of local classes, you have to navigate to tab Local Types.
ADT provides a source code template for local class. To use this template proceed as follows:
- In the ABAP editor, type lcl and press Ctrl + Space.
- From the list that displays choose lcl - Local class and press Enter.
- Adjust the name of the new local class.
For the classes in this course you have to remove the create private addition from the CLASS … DEFINITION statement.