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

ABAP - OOPS: Use Of Parameter Table Keyword In Method Programming.

For dynamic method call, one can use the concept of PARAMETER TABLE to include references of all interface parameters of the method(instead of mentioning them separately).
-------------------------------------------------------------------------------------------
REPORT YSUBOOPS24 .

DATA : i_result type i,
i_num type i value 5 .
DATA f(2) TYPE c VALUE 'M1'.

CLASS cl_abap_objectdescr DEFINITION LOAD .

DEFINE : poptable.
ptab_line-name = &1.
ptab_line-kind = CL_ABAP_OBJECTDESCR=>&2.
GET REFERENCE OF &3 INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.
IF sy-subrc ne 0.
EXIT.
ENDIF.
END-OF-DEFINITION.

CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS m1 IMPORTING p1 TYPE i
exporting p3 type i .
ENDCLASS.

CLASS c1 IMPLEMENTATION.
METHOD m1.
p3 = p1 + 200.
ENDMETHOD.
ENDCLASS.

DATA r TYPE REF TO c1.
DATA: ptab TYPE abap_parmbind_tab,
ptab_line LIKE LINE OF ptab.

START-OF-SELECTION.

poptable : 'P1' EXPORTING i_num ,
'P3' IMPORTING i_result .

CREATE OBJECT r TYPE c1.
CALL METHOD r->(f) PARAMETER-TABLE ptab.
write:/5 i_result .


Output 205

No comments:

Post a Comment