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

Not able to update a contract using BAPI

Former Member
0 Likes
503

Hi All,

I am tryin to use a BAPI to update the contract and for this I have coded the following:

v_ponumber = 'abc-123' .
   MOVE v_ponumber  TO poheader2-number.
    MOVE 'X'  TO poheaderx-number.

    MOVE '00001' TO po_item2-ITEM_NO.
    MOVE 'test text' TO po_item2-SHORT_TEXT.
    APPEND po_item2.
    MOVE '00001' TO po_item2_x-ITEM_NO.
    MOVE 'X' TO po_item2_x-ITEM_NOX.
    MOVE 'X' TO po_item2_x-SHORT_TEXT.
    APPEND po_item2_x.

CALL FUNCTION 'BAPI_CONTRACT_CHANGE'
  EXPORTING
    PURCHASINGDOCUMENT          = v_ponumber
   HEADER                      = poheader2
   HEADERX                     = poheaderx

 TABLES
   ITEM                        = po_item2
   ITEMX                       = po_item2_x


   RETURN                      = return2
          .
if sy-subrc = 0.
commit work.
endif.

in the return table I am getting the message which says that the contract has been updated but I went to see the contract was actually not updated.... any advise where I am missing?

Thanks,

Rajat

3 REPLIES 3
Read only

Former Member
0 Likes
466

I am not sure why it is not working?? Try for any other alternate function modules.

But i see one issue with your coding, always check the return table message type and use commit work, instead of sy-subrc check. This fails for BAPI's

Read only

0 Likes
466

Thanks for the reply Vijay, I was using that commit work just for the testing purposes, I will use BAPI_TRANSACTION_COMMIT to do the actual commit.

Thnaks,

Rajat

Read only

Former Member
0 Likes
466

somehow it's working now.