We have developed a program to change the cost center of an employee.
This program is composed by 2 steps: the first one is updating the relationships and the second one is executing a personnel action.
The problem we are facing is, when the personnel action is executed (with HR_MAINTAIN_MASTERDATA FM) after the relationships updating sometimes (yes, sometime) the following error is returned: "The employee cannot be locked". However, after receiving this error, if we execute again the program, the process is finished with success and all relationships and infotypes are updated.
Unfortunatelly, in some cases, the manager can change the job as well as the cost center and for this reason, before executing the personnel action, we need the relationships updated.
I believe that, this message is related the delay that SAP has after performing RH_UPDATE_DATABASE to update the database.
These 2 phases are developed as bellow:
1 - Clear the buffer (HR_PSBUFFER_INITIALIZE FM).
2 - Lock the employee
3 - Update relationships ( RH_CUT_INFTY FM)
4 - RH_UPDATE_DATABASE (i_task = 'S') -> we have tried putting SET UPDATE TASK LOCAL before this FM, but without success
5 - Execute personnel action (HR_MAINTAIN_MASTERDATA FM) -> THE PROBLEM IS THROWN HERE
6 - Unlock the employee
7 - UPDATE a Z table.
CALL FUNCTION 'RH_UPDATE_DATABASE'
vtask = 'S' (We've tried = 'D', but without success)
corr_exit = 1
OTHERS = 2.
CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
pernr = wa_colaborador_proposto-pernr
massn = lv_medida
actio = 'COP'
tclas = 'A'
begda = i_begda
endda = i_endda
werks = wa_colaborador_proposto-werks
persg = wa_colaborador_proposto-persg
persk = wa_colaborador_proposto-persk
plans = wa_colaborador_proposto-plans
dialog_mode = i_tipo_exec
no_enqueue = '' (We've tried = 'X', but without success)
luw_mode = '1'
return = wa_return
return1 = wa_return1
hr_return = wa_hr_return
proposed_values = it_proposed_values.
Actually, we have tried many other parameter options, but all of them without success. Has someone any tip to solve this issue?