‎2008 Apr 12 10:54 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 Apr 12 11:48 AM
every bapi has a return structure with name bapiret2 or bapireturn
make an internal table with that structure.
every bapi has an importing parameter return
pass the internal table to it
we will get messages in the internal table
read the table with message type s
then perform commit.
if it is helpful please reward points.
Edited by: moazam hai on Apr 12, 2008 12:48 PM
‎2008 Apr 12 1:56 PM
Hi Subramanian,
Every BAPI fm has one parameter under tables called RETURN. When u execute the BAPI what ever messages u get irrespective of message type all will be returned in this table. After calling the BAPI u have to read this table with TYPE = 'E' for errors. If no errors the again read with TYPE = 'A' Abort messages. If again fails then ur BAPI has successfuuly worked.
There is one more message which indicates Failure i.e TYPE = 'X'. But generally we will never encounter this message.
So u can read the return table with TYPE = E and A. If Both fails then ur BAPI is success.
In most of the BAPIs there will be one importing parameter which will return Document number generated etc. It depends on the application of the BAPI. Suppose if u are posting some thing then a document will be generated and will be returned in this parameter.
Thanks,
Vinod.