‎2006 Nov 13 5:09 AM
Hi Experts,
Could you give me stuff regarding
1) how to handle errors in BAPI
2) In BAPI How should Return custom fields in BAPIRET2
Thanks,
Asha
‎2006 Nov 13 5:12 AM
‎2006 Nov 13 5:17 AM
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.
http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/content.htm
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
‎2006 Nov 13 5:28 AM
Hi Asha,
In BAPI'S u can handle the errors with the help of BAPI RETURN parameter.
U have to declare an internal table like BAPIRET2. u need to pass this internal table to the RETURN structure .Now this internal table will capture the error messages once u run the BAPI.
Regards,
Nagaraj
‎2006 Nov 13 11:31 AM
Hi
U have two structures 'BAPIRETURN' and BAPIRET2 which u have to use in ur BAPI FM as export parameter or tables parameter which will hold the errors.
For passing the errors to these structures u have to call FM
BALW_BAPI_RETURN_GET'.See the FM documentation in SE37.
And see the structure parameters in SE11 for better understanding.
Mark points if helpful.
Regs
Manas Ranjan Panda