Application Development 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: 

Dynamic Function Module call with table parameter?

Former Member
0 Kudos

Hi All,

I'm trying to call FMs dynamically with PARAMETER-TABLE. These FMs are mainly about searching data from inputs and returning internal table as outputs. I managed to pass data into import parameters as query conditions, but still failed to set tables parameter. The code is like below, could you please help me check what's the problem? Thank you very much!!


data: lv_val type RS38L_TYP value 'ls_service_para-fmparam'.

data: lt_interface TYPE rsfbintfv,

           ls_import_para TYPE rsfbpara,

           ptab TYPE abap_func_parmbind_tab,

           ptab_line TYPE abap_func_parmbind,

           ref_wa type ref to data.

Field-symbols: <fs> type any,


CALL METHOD cl_fb_function_utility=>meth_get_interface

       EXPORTING

         im_name             = LV_FM          "FM name

       IMPORTING

         ex_interface        = lt_interface

       EXCEPTIONS

         error_occured       = 1

         object_not_existing = 2

         OTHERS              = 3.

***loop IMPORT parameters and fill in data from lt_params***

loop at  lt_interface-import into ls_import_para.

     read table lt_params into ls_param with key key = ls_import_para-parameter.  "check if exists query value

    if sy-subrc = 0 and ls_param-value is not initial.

          assign (lv_val) to <fs>.

           <fs> = ls_param-value.

          create data ref_wa type (ls_import_para-STRUCTURE).

          assign ref_wa->* to <fs2>.

           <fs2> = <fs>.  UNASSIGN: <fs>,<fs2>.

           ptab_line-name = ls_import_para-PARAMETER.

           ptab_line-value = ref_wa.

           ptab_line-kind = abap_func_exporting.

          insert ptab_line into table ptab.

     endif.

endloop.

***loop at TABLE parameters to retrieve data from FM***

loop at lt_interface-TABLES into ls_import_para.

     create data ref_wa type (ls_import_para-STRUCTURE).

      ptab_line-tables_wa = ref_wa.     "set data type

      ptab_line-name = ls_import_para-PARAMETER.

      ptab_line-kind = abap_func_tables.

     insert ptab_line into table ptab. "if commented, no exception occurs,but I cannot get any dataset.

endloop.

CALL FUNCTION LV_FM PARAMETER-TABLE ptab.

if I execute the code, when there has TABLES parameter defined in the FM, I get CX_SY_DYN_CALL_PARAM_MISSING exception with runtime error DATREF_NOT_ASSIGNED. But in debug mode, as shown in the screen shot attached, I did see the field TABLES_WA has correct type. So maybe I misunderstand the usage of PARAMETER-TABLE. Does anyone has experience on it?

Best Regards,

Jeff

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Jeff Liu,

CX_SY_DYN_CALL_PARAM_MISSING - This error mainly because Function module parameter not passed correctly,

Check whether all Parameters to the Functional module are passed...and check..

Regards,

Vijay SR

7 REPLIES 7

Former Member
0 Kudos

Hi Jeff Liu,

CX_SY_DYN_CALL_PARAM_MISSING - This error mainly because Function module parameter not passed correctly,

Check whether all Parameters to the Functional module are passed...and check..

Regards,

Vijay SR

0 Kudos

Hi Vijay,

I know there must be something wrong with my parameter and I also know where are they, it's just the TABLE parameter that causes the error, but I don't know what's the correct way of filling TABLE parameter. If you know that, could you please help me to check that? I've attached the screen shot with runtime values, do you think I assign the wrong value? if so, what's the correct value?

Thanks.

Jeff

nabheetscn
Active Contributor
0 Kudos

Hi Jeff

Which function module are you trying to call..? If its standard please provide the name. You have missed passing an obligatory parameter. Please do an F1 for parameter table. It has a very well documented example.

Nabheet

0 Kudos

Hi Nabheet,

I want to call function module dynamically, including both standard FM and customized ones, not specific FM. As I mentioned in my first post, the problem occurred for TABLE parameter, in my test case, the parameter is an optional parameter, so if I comment the statement "insert ptab_line into table ptab" of the TABLE parameter filling block, it works correctly and I can get into the FM I was debugging, but as I did not assign TABLE parameter into the PARAMETER-TABLE, I was not able to get expected data from the FM, so I've to find way of maintaining TABLE parameters. As to the IMPORT parameter, it's working correctly, that's why I'm concentrating on TABLE parameter only. Do you know how to set the structure of TABLE type? Could you please show me some piece of code if possible?

Thank you very much!

Jeff

ramakrishnappa
Active Contributor
0 Kudos

Hi Jeff,

I think you are not passing value to the required parameter.

Please use this statement at line 35,

      ptab_line-value = ?     "set the reference to the internal table data

Hope this helps you.

Regards,

Rama

0 Kudos

Hi Rama,

Yes, I'm not passing value to the table parameter, but that parameter is where I want to retrieve data from FM, not pass value to, so I don't assign any value to ptab_line-value for that parameter.

BTW, I just did some test to pass value to the parameter using the following code and still got CALL_FUNCTION_PARM_MISSING exception:

FM: ZLEAD_CONTACT

parameters:

IMPORT:  I_PARTNER TYPE BUT000-PARTNER mandatory

TABLES: OT_CONT LIKE ZLEAD_INFO_S optional (here ZLEAD_INFO_S is a flat structure)


ptab_line-name = ls_import_para-PARAMETER.

ptab_line-kind = abap_func_tables.


create data ref_type type table of (ls_import_para-STRUCTURE).

ptab_line-tables_wa = ref_wa.

ptab_line-value = ref_type.

The detail of ptab:

VALUETABLES_WAKINDNAME
->2000000025{A:initial}102000000025
->Standard Table[0x10(588)]->Structure: flat & not charlike30OT_CONT

And the same error if I set parameter using below code:


create data ref_wa type RS38L_TYP.

assign ref_wa->* to <fs>.

<fs> = ls_import_para-STRUCTURE.

ptab_line-tables_wa = ref_wa.

The detail of ptab:

VALUETABLES_WAKINDNAME
->2000000025{A:initial}102000000025
->Standard Table[0x10(588)]->ZLEAD_INFO_S30OT_CONT

Regards,

Jeff

0 Kudos

Hi All,

OK, I've to say sorry to all of you because I made a stupid mistake of assigning value of IMPORT parameter, I use the code assign (lv_val) to <fs>. instead of assign lv_val to <fs>. That makes the name of the IMPORT parameter wrongly replaced by the parameter's value. So you can see here in the detail of ptab, the name in the first row is 2000000025, that's the value I was querying for.

Also I want to mention here is for structure parameter, even it's for output only, field 'tables_wa' and 'value' should always be assigned.

Thanks you all for spending or wasting your time on it!

Regards,

Jeff