Ex :-
Steps : -
- Go to Transaction Code SE38.
Source Code
CLASS C1 DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS : FETCH_DATA ABSTRACT IMPORTING IM_VBELN TYPE VBAP-VBELN
CHANGING CH_ITAB TYPE VBAP_T,
DISPLAY IMPORTING IM_ITAB TYPE VBAP_T.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD DISPLAY.
DATA : WA_VBAP TYPE VBAP.
LOOP AT IM_ITAB INTO WA_VBAP.
WRITE : / WA_VBAP-VBELN , WA_VBAP-POSNR , WA_VBAP-MATNR ,
WA_VBAP-ARKTX, WA_VBAP-NETWR.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
CLASS C2 DEFINITION INHERITING FROM C1.
PUBLIC SECTION.
METHODS : FETCH_DATA REDEFINITION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD FETCH_DATA .
SELECT * FROM VBAP INTO TABLE CH_ITAB WHERE VBELN = IM_VBELN.
ENDMETHOD.
ENDCLASS.
" Main program
DATA : OBJ TYPE REF TO C2.
DATA : IT_VBAP TYPE TABLE OF VBAP.
PARAMETERS : P_VBELN TYPE VBAP-VBELN.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->FETCH_DATA
EXPORTING
IM_VBELN = P_VBELN
CHANGING
CH_ITAB = IT_VBAP
.
CALL METHOD OBJ->DISPLAY
EXPORTING
IM_ITAB = IT_VBAP.
No comments:
Post a Comment