Skip to Content

This blog applies to SAP Netweaver 7.0, SAP HR EHP3(EA-HR 603) and above. For more information, visit the link.

 

Summary

 

In the current Employee self service(ESS), when the personal information is updated by the employee, it directly updates the record in the database. There are some organizations, where they want to validate the employee record before they actually get updated in SAP HR infotypes. This blog explains you in detail how the empolyee record is created with the locked status and HR administrators will remove the lock after validating the data. With this solution, dynamic action could also be acheived which is missing in the standard ESS solution.

      

Introduction

 

We faced the requirement from the client that all the personal information created/updated by employee through ESS should be validated by HR  administrator before the record is actually written to HR infotypes.

 

To cater this requirement, whenever the employee enters the data through Personal Data in ESS, the record is created in locked mode and a workflow is triggered to the HR administrator. When the HR administrator approves the request, PA30 transaction is displayed with employee data, allowing the approver to unlock the particular employee record.

This blog will explain about in updating the Family dependent info type(PA0021).

Lock the record created/updated from ESS

This is based on the De-Coupled Framework. To find more on this, refer the following link.


Below  picture will explain you at the high level.  BADI plays an important role in mapping the screen structure of ESS with infotype record structure.

 

/wp-content/uploads/2012/05/1_98960.png

 

Implement the BADI HRPAD00INFTYUI in R/3 system and perform the following changes. 

/wp-content/uploads/2012/05/2_98961.png

In one of the interface method INPUT_CONVERSION, perform the above changes. I have classified the record based on the structure name. You can simply validate based on the infotype name available in the structure pnnnn. Field sprps is the key field in creating the lock to the infotype record.

 

While saving the infotype record in locked mode, in parallel it’s important to trigger the workflow to the HR administrator.

Triggering Workflow to the HR administrators

 

While saving the infotype records, SAP standard calls the events entered through SWEHR2 and SWEHR3 transaction. SWEHR2 has the standard events while you can configure the custom events using SWEHR3 transaction.

 

Below is the configuration for Address infotype in transaction SWEHR3.

/wp-content/uploads/2012/05/3_98962.png

The function module ‘ZHR_EVENT_RULES_PA0021’ plays an important role in triggering the workflow to the HR administrators.

 

Function module to trigger the workflow

 

ZHR_EVENT_RULES_PA0021 is the copy of the standard function module HR_EVENT_RULES_PA0021.

This function module has the parameters such as

 

AFTER_IMAGE     – > Changed record.
BEFORE_IMAGE  – > Old record.

I have created a custom business object(ZFAMILYINT) which is the subtype of the standard business object FAMILYINT and used the after image key to trigger the workflow.

  

Code to trigger the Workflow using the Function module

 

FUNCTION zhr_event_rules_pa0021.

*”——————————————————————–
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(AFTER_IMAGE) LIKE  PRELP STRUCTURE  PRELP
*”     VALUE(BEFORE_IMAGE) LIKE  PRELP STRUCTURE  PRELP
*”     VALUE(BUSINESSOBJECT) LIKE  SWOTBASDAT-OBJTYPE
*”     VALUE(OPERATION) LIKE  T779W-WFOPR
*”  EXPORTING
*”     VALUE(EVENT) LIKE  SWETYPECOU-EVENT
*”  TABLES
*”      EVENTS_PER_OPERATION STRUCTURE  EVENTPOPER OPTIONAL
*”——————————————————————–

  DATA: lt_lock_return TYPE bapireturn1,

        real_event     LIKE swetypecou-event,

        real_workflow_id LIKE swetypecou-rectype,

        wi_id          LIKE swelog-recid,

        key            TYPE sweinstcou-objkey,

        event_cont     TYPE TABLE OF swcont,

        lv_old_param   TYPE bapip0006l,

        lv_new_param   TYPE bapip0006l.

*Generate the key of the old record

  DATA: key_of_record   LIKE  pakey,

        entity          LIKE  pspar-tclas,

        lv_pa_key       LIKE  pakey.

  DATA businessobjectkey  LIKE  sweinstcou-objkey.

  DATA addressempkey LIKE bapipakey.

*Check for the Operation

  IF businessobject CS ‘FAMILYINT’.

  ELSE.

    EXIT.

  ENDIF.

  IF sy-tcode CS ‘PA’.

    EXIT.

  ENDIF.

