12-06-2012, 05:12 PM
Local and Global Classes
Local and Global Classes.pptx (Size: 582.29 KB / Downloads: 31)
There are two type of classes in ABAP - global and local.
You can define the global classes in the Class Builder (Transaction SE24) in the ABAP Workbench.
They are stored centrally in class pools in the class library in the Repository.
All of the ABAP programs in a System can access the global classes.
Defining Local Classes
A complete class definition consists of a declaration part and an implementation part. The declaration part of a class <class> is a statement block:
CLASS <class> DEFINITION. ...ENDCLASS.
It contains the declaration for all components (attributes, methods, and events) of the class. When you define local classes, the declaration part belongs to the global data. You should therefore place it at the beginning of the program.
Class Components
The components of a class make up its contents. All components are declared in the declaration part of the class. The components define the attributes of the objects in a class. When you define the class, each component is assigned to one of the three visibility sections, which define the external interface of the class. All of the components of a class are visible within the class. All components are in the same namespace. This means that all components of the class must have names that are unique within the class.
Attributes
Attributes are internal data fields within a class that can have any ABAP data type. The state of an object is determined by the contents of its attributes.
Instance Attributes
The contents of instance attributes define the instance-specific state of an object. You declare them using the DATA statement.
Static Attributes
The contents of static attributes define the state of the class that is valid for all instances of the class. Static attributes exist once for each class. You declare them using the CLASS-DATA statement. They are accessible for the entire runtime of the class.