Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
ChrisPaine
Active Contributor
6,377

Hello,

It's been a while since I've thrown together a blog which hasn't involved cloud or mobile or just general ranting, but today I threw together some code that was so simple and useful that I just had to share it. :grin:

The business problem

The client wanted a solution where accessing their ESS personal profile screens would not lock the employee records, but only during the day or so a month that payroll was processing.

Now, personally, if I had my way there wouldn't be a need for this as I'd redesign payroll on HANA such that payroll processing was obsolete... but that's another blog and a dream away.

The solution

A simple switch?

There is a parameter for the WDA personal profile application that can be set to put the application into a read-only state.  Check outsagar.joshi blog post Exciting Enhacements to ESS Personal Information Profile in Enhancement pack 6 for an explanation of the various parameters.

So by setting the WD application parameter READ_ONLY_PERSONAL_PROFILE equal to 'X' the application won't cause a lock. :smile:

Unfortunately a little testing found that this wasn't actually the case :sad:

A search on Service Market Place however found:

After implementing the note, the promised functionality did work :smile:

Making it dynamic

So I could now switch the functionality to read only by using an application parameter, the question was how to do this dynamically?

Sometime the simplest ways are best :smile:

I created a simple freestyle FPM UIBB:

and in the WDDOINIT method added some very simple code:

METHOD wddoinit .
  DATA: lo_fpm TYPE REF TO if_fpm,
        lv_dummy TYPE string.
  IF wd_assist->is_pay_processing( ) = abap_true.
    lo_fpm = cl_fpm_factory=>get_instance( ).
    lo_fpm->mo_app_parameter->set_value(
        iv_key   = 'READ_ONLY_PROFILE_WITH_DETAILS'
        iv_value = abap_true
    ).
    MESSAGE e000(zm_hr_ess) INTO lv_dummy.
    lo_fpm->mo_message_manager->report_t100_message(
        iv_msgid     =  'ZM_HR_ESS'   " Message indentification (Class)
        iv_msgno     =  '000'   " Message number
        io_component =  wd_this->wd_get_api( ) 
        iv_severity  = if_fpm_message_manager=>gc_severity_warning  ).  " Report the severity of the message
   
  ENDIF.
ENDMETHOD.

This code called the assistance class to figure out if the payroll was processing. The logic of that will quite possibly vary from site to site so I won't go into too much detail (also because I don't think my employee object is perfectly implemented either (should have built an interface and a factory method, but never mind!)

METHOD is_pay_processing.
  DATA: lo_pernr TYPE REF TO zcl_hr_employee.
  TRY.
      CREATE OBJECT lo_pernr
        EXPORTING
          iv_pernr = cl_hress_employee_services=>get_instance( )->get_pernr( ).
      rv_payroll_processing = lo_pernr->is_pay_processing( ).
    CATCH cx_hress.
* caught and handled by main ESS page too
  ENDTRY.
ENDMETHOD.

Note the use of the cl_hress_employee_services method - very useful!

Adding it together

Now I added this UIBB into the INITIAL_SCREEN of my ESS config.

It's important that it's the first UIBB in the page - as this determines that it gets called first!

To wrap up

So I met the customer's requirement to have a dynamic read-only ESS screen with very little code indeed, and even better, no modifications or enhancements! :smile:

I hope this post is of use to you, it was such a simple :cool: solution that it really needed to be shared. Hopefully it might save you buying a really expensive modification solution from a third party! :grin: Just throw a little code together and you should have a solution that can work in less than a day.

All the usual disclaimers, as in, even if the pictures above make it very clear that the solution and code provided work, they might not, they might even make little green men start running out of your coffee machine - you implement at your own risk! No opinions expressed here should be taken as representing the company I work for, the client I implemented this for or anything other than my ramblings. Nothing here or should be relied on for making any decisions whatsoever.  HTTP 418.

15 Comments
Labels in this area