Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic method call

former_member205645
Participant
0 Likes
389

Hello Gurus,

is there any possibility to write something like this in ABAP ??


  CALL METHOD zz_but050=>get_but050
    EXPORTING
    IF X = 1.  i_var_partner1 = l_var_partner1 ENDIF. 
    IF X = 2.  i_var_partner2 = l_var_partner2 ENDIF.
    IMPORTING
      e_tab_but050   = l_tab_but050
    EXCEPTIONS
      keine_daten    = 1.

Best regards,

Ioan Constantin.

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
339

Yes there is. The simplest would be


data: lv_partner  type ...

IF X = 1.  lv_partner = l_var_partner1 ENDIF. 
IF X = 2.  lv_partner = l_var_partner2 ENDIF.

CALL METHOD zz_but050=>get_but050
    EXPORTING
     i_var_partner1 = lv_partner 
    IMPORTING
      e_tab_but050   = l_tab_but050
    EXCEPTIONS
      keine_daten    = 1.

Or you can use dynamic form of CALL METHOD where you pass your parameters by means of PARAMETER-TABLE addition. Please refer [CALL METHOD|http://help.sap.com/abapdocu_70/en/ABAPCALL_METHOD_SHORTREF.htm] -> dynamic form.

Regards

Marcin

1 REPLY 1
Read only

MarcinPciak
Active Contributor
0 Likes
340

Yes there is. The simplest would be


data: lv_partner  type ...

IF X = 1.  lv_partner = l_var_partner1 ENDIF. 
IF X = 2.  lv_partner = l_var_partner2 ENDIF.

CALL METHOD zz_but050=>get_but050
    EXPORTING
     i_var_partner1 = lv_partner 
    IMPORTING
      e_tab_but050   = l_tab_but050
    EXCEPTIONS
      keine_daten    = 1.

Or you can use dynamic form of CALL METHOD where you pass your parameters by means of PARAMETER-TABLE addition. Please refer [CALL METHOD|http://help.sap.com/abapdocu_70/en/ABAPCALL_METHOD_SHORTREF.htm] -> dynamic form.

Regards

Marcin