Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

bapi error

Former Member
0 Likes
1,387

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.

3 REPLIES 3
Read only

Former Member
0 Likes
797

Hi ,

You can handle the errors in Bapi using the the return structure not exception .

Thanks

rahul

Read only

Former Member
0 Likes
797

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.

Read only

Former Member
0 Likes
797

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