Google Search - Blog...........

ABAP - Method Using Internal Table As One Of The Parameters - OOPS Concept.

REPORT YSUBOOPS5 .

types : begin of typ_tab ,
matnr like mara-matnr ,
meins like mara-meins ,
end of typ_tab .

data : itab type standard table of typ_tab ,
x_tab LIKE LINE OF ITAB.

CLASS get_materials DEFINITION.
PUBLIC SECTION.
METHODS : getmara IMPORTING matgr TYPE C
EXPORTING l_tab TYPE ANY TABLE.
endclass.

CLASS get_materials IMPLEMENTATION.
METHOD : getmara .
SELECT matnr meins INTO TABLE l_tab
FROM MARA
WHERE MATKL = matgr.
ENDMETHOD.
ENDCLASS.

PARAMETERS : p_matkl like mara-matkl .

START-OF-SELECTION.
DATA : w_mat TYPE REF TO get_materials.
CREATE OBJECT : w_mat.
CALL METHOD w_mat->getmara EXPORTING matgr = p_matkl
IMPORTING l_tab = itab .
LOOP AT ITAB INTO X_TAB.
WRITE:/5 X_TAB-MATNR , X_TAB-MEINS.
ENDLOOP.

No comments:

Post a Comment