We can help. Together we learn....


BAPI_PO_CHANGE is used for re-pricing the Purchase Order. The calculation type CALCTYPE should be set to ‘B’ (meaning ‘Carry out new pricing’) and PRICEDATE should be set to ‘3’ (meaning ‘Current Date’).

Code snippet
Data:
        li_bapiitem         TYPE STANDARD TABLE OF bapimepoitem,
        li_bapiitemx       TYPE STANDARD TABLE OF bapimepoitemx.

FIELD-SYMBOLS :
               TYPE EKPO.

      lk_bapiitem-po_item     = -ebelp.
      lk_bapiitem-calctype     = 'B'.                       " Reprice it
      lk_bapiitem-pricedate   =  '3'.           " Reprice it based on current date
      APPEND lk_bapiitem TO li_bapiitem.


      lk_bapiitemx-po_item    = -ebelp.
      lk_bapiitemx-calctype    = ‘X’.
      lk_bapiitemx-pricedate  =  ‘X’.
      lk_bapiitemx-po_itemx  =  ‘X’.   
      APPEND lk_bapiitemx TO li_bapiitemx.


*     Change condition price using BAPI_PO_CHANGE
      CALL FUNCTION 'BAPI_PO_CHANGE'
        EXPORTING
          purchaseorder = -ebeln         " PO number
        TABLES
          return           = li_return                " For return messages
          poitem         = li_bapiitem                        " PO Line item
          poitemx       = li_bapiitemx.         " PO Item data change parameter

Issue with re-pricing

The above code should work fine. But, if the re-pricing does not happen with the current date info, instead the re-pricing is being done based on PO creation date, then you need to check the configuration (shown below).

Root Cause

There is a configuration setting which should be changed.

SPRO -- Material Management -- Purchasing -- Purchase Order -- Define Screen Layout at Document Level -- ME21N -- Quantity and Price -- Field (Pricing date control)

Here we can set, whether the Pricing data control fields can be entered and changed by user or not. The Opt. entry check box should be checked in order for the BAPI to work. Even for manual re-pricing this Opt. entry check box should be checked.

Correct configuration setting


With the above setting, the PO t-code looks like below. Check the Pr.Date Cat and Price Date is available in Condition Control Tab. This is the correct configuration for BAPI to work. Even for manual re-pricing to take place for current date, these two fields should be visible.


Point to Remember

Next time, the Bapi 'BAPI_PO_CHANGE', is not re-pricing the PO correctly, in stead of wasting time in debugging, look for the above said configuration and explain the root cause.

0 comments:

Categories