Object Oriented Programming & System - ABAP
Object Oriented Programming & System - ABAP
System - ABAP
Subtitle
CLASS :
• Cl a s s i s a c ol l e c t i on of c om pone nts /Obj e c ts ( Att ri bute s + m e thods + e v e nts +
i nterfa c e s + a l i a se s + m a c ros ) .
• PUBLIC: Publ i c components can be access anywhere (it can be access within the
class or outside of the class ).
• Private: Publ i c c o m p o n e n t s c a n b e a c c e s s a n y w h e re ( i t c a n b e a c c e s s w i t h i n t h e c l a s s o r
outside of the class ).
• Protected: Publ i c c o m p o n e n t s c a n b e a c c e s s a n y w h e re ( i t c a n b e a c c e s s w i t h i n t h e c l a s s
or outside of the class ).
Example …
• CLASS TEST DEFINITION.
PUBLIC SECTION .
DATA : X TYPE I. " INSTANCE ATTRIBUTE..
EXAMPLE
INSTANTIATION OF CLASS
• DATA OBJ1 TYPE REF TO TEST." refe
rence-alias for class ..
1. D e cl ar e r e fe r e n ce .
• CREATE OBJECT OBJ1. " object-
• Da t a Obj 1 t y pe re f to e m p. allocate memory for instance Attribut
e ..
2. C r e at e o bj e ct base d o n
OBJ1->X = 1000.
r e fe r e n ce
OBJ1->Y = 2000.
OBJ1>Z = 333000." SYNTAX ERROR BECAUS
• Cre a te Obj e c t Obj 1 .
E OF CONSTANT VALUE ...
• WRITE :/ OBJ1->X,
OBJ1->Y,
OBJ1->Z.
Diff erences:
STATIC CONSTANT
• St a ti c c a n be m odi fi e d. • Cons ta nt c a n not m odi fi e d.