Skip to Content

HCM Processes and Forms : My Journey around “User Events”

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.

/wp-content/uploads/2013/03/p1_198098.jpg

Reality

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 🙁

/wp-content/uploads/2013/03/p2_198099.jpg

Workaround solution


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 –

/wp-content/uploads/2013/03/p3_198100.jpg

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) –

/wp-content/uploads/2013/03/p4_198101.jpg

In the Generic Service Class method you can now handle the events gracefully –

method IF_HRASR00GEN_SERVICE~DO_OPERATIONS.

* Extract the event

  IF GV_EVENT = ‘EVENT1’.

      * Handle Event1 gracefully

      …

  ELSEIF GV_EVENT = ‘CHECK’.

      * Handle all custom validations using generic service

      …

  ENDIF.

  …
endmethod.

Ideal Expectation


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 –

TRY.
CALL BADI a_gs_badi_basic->do_operations
     
EXPORTING
           special_fields    
= special_fields
           service_operations
= service_operations
           no_auth_check     
= no_auth_check
           message_handler   
= gs_message_handler

            event              = event
        CHANGING
           help_datasets     
= help_datasets
           service_datasets  
= service_datasets_do_operations
           ui_attributes     
= loc_ui_attributes.
    
CATCH
           cx_badi              
“No BADI implementation exist
           cx_sy_dyn_call_error
. “Catch dynamic call errors
ENDTRY.

5 Comments
You must be Logged on to comment or reply to a post.
  • Good article.

    Sadly user event does not work as expected. Alternatively, create a service field called USR_EVENT and assign user event value before round trip happen; take this as indicator in DO_OPERATION method and performs as necessary.

    • Thanks Xiangli heah,

      Yah, that’s another alternative to resolve the same issue. Well, even with this approach, you would have to enhance the SAP Standard class!

      Regards

      Kuncham

  • From your lips to SAP’s ears, Raja. User events have been a pain point since inception and now that WDA forms have freed us from our ISR overlords, we should be able to find a way to extend beyond CHECK and INITIALIZE.  However, this is not quite the case yet. 

    • Agreed Justin,

      At least with this work around solution, we were able to solution many of our issues.

      Yah, I am sure SAP is hearing this feedback and hope they would come up with a stronger and better “User Event” solution.

      Let’s see…

  • did you try defining a user event that you assign to an operation that you defined in the method get_operations of your GS class? DO_OPERATIONS will be triggered and you’ll get the operations that are to be executed in the parameter SERVICE_OPERATIONS. Depending on your customising of the form only your custom GS in DO_OPERATIONS will be called and not SAP_PA for instance (depends on how you define the combination of fields).

    /wp-content/uploads/2016/03/hrasr_dt_scenario_user_events_900777.png