Trigger re-pricing WebUI
Objective: Trigger re-pricing of product in WebUI ON ACTION
Requirement: In most of the cases we usually have been asked to re calculate the pricing of an Item in Sales Order (Orders) based on the possible user actions in WebUI
1. On change of dates
2. On change of status
3. On change of Price group
4. On change of any field at Item or Header level.
Case: I have an requirement whenever Price group of an item is changed or the reason for return order changed to a specific reason then calculate the pricing again.
In oil and Gas industry, Customer may return the cylinder for 2 reasons.
1. Gas cylinder has been used completely and returned empty – Return order created with zero price
2. Gas cylinder is returned with partially used and due to valve problems – Company may charge customer for cleaning charges – When this reason is selected in drop down at Item level then re- pricing needs to be triggered.
Solution:
In my case, my field is dropdown field where user can select the reason(Price group 5) for return order / Item. Whenever the value is changed to certain value, in Setter method of that particular Attribute write below code to trigger the re-pricing.
1. Trigger a roundtrip event when the user changes the dropdown value
in GET_P method of that particular attribute, register an event “PRICE_GROUP_IS_CHANGED” under server event.
2. Call the above event:
in SET method of the particular attribute,check the attribute value which matches to relevant for re pricing, if yes call the event above.
3. EH_ON<EVENT> – Use FM CRM_PUBLISH EVENT OW and pass the item GUIDE and object type as below to trigger the pricing procedure again.
* Publish event, to perform Re pricing
CALL FUNCTION ‘CRM_EVENT_PUBLISH_OW’
EXPORTING
iv_obj_name = gc_object_name–pridoc_com ” PRIDOC_COM
iv_guid_hi = lv_item_guid
iv_kind_hi = gc_object_kind–orderadm_i
iv_event = gc_event–after_change
EXCEPTIONS
OTHERS = 0.
The above FM will trigger the call back which is responsible for Pricing.
Thanks for your contribution, but if you want to recalculate pricing on WebUI level I would go for this solution instead:
Redetermine conditions in sales orders massively using BOL
If I was developing a Model BADI or Action, I would probably go for your path, I believe software layers should be respected, and you are calling an API event on the Presentation layer which can cause weird behaviour. This is just my opinion, did you check if the SAP standard is doing a similar step on the WebUI?
Cheers!
Luis
Hi Luis, thanks for the feedback and the blog. I do agree that we need to respect the layers and adhere to the guidelines. There are instances in standard SAP where it is triggering Pricing determination event which eventually taking care of everything.. I will confirm this once with example scenario.
That will be cool, I'm also investigating a scenario where you can recalculate the condition on a PPF Action, I tried CRM_EVENT_PUBLISH_OW and it didn't worked for me, maybe this approach is too specific 😕