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

using Dynamic Function module

Former Member
0 Likes
678

Hi,

I have requirement where have to call FM dynamically. I need to check if the IS OIL switch is on, than call the OIL FM otherwise normal FM.

Problem is when the IS OIL switch is off, the Oil FM will not be present and will give syntax error. Hence the requirement to use dynamic FM calling

I went through some site & found how to use this FM. But in those FM you have declare data type of Input/export parameter.

Since in absence of Oil switch this data corresponding data element & domain would also be not there, I need to used this data declaration also dynamically.

Is there a way i can code for the above requirement to use Data declaration & FM dynamically, without giving syntax error.

Thanks,

Harish

4 REPLIES 4
Read only

Former Member
0 Likes
599

Hi,

You can check the if the function name exists in table TADIR with object=FUGR , obj_name=function_name.

Best regards,

Leandro Mengue

Read only

0 Likes
599

Hi,

Thanks for the reply. In this case let's say i will code like this.

If FM exists call FM else not.

For the calling FM dynamically i have to pass the parameter

let's say i write like something here

Data : I_CHARG like OIB_DEF_INDEX_GM-CHARG. u201C First export paramter

DATA: ptab TYPE abap_func_parmbind_tab,

ptab_line TYPE abap_func_parmbind,

func TYPE string.

Func = u2018OIB_QCI_READ_CONV_PARAMETERSu2019 " FM name

    • Exporting value 1

I_CHARG = 'XYZ'

    • Add into dynamic table

ptab_line-name = 'I_CHARG '.

ptab_line-kind = abap_func_exporting.

GET REFERENCE OF I_CHARG INTO ptab_line-value.

INSERT ptab_line INTO TABLE ptab

Here the issue is since the oil switch id off, data type OIB_DEF_INDEX_GM-CHARG, will not be there

Once this program is loaded it will not compile

I need to declare this data I_CHARG also dynamically. Thihs is due to the fact that program with data declaration is loaded first & any program logic ( if else ) is done afterwards.

Once the program is loaded, sicne the data element is not there, it will not comiple & give error

I hope I am clear with the question

Regards

Edited by: Harish Wadhwani on Oct 21, 2010 9:35 PM

Read only

Former Member
0 Likes
599

Few tips:

1. FM FUNCTION_EXISTS can be use to check availability of function module

2. dynamic type declaration can be done by using parenthesis '( <> )'

Thanks

Read only

0 Likes
599

Thanks,

Can you please elaborate.

My data declaration is

Data : I_CHARG type OIB_DEF_INDEX_GM-CHARG. " First export parameter

How can i declare this so that if even the data type OIB_DEF_INDEX_GM-CHARG is not existing, it should not give syntax error

Data : I_CHARG type (OIB_DEF_INDEX_GM-CHARG) .but this does not work.

Regards,

Harish