‎2008 Apr 12 10:55 AM
Hi all,
In a interview i was asked a question, how to handle errors in BAPI. Even though i have worked in BAPI, i don't know how to handle errors in BAPI. Please help me if anyone knows the answer....
Thanks and Regards,
subbu.
‎2008 May 19 11:25 AM
Hi ,
You can handle the errors in Bapi using the the return structure not exception .
Thanks
rahul
‎2008 May 19 12:01 PM
Hi subramanian karthi ,
Refer to the following link for handling errors in bapis.
[http://help.sap.com/saphelp_46c/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/frameset.htm]
Reward points if useful.
Thanks ,
Surya Pydikondala.
‎2008 May 19 1:06 PM
Hi,
BAPIs have standardized error handling. They neve throw or raise any exception but return the corresponding messages.
If you simply want to check for success or failure you could use the following coding:
" BAPI returns single message
IF ( return-type CA 'AEX' ).
"... failure -> rollback and exit
ELSE.
"... success -> commit work
ENDIF.
"BAPI returns itab with messages
LOOP AT return TRANSPORTING NO FIELDS
WHERE ( type CA 'AEX' ).
EXIT.
ENDLOOP.
IF ( syst-subrc = '0' ).
"... failure -> rollback and exit
ELSE.
"... success -> commit work
ENDIF.
Please note that the names of the return parameters may vary between BAPIs.
check the theard for more info.
https://forums.sdn.sap.com/click.jspa?searchID=11927970&messageID=2743114
Regards
Kiran Sure