OOPS ABAP LOCAL CLASS PROGRAM ON METHODS



PROGRAM ON LOCAL CLASS WITH METHODS

PARAMETERS P_LIFNR TYPE LFM1-LIFNR.
DATA WA_LFM1 TYPE LFM1.

*----------------------------------------------------------------------*
*       CLASS LCL_ABAP DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*

CLASS LCL_ABAP DEFINITION.
  
PUBLIC SECTION.
    
METHODS GET_LFM1_DATA
    
IMPORTING IM_LIFNR TYPE LFM1-LIFNR
    EXPORTING EX_LFM1 TYPE LFM1.
ENDCLASS.                                                                                                                       "LCL_ABAP DEFINITION


DATA OBJ TYPE REF TO LCL_ABAP.
CREATE OBJECT OBJ.                 "OBJECT CREATION

CALL METHOD OBJ->GET_LFM1_DATA                                     " METHOD CALLING
EXPORTING
IM_LIFNR 
P_LIFNR
IMPORTING
EX_LFM1 
WA_LFM1.

WRITE:/ WA_LFM1-LIFNR,WA_LFM1-EKORG,
        WA_LFM1
-ERDAT,WA_LFM1-ERNAM,                              "DISPLAYING THE DATA
        WA_LFM1
-WAERS,WA_LFM1-VERKF.

*----------------------------------------------------------------------*
*       CLASS LCL_ABAP IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*

CLASS LCL_ABAP IMPLEMENTATION.
  
METHOD GET_LFM1_DATA.
    
SELECT SINGLE *
      
FROM LFM1 INTO EX_LFM1
      
WHERE LIFNR IM_LIFNR.
  
ENDMETHOD.
ENDCLASS.                                            "LCL_ABAP IMPLEMENTATION



****************************************************************************
"HERE IN CLASS LCL_ABAP DEFINITON
"1. WE SHOULD ASSIGN AS METHODS FOR INSTANCE.
"2. WE SHOULD ASSIGN AS CLASS-METHODS FOR STATIC.

****************************************************************************
"IN LCL_ABAP IMPLEMENTATION
"1. WE SHOULD ASSIGN AS METHOD FOR INSTANCE.
"2. WE SHOULD ASSIGN AS METHOD FOR STATIC.
****************************************************************************

OUTPUT