Class Declaration

:
CLASS <class name> DEFINITION . PUBLIC SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration PROTECTED SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration PRIVATE SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration

ENDCLASS.

Class Definition/Implementation :
CLASS <class name> IMPLEMENTATION. METHOD : <method name>. "method definition "write statements , member data access e.t.c,....

ENDMETHOD. ENDCLASS.

Object Creation And Data Accessing :
START-OF-SELECTION. "object declaration usually in start-of-selection DATA : <object name> TYPE REF TO <class name> . CREATE OBJECT : <object name>. CALL METHOD :<object name> -> <method name> . <object name> -> <MEMBER DATA> "calling methods using objects.

"CALLING MEMBER DATA

Inheritance (parent -----> child) :
CLASS <child class name> DEFINITION INHERITING FROM < parent class name>. PUBLIC SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration PROTECTED SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration PRIVATE SECTION. DATA : <var> TYPE <data type> VALUE '<value>'. METHODS : <method name>. "method declaration ENDCLASS.

class <class name2> definition. "looping internal table to work area. GLOBAL AREA END OF TYP_TAB . endmethod. ENDCLASS. public section. methods : <method name2> . public section.Global Definitions : TYPES : BEGIN OF <structure name> . endclass. DATA : <var> TYPE <data type> . endmethod. One Class Object Creation In Another Class : class <class name1> definition. call method obj1-> <method name1>. methods : <method name1> . start-of-selection. <work area name> like line of <structure name>. method : <method name> . "append work area to internal table. data : <obj1> type ref to <class name1>. method :<method name1>. endmethod. methods : <method name> . public section. call method <obj2> -> <method name2>. method : <method name2>. DATA : <var> TYPE <datatype> <internal table name> type standard table of <structure name>. CLASS c1 DEFINITION . endclass. CLASS c1 IMPLEMENTATION. endclass.IMPLEMENTATION DATA : <var> TYPE <data type> . create object obj1. data : <obj2> type ref to <class name2>. endclass. THIS DATA CAN BE USED IN CLASS DEFINITION. <var1> type <data type> . class <class name1> implementation. create object : <obj2>. endclass. . class class2 implementation.

Put Non-Declarative Statements In Start Of Selection : class <class name> definition. start-of-selection.... .. ENDCLASS.. DATA <Obj name2> TYPE REF TO <Class name2>. CREATE OBJECT <obj name1>. endclass. CLASS <Class name1> DEFINITION.. PUBLIC SECTION. data : <obj name1> type ref to <Class name1>.. Any statements after definition and implementation of class should be in start-of-selection. ENDCLASS. CLASS C2 DEFINITION. "non declarative statements . .If we want to give class definition later we use below statement : CLASS <Class name2> DEFINITION DEFERRED. class <class name> implementation. endclass. create object <obj name1> -> <object name2>..

Sign up to vote on this title
UsefulNot useful