MOVE-CORRESPONDING after_image-pskey TO lv_pa_key.

  CALL FUNCTION ‘HR_ASSEMBLE_OBJECTKEY’

    EXPORTING

      businessobject    = ‘ZFAMILYINT’ “businessobject

      key_of_record     = lv_pa_key

      entity            = ‘A’

    IMPORTING

      businessobjectkey = businessobjectkey

    EXCEPTIONS

      OTHERS            = 1.

  real_event       = ‘CREATED’.

  real_workflow_id = ‘WS90000216’.

  CALL FUNCTION ‘SWW_WI_CREATE_VIA_EVENT’

    EXPORTING

      event                    = real_event

      rectype                  = real_workflow_id

      objtype                  = ‘ZFAMILYINT’

      objkey                   = businessobjectkey
*         EXCEPTIONS_ALLOWED       = ‘ ‘

   IMPORTING

     rec_id                   = wi_id

    TABLES

      event_container          = event_cont

            .

  IF sy-subrc <> 0.
*          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

Workflow high level design

In the workflow part, I’ve covered only the essential part which is to display the PA30 transaction with the locked record to the HR administrators.

 

Overview of Workflow:

/wp-content/uploads/2012/05/4_98963.png

I have designed the workflow in such a way that once the workflow is triggered, the workitem has to go to the Initiator of the workflow thus enabling the initiator to attach the documents required for the approval for his changed information in ESS.

 

In the next step of the workflow,  I have launched the custom transaction that will have the following information in the workitem.

 

The approver will see the workitem with the following information.

/wp-content/uploads/2012/05/5_98964.png

Once they click the approve button, it will launch the PA30 transaction in change mode for the particular employee record. In the description area of the workitem, you can display the changed information of the employee record.

Display family info: Displays the changed record in display mode.

/wp-content/uploads/2012/05/6_98985.png

Upon approval, HR administrator will then see the record  in changed mode as below.

/wp-content/uploads/2012/05/7_98986.png

 

Rejection of Workflow: It deletes the record  upon rejecting the workitem.

/wp-content/uploads/2012/05/8_98987.png

Display/Approve/Rejection logic in the Workflow:

I have added the new method in the business object that launches the custom transaction.

/wp-content/uploads/2012/05/9_98968.png

/wp-content/uploads/2012/05/10_98969.png

  Pass the input parameters of the function module and make it as a global parameters.

/wp-content/uploads/2012/05/11_98970.png

I have created the screen 9000, that has all the available buttons to the approvers.

 

In the PAI screen events,  place your business logic.

/wp-content/uploads/2012/05/12_98971.png

REMOVE_LOCK:

FORM remove_lock .

IF gv_employeenumber IS NOT INITIAL.

DATA: address TYPE bapiaddr3,

          return  TYPE TABLE OF bapiret2.

    DATA:  lv_data TYPE TABLE OF seqg3,

           lv_result TYPE sy-tabix.

    DATA lv_rec TYPE pa0105.

    SELECT SINGLE * FROM pa0105 INTO lv_rec WHERE pernr = gv_employeenumber AND

                                                  begda LE sy-datum AND

                                                  endda GE sy-datum AND

                                                  subty = ‘0001’.

    IF sy-subrc EQ 0.

       DATA: lv_name(12) TYPE C.

       lv_name =  lv_rec-usrid.

      CALL FUNCTION ‘ENQUEUE_READ’

        EXPORTING

          gclient = sy-mandt

          guname  = lv_name

        IMPORTING

          number  = lv_result

        TABLES

          enq     = lv_data.

      IF sy-subrc <> 0 OR lv_result GT 0.

        MESSAGE e000(zess).

        EXIT.

      ENDIF.

   ENDIF.

  ENDIF.

ENDFORM.

APPROVE DEPENDENTS:

  SET PARAMETER ID ‘ITP’ FIELD ‘0021’.“OBJECT-INFOTYPENUMBER.

SET PARAMETER ID ‘SUB’ FIELD GV_SUBTYPE .

SET PARAMETER ID ‘BEG’ FIELD GV_VALIDITYBEGIN.

SET PARAMETER ID ‘END’ FIELD GV_VALIDITYEND.

SET PARAMETER ID ‘PER’ FIELD GV_EMPLOYEENUMBER.

SET PARAMETER ID ‘FCD’ FIELD ‘MOD’.“DISPLAY.

SET PARAMETER ID ‘OPS’ FIELD GV_OBJECTID.       “VAPP30K122770

SET PARAMETER ID ‘SPP’ FIELD GV_LOCKINDICATOR.  “VAPP30K122770

SET PARAMETER ID ‘PSQ’ FIELD GV_RECORDNUMBER.   “VAPP30K122770

