‎2021 Feb 15 2:14 PM
Hi Folks,
Greetings,
I am facing the problem in calling dynamic function module or BAPI in s/4 hana system.
It is giving me an error saying that parameter missing.

Kindly help on this .
Please find my code snippet.
REPORT zdynamic.
TYPE-POOLS : abap.
DATA: lv_fname TYPE string,
lt_ptab TYPE abap_func_parmbind_tab,
ls_ptab TYPE abap_func_parmbind,
lt_etab TYPE abap_func_excpbind_tab,
ls_etab TYPE abap_func_excpbind,
str TYPE TABLE OF BAPIPARAM.
FIELD-SYMBOLS : <itab> TYPE ANY TABLE.
ASSIGN str TO <itab>.
DATA : lv_level TYPE string.
DATA : lv_type TYPE char10.
lv_level = 'xyz'.
*** Importing
ls_ptab-name = 'USERNAME'.
ls_ptab-kind = abap_func_importing.
GET REFERENCE OF lv_level INTO ls_ptab-value.
INSERT ls_ptab INTO TABLE lt_ptab.
** Table
ls_ptab-name = 'PARAMETER'.
ls_ptab-kind = abap_func_tables.
GET REFERENCE OF <itab> INTO ls_ptab-value.
INSERT ls_ptab INTO TABLE lt_ptab.
*** Exceptions
ls_etab-name = 'NOT_EXISTS'.
ls_etab-value = 1.
INSERT ls_etab INTO TABLE lt_etab.
ls_etab-name = 'OTHERS'.
ls_etab-value = 2.
INSERT ls_etab INTO TABLE lt_etab.
lv_fname = 'BAPI_USER_GET_DETAIL'." Function Name
CALL FUNCTION lv_fname
PARAMETER-TABLE
lt_ptab
EXCEPTION-TABLE
lt_etab.
IF sy-subrc NE 0.
*** Error Handling
ENDIF.
I referred the many posts the gui_download dynamic function call is working fine but i am not able to call the functions other than gui_download dynamically.
Regards,
Hiri
‎2021 Feb 15 2:26 PM
Hello Hiriyappa Myageri,
As Andrea said, it would be easier if you provided a code snipper of the call.
However, judging from the short dump description it seems you have not provided a value for a required parameter of the function you're trying to use. Please check that functions definition and provide values for all required parameters. Otherwise it will not work.
Edit: You can open the function module in SE37 transaction to check its parameters and their attributes.
Kind regards,
Mateusz
‎2021 Feb 15 2:20 PM
Please edit the question to add the relevant snippet of code.
‎2021 Feb 15 2:26 PM
Hello Hiriyappa Myageri,
As Andrea said, it would be easier if you provided a code snipper of the call.
However, judging from the short dump description it seems you have not provided a value for a required parameter of the function you're trying to use. Please check that functions definition and provide values for all required parameters. Otherwise it will not work.
Edit: You can open the function module in SE37 transaction to check its parameters and their attributes.
Kind regards,
Mateusz
‎2021 Feb 15 2:36 PM
Hi Mateusz,
I have added code snippet. Kindly find same in original post.
Regards,
Hiri
‎2021 Feb 15 2:44 PM
Thanks.
You're missing the RETURN tables parameter in your call. This parameter is obligatory.
‎2021 Feb 15 3:20 PM
Hi hirizm
RETURN is an obligatory parameter in BAPI_USER_GET_DETAIL function.
Please format your code with the "Code" button in the message editor's toolbar.
If function's parameter is marked as IMPORTING, you have to mark it as EXPORTING in your report. And vice versa. Like in normal ABAP function call.
Kind regards,
Mateusz
‎2021 Feb 15 5:39 PM
Hi Mateusz,
You are right . Parameter table is we need to pass the values as you mentioned .
Now it is working fine
Regards,
Hiri
‎2021 Feb 15 2:49 PM
By using the model option to add the function in some ABAP code it looks like your missing RETURN table parameter.
‎2021 Feb 15 3:07 PM
Hi Mateusz,
In the example I gave the return parameter is not a obligatory.
Please find another example where return parameter is not present still there is dump as missing parameter .
REPORT zdynamic.
TYPE-POOLS : abap.
DATA: func TYPE string,
lt_ptab TYPE abap_func_parmbind_tab,
ls_ptab TYPE abap_func_parmbind,
lt_etab TYPE abap_func_excpbind_tab,
ls_etab TYPE abap_func_excpbind,
str TYPE TRDIR.
FIELD-SYMBOLS : <itab> TYPE any.
ASSIGN str TO <itab>.
DATA : lv_level TYPE string.
DATA : lv_type TYPE char10.
lv_level = 'ZDYNAMIC'.
** Exporting ls_ptab-name = 'E_TRDIR'.
ls_ptab-kind = abap_func_exporting.
GET REFERENCE OF lv_type INTO ls_ptab-value.
INSERT ls_ptab INTO TABLE lt_ptab.
*** Importing ls_ptab-name = 'I_PROGNAME'.
ls_ptab-kind = abap_func_importing.
GET REFERENCE OF lv_level INTO ls_ptab-value.
INSERT ls_ptab INTO TABLE lt_ptab.
*** Exceptions ls_etab-name = 'NOT_EXISTS'.
ls_etab-value = 1.
INSERT ls_etab INTO TABLE lt_etab.
ls_etab-name = 'OTHERS'.
ls_etab-value = 2.
INSERT ls_etab INTO TABLE lt_etab.
func = 'READ_TRDIR'.
" Function Name
CALL FUNCTION func
PARAMETER-TABLE lt_ptab
EXCEPTION-TABLE lt_etab.
IF sy-subrc NE 0. *** Error Handling ENDIF.
is there any restrictions while calling the dynamic FM.

Regards,
Hiri