How to create Call Back/ Event Handler Function Modules
This blog is about how to create and register the Event handler Function modules for our own requirements.
How it is used?
This Event Handler FM’s are useful in many scenarios like
1. When we want to update some field values on save of the Transactions ( Here FM will be called after ORDER_SAVE BADI check is successful so you can confirm that transaction will be saved)
2. When partner value is changing on after change you wnat to perform any update in Transaction
3.You can register this FM for any objects ( ORDERADM_H, ORDERADM_I, CUSTOMER_H, CUSTOMER_I, … etc)
How to create the FM
Fm should created with name endes with _EC for ex ZTEST_EVENT_SAVE_EC
Created FM must registered for Specific Objects ( CRM_ORDERADM_H, CRM_ORDERADM_I, ..etc)
Under this register your custom FM for your specific object
After registeration Maintain Event handler for which transaction, object and event in SPRO under CRM->Transaction->Basic Settings->Edit Event Handler Table
After this You can all the registered FM for events
Click on new entries and maintain the event for your custom FM
In the above screenshot FM is registered for Object PARTNER , for Event After Change and execution time is Immediately
This FM will be called immediately after Partner changed for Service Request Transactions
This FM will be called for Header/Item partner changes with importing fields passed are object name, event attributes with old and new values
In the above screenshot FM is registered for Service Request Transaction types, for object ORDERADM_H and for event SAVE and execution time before saving
This FM will be called when Service Request Transaction are saved and before saving the document you want to do any update according to user inputs you can do the code in this custom FM.
This FM will be called only once
Possib;e call Callback are
After these steps are done FM will be called on registered Events.