‎2005 Oct 10 7:45 PM
Hi,
I am writing a custom BAPI in which i am calling XD01 transaction. I want to trap the error message into the BAPI return. How do I do this ?
Thanks in advance.
‎2005 Oct 10 7:55 PM
It is your custom BAPI, so this should not be a problem at all. I hope you are doing the call transaction with the option 'messages into <bdc_mesages_itab>'. Once you add this option, your bdc_messages_itab will contain the error messages from the call transaction. Then all you have to do is to loop at this and fill your BAPI_RETURN structure.
data: begin of i_bdcmsgcoll occurs 0.
include structure bdcmsgcoll.
data: end of i_bdcmsgcoll.
CALL TRANSACTION 'XD01'
USING BDCDATA
MESSAGES INTO I_BDCMSGCOLL.
LOOP AT I_BDCMSGCOLL.
MOVE: I_BDCMSGCOLL-MSGTYP TO RETURN-TYPE
I_BDCMSGCOLL-MSGID TO RETURN-ID
I_BDCMSGCOLL-MSGNR TO RETURN-NUMBER
I_BDCMSGCOLL-MSGV1 TO RETURN-MESSAGE_V1
I_BDCMSGCOLL-MSGV2 TO RETURN-MESSAGE_V2
I_BDCMSGCOLL-MSGV3 TO RETURN-MESSAGE_V3
I_BDCMSGCOLL-MSGV4 TO RETURN-MESSAGE_V4.
APPEND RETURN.
CLEAR RETURN.
ENDLOOP.
Srinivas
Message was edited by: Srinivas Adavi
‎2005 Oct 10 8:01 PM
‎2005 Oct 10 8:05 PM