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

Error message handling in BAPI...

Former Member
0 Likes
2,735

Hi Guys,

I am working on documentation of a BAPI used SAP insurance module. Now I want to see all the error messages associated/ handled in that BAPI. How can I do that ? Is there a table in data dictionary where I can see error messages handled by a given Function module/ BAPI?

Any inputs will be highly appreciated.

Thanks.

Regards,

Tushar.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,169

No, there is nothing like that, the only way is to view the source, any messages will be written to the BAPIRET2 structure. Yes, this will be a little cumbersome.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,169

Hi,

If a BAPI Module has a Return Structure or Return Table, the connector checks for the message types A (abort) and E (error) to determine if the service call request processed successfully. A message type A or E indicates that the service call request failed to process. If a BAPI does not have a Return Structure or Return Table, you must implement your own error handling

Your bapi will return the error messages if you have a structure and capture the messages in a table. The message table should have the structure BAPIRET2.

Eg:

data: gi_return TYPE STANDARD TABLE OF bapiret2.

  • Call the BAPI function

CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

EXPORTING

documentheader = g_docheader

  • IMPORTING

  • OBJ_TYPE =

  • OBJ_KEY =

  • OBJ_SYS =

TABLES

accountgl = gi_accountgl

currencyamount = gi_amount

return = gi_return

  • EXTENSION1 =

Regards,

Sookshma

Read only

Former Member
0 Likes
1,169

You can narrow it down a bit. Go to SE37 and enter the name of your BAPI. Then:

GOto -> Main program.

Double click on the top include. That will take you to the ABAP editor. Double click on the message-id used by the program. This will take you to the messages for the function group.

The BAPI can use messages from other message classes and not all messages in this class may be used by your BAPI, but it should be a start.

Rob

Read only

former_member182371
Active Contributor
0 Likes
1,169

Hi,

here´s one possible solution:

CALL FUNCTION 'MESSAGES_INITIALIZE'.

LOOP AT it_return_bapi.

CALL FUNCTION 'MESSAGE_STORE'

EXPORTING

arbgb = it_return_bapi-id

exception_if_not_active = ' '

msgty = it_return_bapi-type

msgv1 = it_return_bapi-message_v1

msgv2 = it_return_bapi-message_v2

msgv3 = it_return_bapi-message_v3

msgv4 = it_return_bapi-message_v4

txtnr = it_return_bapi-number

zeile = ' '

EXCEPTIONS

message_type_not_valid = 1

not_active = 2

OTHERS = 3.

ENDLOOP.

CALL FUNCTION 'MESSAGES_STOP'

EXCEPTIONS

a_message = 04

e_message = 03

i_message = 02

w_message = 01.

IF NOT sy-subrc IS INITIAL.

CALL FUNCTION 'MESSAGES_SHOW'

EXPORTING

i_use_grid = 'X'

i_amodal_window = i_amodal_window

EXCEPTIONS

inconsistent_range = 1

no_messages = 2

OTHERS = 3.

ENDIF.

ENDFUNCTION.

Best regards