‎2006 Jul 15 9:49 AM
Hi
how to handles the errors in bapi function modules asa compared to normal function modules
thanks,
kiran.M
‎2006 Jul 15 9:52 AM
Normally BAPI's will retun you an internal table with RETURN table, which will have the list of message it encountered while processing the BAPI.
Then you need to loop at that internal table to build the messages, you can use messagetextbuild FM to build the messages.
Regds
Manohar
‎2006 Jul 15 9:52 AM
Hi,
Normally u avoid exceptions in BAPI.
Use internal table ; Populate the error if any and return the internal table.
<b>BAPI-step by step</b>
‎2006 Jul 15 9:56 AM
EXample for error handling in bapi.
Bapi :- BAPI_0035_CHANGE
Tables :- RETURN
Return is a internal table which returns error .
Structure of return table ( BAPIRET2 ).
TYPE
ID
NUMBER
MESSAGE
LOG_NO
LOG_MSG_NO
MESSAGE_V1
MESSAGE_V2
MESSAGE_V3
MESSAGE_V4
PARAMETER
ROW
FIELD
SYSTEM
u append the error in this table.
look at the structure ( BAPIRET2 ) for detail.
‎2006 Jul 15 4:27 PM
Hi Kiran,
There is no explicit condition or any BAPI or FM to handle the errors. It has to be done manually, the same procedure we use in BDC programs after CALL TRNSACTION and getting the messages into the Internal Table.
Assume I am using <b>BAPI_QUOTATION_CREATEFROMDATA2</b> for creating quotations(Transaction VA21).
I called the BAPI and got the following error messges in my <b>RETURN</b> table.
<b>TYPE |ID | NUMBER| MESSAGE</b>
E |VP |112 |Please enter sold-to party or ship-to party
E |V4 |219 |Sales document was not changed
So based on this you have to determine your error handling.
Something like this after calling the BAPI.
READ TABLE return WITH KEY id = 'VP'
number = '112'.
IF sy-subrc = 0.
* Your error handling
ENDIF.
You can use the BAPI_MESSAGE_GETDETAIL to get the detailed error messages. Refer to the table T100 for exporting parameters.
Regards,
Arun Sambargi.
‎2006 Jul 16 12:02 PM
Hi,
All BAPIs contains Return table as table parameter. This table is populated with error messages/Sucessful messages after BAPI was executed.
Please check this table for any error messages.
Regards,
Ganesh