Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

BAPI_PO_CHANGE change price of service

$
0
0

Hi,

 

I am trying to update the price of a service irem using BAPI_PO_CHANGE and BAPI_PO_GETDETAIL1. The issue im having is for multiple PO's for the first PO the price updates as expected but on the next loop pass for the second PO the BAPI_PO_CHANGE is returning error message ''Instance 4330000362 of object type purchase order could not be changed" and "Please specify a valid account assignment". If I run the program with this same PO ONLY, the same one that is failing on the second loop pass it updates the price as expected.

 

I compared the contents of the internal tables poitem, poitemx and i_services just before te call of bapi_po_change when I run the program with 1 PO (Result as expected) and when I run the program with 2 PO's. The contents of the internal tables for the same PO is the same its just returning errors on the second loop pass.

 

In other words. The input for the bapi is the same but the bapi returns errors when I run the program with more than one PO.

 

All the internal tables get cleared after the first loop pass so I dont think is a clear refresh issue. Below is my code, te issue is happening in the call of bapi below comment "* Call bapi to change the gross price." Please advice me on this.

 

     

FIELD-SYMBOLS: <fs_po>   LIKE LINE OF i_poitem,                   <fs_k_serv> LIKE LINE OF i_services.     

*   Get PO details    CALL FUNCTION 'BAPI_PO_GETDETAIL1'      EXPORTING        purchaseorder = pk_po-ebeln        services      = c_x      TABLES        return        = i_return        poitem        = i_poitem        poservices    = i_services.    SORT i_return BY type.    READ TABLE i_return INTO k_return WITH KEY type = c_e BINARY SEARCH.    IF sy-subrc <> 0.      LOOP AT i_poitem ASSIGNING <fs_po>.
*       If PO is locked clear deletion indicator to unlock it.        IF <fs_po>-delete_ind = c_l.          CLEAR  <fs_po>-delete_ind.        ENDIF.        k_poitemx-po_item = <fs_po>-po_item.        k_poitemx-delete_ind = c_x.        APPEND k_poitemx TO i_poitemx.        CLEAR  k_poitemx.      ENDLOOP.      UNASSIGN <fs_po>.      CLEAR i_return.
*     Unlock PO      CALL FUNCTION 'BAPI_PO_CHANGE'        EXPORTING          purchaseorder = pk_po-ebeln        TABLES          return        = i_return          poitem        = i_poitem          poitemx       = i_poitemx.      SORT i_return BY type.      READ TABLE i_return INTO k_return WITH KEY type = c_e BINARY SEARCH.      IF sy-subrc <> 0.
*       Commit changes to DB.        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'          EXPORTING            wait = c_x.
*           No sy-subrc check required.
*       Modify the gross price of the services        LOOP AT i_services ASSIGNING <fs_k_serv>.                     <fs_k_serv>-gr_price = pk_po-ucost.               
*          In order to set the price the deletion indicator must be cleared.          CLEAR <fs_k_serv>-delete_ind.                             ENDLOOP.        UNASSIGN <fs_k_serv>.                                       CLEAR i_return.
*       Call bapi to change the gross price.        CALL FUNCTION 'BAPI_PO_CHANGE'          EXPORTING            purchaseorder = pk_po-ebeln          TABLES            return        = i_return1                           "<----------- Error            poitem        = i_poitem            poitemx       = i_poitemx            poservices    = i_services.        SORT i_return1 BY type.        READ TABLE i_return1 INTO k_return1 WITH KEY type = c_s         BINARY SEARCH TRANSPORTING type message.                    IF sy-subrc = 0.
*         Commit changes to the DB.          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'            EXPORTING              wait = c_x.
*         No sy-subrc check required

.

 

Edited by: bodyboarder1 on Apr 15, 2011 9:48 PM


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>