oops abap own material

Upload: sriplns

Post on 03-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Oops Abap Own Material

    1/3

    Class Declaration :

    CLASS DEFINITION .

    PUBLIC SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declarationPROTECTED SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declaration

    PRIVATE SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declaration

    ENDCLASS.

    Class Definition/Implementation :CLASS IMPLEMENTATION.

    METHOD : . "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 : TYPE REF TO .

    CREATE OBJECT : .

    CALL METHOD : -> . "calling methods usingobjects.

    -> "CALLING MEMBER DATA

    Inheritance (parent -----> child) :CLASS DEFINITION INHERITING FROM < parent class name>.

    PUBLIC SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declaration

    PROTECTED SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declaration

    PRIVATE SECTION.

    DATA : TYPE VALUE ''.

    METHODS : . "method declaration

    ENDCLASS.

  • 7/28/2019 Oops Abap Own Material

    2/3

    Global Definitions :

    TYPES : BEGIN OF ,

    DATA : TYPE , type , GLOBAL AREA

    END OF TYP_TAB . THIS DATA CAN BE USED INCLASS DEFINITION,IMPLEMENTATION

    DATA : TYPE .

    CLASS c1 DEFINITION .public section.methods : .

    DATA : TYPE type standard table of , like line of .

    ENDCLASS.

    CLASS c1 IMPLEMENTATION.

    method : ."append work area to internal table."looping internal table to work area.

    endmethod.endclass.

    One Class Object Creation In Another Class :

    class definition.public section.

    methods : .endclass.

    class definition.public section.

    methods : .endclass.

    class implementation.method :.endmethod.

    endclass.

    class class2 implementation.

    method : .data : type ref to .create object obj1.call method obj1-> .

    endmethod.endclass.start-of-selection.

    data : type ref to .create object : .call method -> .

  • 7/28/2019 Oops Abap Own Material

    3/3

    If we want to give class definition later we use below statement :

    CLASS DEFINITION DEFERRED.

    CLASS DEFINITION.

    PUBLIC SECTION.DATA TYPE REF TO .

    ENDCLASS.

    CLASS C2 DEFINITION.

    ENDCLASS.

    start-of-selection.data : type ref to .CREATE OBJECT .

    create object -> .

    Put Non-Declarative Statements In Start Of Selection :

    class definition.

    endclass.

    class implementation.

    endclass.

    Any statements after definition and implementation of class should be in

    start-of-selection.

    .....

    ..... "non declarative statements