on 10-13-2010 10:20 AM
I am calling the BAPI_PO_CHANGE to change the NO_MORE_GR indicator via an ABAP program. After calling the BAPI I would like to trap the error before calling the BAPI_TRANSACTION_COMMIT. Please see code snippet below. When testing the BAPI via the testing module (/nbapi) the return entries show errors but when calling via ABAP the SY-SUBRC always returns a 0. I would like to know if there are other ways of trapping such errors rather than depending on SY-SUBRC.
FORM updatepoitem.
DATA: test TYPE bapiflag-bapiflag,
po_item TYPE TABLE OF bapimepoitem WITH HEADER LINE,
po_itemx TYPE TABLE OF bapimepoitemx WITH HEADER LINE.
DATA:i_msg LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
LOOP AT itab_sel INTO wa_itab .
*Clear the tables.
CLEAR: po_item, po_itemx, t_bapireturn.
REFRESH: po_item, po_itemx, t_bapireturn.
MOVE wa_itab-ebelp TO po_item-po_item.
MOVE wa_itab-ebelp TO po_itemx-po_item.
MOVE 'X' TO po_itemx-no_more_gr.
MOVE 'X' TO po_item-no_more_gr.
APPEND po_item.
APPEND po_itemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = wa_itab-ebeln
TABLES
poitem = po_item
poitemx = po_itemx.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDLOOP.
ENDFORM.
Many Thanks
Problem resolved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The BAPI BAPI_PO_CHANGE has a return table which will return the errors . So before calling the commit bapi , move the retun table into another internal table .
On this internal table write a condition , that if there are not Errors i.e there is no message type E , then call the commit BAPI.
-Hari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.