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?