Skip to Content
author's profile photo Former Member
Former Member

BAPI_PO_CHANGE trapping erros

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2010 at 12:03 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2010 at 12:27 PM

    Problem resolved.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.