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.
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).
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.
Implement the BADI HRPAD00INFTYUI in R/3 system and perform the following changes.
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.
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.
The function module ‘ZHR_EVENT_RULES_PA0021’ plays an important role in triggering the workflow to the HR administrators.
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.
*"--------------------------------------------------------------------
*"*"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.
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:
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.
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.
Upon approval, HR administrator will then see the record in changed mode as below.
Rejection of Workflow: It deletes the record upon rejecting the workitem.
Display/Approve/Rejection logic in the Workflow:
I have added the new method in the business object that launches the custom transaction.
Pass the input parameters of the function module and make it as a global parameters.
I have created the screen 9000, that has all the available buttons to the approvers.
In the PAI screen events, place your business logic.
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.
I have used the method ChangeInteractive to edit the record in change mode. For rejection, I’ve used the method DeleteInteractive as shown
below.
Thanks,
S.Rajkumar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |