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’).
li_bapiitem TYPE STANDARD TABLE OF bapimepoitem,
li_bapiitemx TYPE STANDARD TABLE OF bapimepoitemx.
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'
purchaseorder = -ebeln " PO number
return = li_return " For return messages
poitem = li_bapiitem " PO Line item
poitemx = li_bapiitemx. " PO Item data change parameter.
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).
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.
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.
If you want to get such practical issues and resolutions straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.
If you liked this post, please hit the share button at the left side of your screen.
Image source : www.hawkeyerecruitment.com