07.local Classes in SAP ABAP
07.local Classes in SAP ABAP
Local classes in SAP ABAP programming, properties of local classes in SAP ABAP
+ -
Classes are two types in SAP Classes, one is Global class which can be created in SE24 and
second one is local class.Local class is a class which have definition and implementation in a
program .
Syntax for creating local class is :
*CLASS DEFINITION
CLASS <CLASS NAME> DEFINITION. "THIS IS CLASS DEFINITION
<ATTRIBUTES>
<METHODS>
<EVENTS>
<CONSTRUCTOR>
ENDCLASS.
*CLASS IMPLEMENTATION
CLASS <CLASS NAME> IMPLEMENTATION.
*METHODS, EVENTS IMPLEMENTATION
ENDCLASS.
ENDCLASS.
Learner Questions
V
Implement class
CLASS CL_ATTRIBUTES IMPLEMENTATION.
*LEAVE BLANK FOR THIS EXAMPLE
ENDCLASS.
Using class
DATA : LO_ATTRIBUTES TYPE REF TO CL_ATTRIBUTES. "DECLARE CLASS
CREATE OBJECT LO_ATTRIBUTES. "CREATE OBJECT
LO_ATTRIBUTES->PA_NAME = 'SACHNTHENDULAKR'. "ASSIGN A VALUE TO INSTANCE
ATTRIBUTE
CL_ATTRIBUTES=>PA_NANE_ST = 'PONTING'. "ASSIGN VALUE TO STATIC ATTRIBUTES
*PRINT ATTRIBUTES VIA CLASS
WRITE:/ 'INSTANCE ATTRIBUTE:', LO_ATTRIBUTES->PA_NAME.
WRITE:/ 'STATIC ATTRIBUTE :', CL_ATTRIBUTE=>PA_NAME_ST.
Learner Questions