04-26-2006 7:29 AM
Friends,
I have a requiement to develope a report which displays the result of given BAPI. In which I used FUNCTION_GET function. In this function i am passing the BAPINAME so it will give me the Import,Export and Return Parameters of that BAPI. This will be stored in one ITAB.
Now if i want to set the Input Parameters of that particular BAPI and want to execute it and stores the result of it in another ITAB.
Can u tell me how to do that.
I have written following code..
REPORT ZGETBAPI_NAME line-size 132.
Parameters: bapiname like TFDIR-FUNCNAME default'BAPI_CREDITOR_GETDETAIL'.
Data: rtrbapi_itab like CATFU occurs 0 with header line.
Data: pName(30) Type C.
Data: Name(30) Type C.
CALL FUNCTION 'FUNCTION_GET'
EXPORTING
FUNCNAME = bapiname
TABLES
PRMTAB = rtrbapi_itab
EXCEPTIONS
FM_NOT_FOUND = 1
NAMETAB_FAULT = 2
REF_FIELD_MISSING = 3
REF_STRUCTURE_MISSING = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Loop At rtrbapi_itab.
Write: / rtrbapi_itab-PARAMTYPE,
07 rtrbapi_itab-NAME,
38 rtrbapi_itab-TABNAME,
68 rtrbapi_itab-FIELDNAME,
98 rtrbapi_itab-DATATYPE,
102 rtrbapi_itab-INTTYPE,
106 rtrbapi_itab-DDLEN,
110 rtrbapi_itab-INTLEN.
EndLoop.
Thanks,
Hitesh Shah
04-26-2006 7:35 AM
I am not sure what you are tyring to do by dynamcially executing different BADI's. You need to have the parameters of the BAPI, in your program, populate them and pass that to the BAPI.
You can call the function dynamically using CALL FUNCTION (funcname), but passing the parameters for a BAPI, which is decided only at runtime, you will not even have a pattern to do that.
Regards,
Ravi