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 return error message

Former Member
0 Likes
1,213

Hi

I use BAPI_ASSET_ACQUISITION_POST and when I fill all need data with incorrect field ASSETTRTYP then I got error message on bottom bar

and my program is stop processing. Why this message isn't in return BAPI table but on screen?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
604

Hi Kosmo,

This is because the code inside the BAPI is not written the way it should have been. Instead of populating the return table it is raising the message with Message command.

If you want to trap it. use this

CALL FUNCTION 'BAPI_ASSET_ACQUISITION_POST'

EXPORTING

......

IMPORTING

TABLES

EXCEPTIONS

error_message = 99.

You have to add the code written in bold in addition to the BAPI call. It will trap the error and will not throw any error in the screen. In order to know the error you can use system variable like SY-MSGID, SY-MSGNO, SY-MSGTY and SY-MSGV1 to SY-MSGV4

So add the following code after the BAPI call

IF SY-SUBRC = 99.

****convert the message to message text using simple coding or FORMAT_MESSAGE/ MESSAGE_TEXT_BUILD FMs

endif.

Hope it helps.

Regards,

R

1 REPLY 1
Read only

Former Member
0 Likes
605

Hi Kosmo,

This is because the code inside the BAPI is not written the way it should have been. Instead of populating the return table it is raising the message with Message command.

If you want to trap it. use this

CALL FUNCTION 'BAPI_ASSET_ACQUISITION_POST'

EXPORTING

......

IMPORTING

TABLES

EXCEPTIONS

error_message = 99.

You have to add the code written in bold in addition to the BAPI call. It will trap the error and will not throw any error in the screen. In order to know the error you can use system variable like SY-MSGID, SY-MSGNO, SY-MSGTY and SY-MSGV1 to SY-MSGV4

So add the following code after the BAPI call

IF SY-SUBRC = 99.

****convert the message to message text using simple coding or FORMAT_MESSAGE/ MESSAGE_TEXT_BUILD FMs

endif.

Hope it helps.

Regards,

R