SET PARAMETER ID ‘PAK’ FIELD ‘X’.                  “VAPP30K130205

CALL TRANSACTION ‘PA30’ AND SKIP FIRST SCREEN.

DISPLAY DEPENDENTS:

SET PARAMETER ID ‘ITP’ FIELD ‘0021’.“OBJECT-INFOTYPENUMBER.

SET PARAMETER ID ‘SUB’ FIELD GV_SUBTYPE .

SET PARAMETER ID ‘BEG’ FIELD GV_VALIDITYBEGIN.

SET PARAMETER ID ‘END’ FIELD GV_VALIDITYEND.

SET PARAMETER ID ‘PER’ FIELD GV_EMPLOYEENUMBER.

SET PARAMETER ID ‘FCD’ FIELD ‘DIS’.“DISPLAY.

SET PARAMETER ID ‘OPS’ FIELD GV_OBJECTID.       “VAPP30K122770

SET PARAMETER ID ‘SPP’ FIELD GV_LOCKINDICATOR.  “VAPP30K122770

SET PARAMETER ID ‘PSQ’ FIELD GV_RECORDNUMBER.   “VAPP30K122770

SET PARAMETER ID ‘PAK’ FIELD ‘X’.                  “VAPP30K130205

CALL TRANSACTION ‘PA20’ AND SKIP FIRST SCREEN.

   

LEAVE_SCREEN:

form LEAVE_SCREEN .

SET SCREEN 0.
LEAVE SCREEN.

endform.

Information about Business Object ADDRESSEMP

I have used the method ChangeInteractive  to edit the record in change mode. For rejection, I’ve used the method DeleteInteractive as shown
below.

/wp-content/uploads/2012/05/13_98972.png

Thanks,

S.Rajkumar.

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

  1. Balaji Kalaivani

    Hi Rajkumar,

    I need a help from you regarding this topic.

    I am developing a workflow of same type, but here the user is allowed for 30 days to submit the document and after that the HR admin will process personal info change.

    I am able to trigger the workflow but after triggering the workflow the standard SAP program is called and it is updating the info types.

    I dont want to update the DB before the HR approves the request.

    Can you please give me some clues on the same?

    Thanks

    Bala

    (0) 
    1. Suresh Subramanian

      Hello Balaji !

                One possible suggestion could be to create a custom screen for employee submission. The submitted details can be collected in internal table( to avoid redundancy)/custom table and thus can be passed to workflow.

                If the approver approves, by calling CREATEINTERACTIVE method from FAMILYINT business object, standard table can be updated and the relevant entries in custom table can be deleted if required and internal table is not used.

      Regards,

      S.Suresh.         

      (0) 
  2. Ali Elkhatib

    Hi Rajkumar,

    Can you please clarify the below statement. I am not sure I understand how can you enable attachements by designing the workflow – can you please provide more details? and where would the initiator attach documents?

    I have designed the workflow in such a way that once the workflow is triggered, the workitem has to go to the Initiator of the workflow thus enabling the initiator to attach the documents required for the approval for his changed information in ESS

    Many Thanks!

    (0) 
    1. Rajkumar Shanmuganathan Post author

      Hi Elkhatib,

      The requirement was to attach any proof of documents whenever the employee changes his personal details in the ESS Screen. As there is no provision in the Standard ESS webdynpro Pages to attach the documents, WF is designed in such a way, the approval will first come to the initiator/Employee who has updated the information. Once the Workitem reaches the employee, there is always an provision to attach any documents within the workitem itself.

      To make it simple, you can attach documents in the workitem as its a standard feature provided by SAP.

      Thanks,

      S.Rajkumar.

      (0) 
  3. jonathan espiniella

    Hi S.Rajkumar,

    Thanks a lot for your document. It is very useful for us.

    However I need a help from any of you regarding this topic

    • We need to develop some similar workflows for ESS personal information records but with all of these infotypes, IT0002, IT0009, IT0021 and IT0185.

    We appreciate this  document but it is focus on IT0021. And when trying to do some similar with the others, we have found that neither IT0009 nor IT0185 contains any rows  in SWEHR2 in order to look for the object and Function module implied. Could you let us know any way to continue? Any object related with the possible triger for these infotypes in order to create another Z function for them?

    • Furthermore, when trying to do some similar for infotype IT0002, we noticed that the record could not be locked, not even with transaction PA30. Then, the changes are updated  when user makes the changes so there is no way to approve or reject them later. Could you please give us an idea to find a similar solution?

             Thanks a lot ,

    Jonathan

    (0) 

Leave a Reply