Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Bapi Return Parameter

0 Kudos


I know that exceptions are handled in BAPI using Return parameter but i want to know how to handle this,i.e if i am calling a bapi function module and suppose it throws some errors and this will be available in Return parameter ,what is the next step , can anyone give a sample code explaining this.

Thanks & Regards,

Rajanidhi Rajasekeran


Former Member
0 Kudos

Hi Rajanidhi,

what is to be done with the entries of the return table is something that is usually dependent on the application. some applications ahve a central log maintained and some other just choose to issue the messages.

So it largely depends on the requirement what has to be done.

Refer also to this link in the documentation -


Anand Mandalika.

Former Member
0 Kudos


Handling of BAPI return parameters depends on the BAPI in question.

In general, a message of type "E" means there has been a serious problem and the BAPI must be rolled back.

Determining if the call was successful is another matter. Some BAPIs return a success message (type "S"), others simply return nothing (i. e. an empty table). Sometimes there will be warnings and/or information messages. In my experience, you have to use trial and error.

Regards, Joerg

Former Member
0 Kudos

Hi Rajanidhi,

In general you can simply scan the return table. See following sample code:

* Sample program template 019
DATA: it_salesorder  TYPE BAPIACSO00 OCCURS 0,
      it_salesamount TYPE BAPIACCRSO OCCURS 0,
      it_return      TYPE BAPIRET2   OCCURS 0,
      wa_return      TYPE bapiret2.

* Do your thing to fill it_salesorder and it_salesamount

* Call to BAPI
    salesorder  = it_salesorder
    salesamount = it_salesamount
    return      = it_return.

* Error check
LOOP AT it_return INTO wa_return
                 WHERE type EQ 'E'
                    OR type EQ 'A'.
*   Give message
    MESSAGE ID wa_return-id
          TYPE wa_return-type
        NUMBER wa_return-number
          WITH wa_return-message_v1

Hope this helps you,



Former Member
0 Kudos


What you are asking is a basic question about how to handle errors. This is always unique to the implementation. There are standards everywhere as to how one wants to handle errors. Error handling consists of a couple of things:

Who should be notified?(Users, functional, technical support etc)

When should they be notified?(batch, immediately)

How they should be notified?(Job Spool, email, paging etc)

What is the mechanism for reprocessing? Do we store the error record(s) in a file or a table or just throw it away? Do we keep them in an IDOC format or a batch input session, if those options are available for the transaction you are using?

Apart from these aspects, most BAPIs require an explicit commit after the BAPI call. So depending on the success or failure of the BAPI call you either call BAPI_COMMIT_TRANSACTION or BAPI_ROLLBACK_TRANSACTION.

Hope this helps,