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.
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’
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
OTHERS = 0.
The above FM will trigger the call back which is responsible for Pricing.