04-23-2008 11:56 AM
hi all,
how to handle errors in bapis,and also can anyone send faqs on bapis.
04-23-2008 11:59 AM
Hi
A BAPI should be able to record and classify all possible errors that may occur a function Module BAPI_MESSAGE_GETDETAIL is used to Handle the Error Messages..
You have to create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.
BAPIs themselves must not trigger any messages (such as MESSAGE xnnn) in the coding. In particular they must not generate terminations or display dialog boxes. Instead, all messages must be intercepted internally and reported back to the calling program in the Return parameter. Otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.
All error messages or indeed any message that may be returned by the BAPI, must be defined in message table (Tools ® ABAP Workbench ® Development ® Programming environment ® Messages) and described in the documentation for the return parameter. This also applies to the most important or most likely error messages generated by other programs that can be indirectly passed via the BAPI to the application program.
You must not use exceptions in BAPI interfaces.
When a termination message (message type A) is triggered, a database rollback is executed in the standard programming model, that is, all tasks performed since the last COMMIT WORK are canceled. When you program BAPIs, we recommend that you also execute a database rollback in the return parameter for termination messages. You must describe this process in the documentation for the Return parameter. For messages of type E (error), the calling program performs the error handling.
Application developers are provided with two service BAPIs to diagnose and process error messages from BAPI calls:
BapiService.MessageGetDetail() displays the short and long texts of BAPI error messages.
BapiService.ApplicationLogGetDetail(), with which information in application logs can be displayed.
Features
The export parameter Return can be implemented as follows:
As a structure, whereby it must be defined in the function module as an export parameter, as well as in the method in the BOR.
As a table, whereby it must be defined in the function module as a table parameter, as well as in the method in the BOR as an export parameter.
Before filling the Return parameter you should either initialize the structure with CLEAR or the table with REFRESH and CLEAR.
If the return parameter is not set or is set to an initial value this means that no error has occurred.
The Return parameter may be based on the following reference structures:
BAPIRET2
You must use this reference structure when developing new BAPIS.
BAPIRET1, BAPIRETURN
These reference structures are still partly used in old BAPIs.
Both structures must be filled in the logon language.
Reward if Helpfull,
Naresh.
04-23-2008 11:59 AM
Hi siva,
use FM
BAPI_MESSAGE_GETDETAIL
Error - Handling in BAPI
http://help.sap.com/saphelp_46c/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/content.htm
Refer below link for additional Info about BAPI ;
http://help.sap.com/saphelp_46c/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm
http://www.sap-img.com/bapi.htm
Regards,
Sunil
04-23-2008 12:01 PM
A BAPI should be able to record and classify all possible errors that may occur.
You have to create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.
BAPIs themselves must not trigger any messages (such as MESSAGE xnnn) in the coding. In particular they must not generate terminations or display dialog boxes. Instead, all messages must be intercepted internally and reported back to the calling program in the Return parameter. Otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.
All error messages or indeed any message that may be returned by the BAPI, must be defined in message table (Tools > ABAP Workbench > Development > Programming environment > Messages) and described in the documentation for the return parameter. This also applies to the most important or most likely error messages generated by other programs that can be indirectly passed via the BAPI to the application program.
Have a look at below link:
[BAPI Error Handling|http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/frameset.htm]
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers