User Events – My recent favorite topic in HCM Processes and Forms. I got a very good idea about the “User Events” from Christopher Solomon’s blog – http://scn.sap.com/community/erp/hcm/blog/2008/06/30/hcm-processes-forms-gotchas-bugs-and-other-curiosities
After understanding the way “User Events” work, I slowly understood it’s restriction too 🙂
My wish about User Events
The way I expected the User Events to work is when the user event is triggered, the appropriate event can be gracefully handled in the INITIALIZE and DO_OPERATIONS methods of the Generic Service class. Like instead of executing the entire source code in these methods for every User event and Standard events(CHECK and SUBMIT) triggered, I should have an option of executing part of the source code conditionally based on the triggered User event.
The User Events doesn’t really work as I wish ! Both these generic service’s methods(IF_HRASR00GEN_SERVICE~INITIALIZE and IF_HRASR00GEN_SERVICE~DO_OPERATIONS) doesn’t really get the User Event that triggered the event 🙁
The only way I could realize my above “wish” is with this workaround solution 🙂 ! The solution is passing the “User Event” to these Generic Service methods magically from the HRASR framework. The BADI Implementation for the Generic Service is called in the method IF_HRASR00_MAPPER~DO_OPERATIONS in the class CL_HRASR00_GENSERV_MAPPER –
Create a pre-exit to this method to pass the parameter “EVENT” to Generic Service class(You can use multiple ways to pass this event i.e. enhancing the Interface IF_HRASR00GEN_SERVICE or using IMPORT/EXPORT PARAMETER or using static class method) –
In the Generic Service Class method you can now handle the events gracefully –
* Extract the event
IF GV_EVENT = ‘EVENT1’.
* Handle Event1 gracefully
ELSEIF GV_EVENT = ‘CHECK’.
* Handle all custom validations using generic service
Instead of this work around solution, Ideally I would expect SAP to add in one single line of code(along with enhancing the parameter interface for Generic service methods – INITIALIZE and DO_OPERATIONS to accept EVENT) in the method IF_HRASR00_MAPPER~DO_OPERATIONS in the class CL_HRASR00_GENSERV_MAPPER –
CALL BADI a_gs_badi_basic->do_operations
special_fields = special_fields
service_operations = service_operations
no_auth_check = no_auth_check
message_handler = gs_message_handler
event = event
help_datasets = help_datasets
service_datasets = service_datasets_do_operations
ui_attributes = loc_ui_attributes.
cx_badi “No BADI implementation exist
cx_sy_dyn_call_error. “Catch dynamic call errors