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 FM call

Former Member
0 Likes
1,808

Hello,

Is there a way to call dynamically a FM? I can get on run-time the FM name, but what about the export&import parameters? How do you handle that? An example would be very usefull.

Thank you!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,172

Let's say that I have the FM names and parameters in a configuration table. Depending on a selection screen parameter, I must select the proper FM name and parameters and call the FM. The number of parameter differs from one FM to another. So, how can I call the FM?

Hello,

Is there a way to call dynamically a FM? I can get on run-time the FM name, but what about the export&import parameters? How do you handle that? An example would be very usefull.

Thank you!

7 REPLIES 7
Read only

Former Member
0 Likes
1,172

HI George,

Even if you get the function module name at the run time, a function module with that name will still be statically defined in se37.

You can see that in the se37 transaction and find the parameters for the same.

then you can simple use those exporting and importing parameters.

call function v_fm_name

exporting

field1 =

importing fiel2 = ..

Regards,

Ravi

Read only

Former Member
0 Likes
1,172

Hi

U can only manage the name of the fm dynamically, but not the interface.

So you can only manage several fms with the same interface:

DATA: FUNCTION_NAME(30) TYPE C.

IF ......
  FUNCTION_NAME = 
ELSE
  FUNCTION_NAME =
ENDIF.


CALL FUNCTION FUNCTION_NAME
   EXPORTING
      ....................   
   IMPORTING
      .....................

Max

Read only

Former Member
0 Likes
1,172

Hi George,

You can write Case Statement or condition u can branch to the required FM.

Darshan

Read only

Former Member
0 Likes
1,172

i think it is not possible.

but you can do like this

if fmnae = 'ABC'.

call fn 'ABC'.

elsif fmname = 'DEF'.

call fm 'DEF'.

endif.

like that.

regards

shiba dutta

Read only

Former Member
0 Likes
1,173

Let's say that I have the FM names and parameters in a configuration table. Depending on a selection screen parameter, I must select the proper FM name and parameters and call the FM. The number of parameter differs from one FM to another. So, how can I call the FM?

Read only

0 Likes
1,172

Hi!

lv_function = 'function1'.

  • fill itab_para with parameters for dynamic parameters

CALL FUNCTION lv_function

PARAMETER-TABLE itab_para.

Example from ABAP help:

type-pools ABAP.

data NAME type STRING value `ABAP_DOCU_SHOW`.

data PARA_TAB type ABAP_FUNC_PARMBIND_TAB.

data PARA_LINE like line of PARA_TAB.

data AREA(4) type C.

data OBJECT(30) type C.

AREA = 'ABAP'.

PARA_LINE-NAME = 'AREA'.

PARA_LINE-KIND = ABAP_FUNC_EXPORTING.

get reference of AREA into PARA_LINE-VALUE.

append PARA_LINE to PARA_TAB.

OBJECT = 'CLASS'.

PARA_LINE-NAME = 'NAME'.

PARA_LINE-KIND = ABAP_FUNC_EXPORTING.

get reference of OBJECT into PARA_LINE-VALUE.

append PARA_LINE to PARA_TAB.

call function NAME

parameter-table PARA_TAB.

Regards

Tamá

Read only

Former Member
0 Likes
1,172

Hi George,

I think you can use a recording over the transation se 37 and place the function modules name that you have dynamically retrieved there in the func. module name field and then press the run button , in this next screen place the input parameters and then capture the required output value.

Regards,

Sunmit.