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

how to do errorhandling in bapi

Former Member
0 Likes
458

errorhandling in bapi

3 REPLIES 3
Read only

alex_m
Active Contributor
0 Likes
397

After excuting BAPI, see the RETURN table, this will have all the successful and failiure details.

Read only

Former Member
0 Likes
397

Hi,

Check the code below:

*Call the BAPI to Create the Return Order

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'

EXPORTING

return_header_in = gs_return_header_in

return_header_inx = gs_return_header_inx

IMPORTING

salesdocument = gv_salesdocument

TABLES

return = gt_return

return_items_in = gt_return_items_in

  • Commit Work

PERFORM error.

FORM error .

CONSTANTS: lc_e TYPE c VALUE 'E'.

LEAVE TO LIST-PROCESSING.

CLEAR: gv_errflag, gs_error1.

  • To display BAPI return messages

LOOP AT gt_return INTO gs_return.

gs_error1-type = gs_return-type.

gs_error1-message = gs_return-message.

APPEND gs_error1 TO gt_error1.

IF gs_error1-type = lc_e.

gv_errflag = gc_x.

ENDIF.

CLEAR gs_error1.

ENDLOOP.

  • Commit Work

PERFORM commit.

ENDFORM. " error

FORM commit .

  • If no errors Commit work else Roll Back

IF gv_errflag IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

ROLLBACK WORK.

ENDIF.

ENDFORM. " commit

Regards

Kannaiah

Read only

Former Member
0 Likes
397

use bapiret2 structure