Application Development and Automation 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: 
Read only

BAPI return messages

Former Member
0 Likes
660

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.

3 REPLIES 3
Read only

Former Member
0 Likes
559

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

Read only

0 Likes
559

BALW_BAPIRETURN_GET1 will do that. Thanks for your reply.

Read only

0 Likes
559

Please close the post in that case.

Regards,

Srinivas