09-05-2008 10:07 PM
From a program Z that updates the IT0009, I am calling to the FM HR_INFOTYPE_OPERATION, and this one calls to FM HR_MAINTAIN_MASTERDATA.
The FM HR_MAINTAIN_MASTERDATA returns the mistake 184 " The employee / Applicant yet is not blocked ". I have verified that the mentioned message is avoided if PA30 is opened, with the employee whose we update.
Please, he would be grateful for some indication to achieve that the function executes without needing the PA30 is opened, situation that is not reasonable.
Thank very much.
09-06-2008 1:35 AM
Before Calling the FM call another FM BAPI_EMPLOYEE_ENQUEUE. *-- > Lock Employee*
and after the call is done call BAPI_EMPLOYEE_DEQUEUE --> Unlock Employee
Hope this resolves your problem.
A
09-06-2008 4:04 AM
you need to lock before calling and unlock after the call.
"Locking
call function 'HR_EMPLOYEE_ENQUEUE'
exporting
number = wa_personal-pernr
* IMPORTING
* RETURN =
* LOCKING_USER =
.
call function 'HR_INFOTYPE_OPERATION'
exporting
infty = '0002'
number = fs_personal-pernr
* SUBTYPE =
* OBJECTID =
* LOCKINDICATOR =
validityend = fs_personal-endda
validitybegin = fs_personal-begda
* RECORDNUMBER =
record = fs_personal
operation = 'MOD'
* TCLAS = 'A'
* DIALOG_MODE = '0'
* NOCOMMIT =
* VIEW_IDENTIFIER =
* SECONDARY_RECORD =
importing
return = w_ret
* KEY =
.
"unlock
call function 'HR_EMPLOYEE_DEQUEUE'
exporting
number = wa_personal-pernr
* IMPORTING
* RETURN =
.
09-06-2008 4:37 AM
Hi Ed,
You need to call the function module 'HR_EMPLOYEE_ENQUEUE' before HR_MAINTAIN_MASTERDATA to lock the record, ie., no other person can work on that record except you.
Then call the function module HR_MAINTAIN_MASTERDATA .
You need to call the function module 'HR_EMPLOYEE_DEQUEUE' after HR_MAINTAIN_MASTERDATA to unlock the record.
Check this one:
CONSTANTS: change TYPE pspar-actio VALUE 'MOD'.
"This code is requred and locks the record ready for modification
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.
"loop at p0071 into p_p0071. "added to put code in context
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-endda = pn-begda - 1.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0071'
subtype = p_record-subty
objectid = P_record-objps
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
recordnumber = p_record-SEQNR
operation = change
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
"endloop.
"unlock record after modification
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.
Regards,
Chandra Sekhar