‎2011 Jul 14 12:09 PM
Hi All,
We are using the FM BAPI_EMPLOYEE_ENQUEUE to lock the pernr while creating the infotypes ,but sometimes the FM wil not work any idea what is the issue ?
Regards
CB
‎2011 Jul 14 12:32 PM
hi,
what do you mean by not work?
do you get an error message?
‎2011 Jul 14 5:09 PM
Hi ,
IT gives the error saying the "Personal number couldn't be locked" ,even thought we are using below FM's
Lock the Pernr
call function 'BAPI_EMPLOYEE_ENQUEUE'
exporting
number = lw_pa0006_92-pernr
importing
return = wa_return.
ls_p0006-pernr = lw_pa0006_92-pernr.
ls_p0006-begda = lw_pa0006_92-begda.
ls_p0006-endda = lw_pa0006_92-endda.
ls_p0006-stras = lw_pa0006_92-stras.
ls_p0006-pstlz = lw_pa0006_92-pstlz.
ls_p0006-ort01 = lw_pa0006_92-ort01.
ls_p0006-land1 = lw_pa0006_92-land1.
call function 'HR_INFOTYPE_OPERATION'
exporting
infty = '0006'
number = ls_p0006-pernr
subtype = '5'
validityend = ls_p0006-endda
validitybegin = ls_p0006-begda
record = ls_p0006
LOCKINDICATOR = 'X'
operation = 'INS'
importing
return = wa_return.
call function 'BAPI_EMPLOYEE_DEQUEUE'
exporting
number = ls_p0006-pernr
importing
return = wa_return.So is there any issue with this code?
Regards
CB
‎2011 Jul 14 5:18 PM
‎2011 Jul 14 5:37 PM
Hi ,
> IT gives the error saying the "Personal number couldn't be locked" ,even thought we are using below FM's
> Lock the Pernr
> call function 'BAPI_EMPLOYEE_ENQUEUE'
> exporting
> number = lw_pa0006_92-pernr
> importing
> return = wa_return.
> CB
Please get the basics right, [SAP lock concept|http://help.sap.com/saphelp_nw04/helpdata/en/c2/2d7037ecc92a7ee10000009b38f8cf/content.htm]
You have to check the message returned(wa_return) by the 'BAPI_EMPLOYEE_ENQUEUE' and only when the FM succeeds in locking the employee you should proceed to change the employee data via 'HR_INFOTYPE_OPERATION'. In case the FM fails to lock the employee(which would be the case when you/someone else are working parallelly on the same employee data in a different session) you should not change the employee data in your program.
-Rajesh.
‎2011 Jul 14 5:59 PM
Hi Rajesh,
Actually we are newly creating an employee in the same program ,after doing BDC for PA40 ,we are deque the Pernr ,then we will go use BAPI_EMPLOYEE_ENQUEUE to enque ,but this FM is not working ,since Pernr is new one no one can access
Regards
CB
‎2011 Jul 15 6:09 AM
Hi,
You are inserting a new record in PA0006. If teh pernr doesnt exist already, how will you lock it?
operation = 'INS'
‎2011 Jul 15 7:00 AM
Hi ,
Before updating the pa0006 ,the pernr already created with PA40 action using BDC ,after thta we are deque the pernr and try to insert the pa0006.
Regards
CB
‎2011 Jul 15 2:06 PM
Well, I count four operations and you still haven't told us after which one you get the error.
Rob
‎2011 Jul 15 4:46 PM
Hi Rajesh,
> Actually we are newly creating an employee in the same program ,after doing BDC for PA40 ,we are deque the Pernr ,then we will go use BAPI_EMPLOYEE_ENQUEUE to enque ,but this FM is not working ,since Pernr is new one no one can access
>
> Regards
> CB
If you are successful with your BDC, any locks set must have been removed, then ideally you should be able to place
locks on the new pernr created using the FM 'BAPI_EMPLOYEE_ENQUEUE'. Capture the return messages of the BDC(assuming that you are following CALL TRANSACTION..approach) and ensure that your BDC is infact successful.
If the FM fails to lock the pernr, I would also expect to see the personnel number in the return message, viz.,
'Personnel number xxxxxxxx could not be locked', which confirms that a new personnel number is infact created and the FM
failed to lock the pernr.
And you don't have to transfer 'X' to the 'LOCK_INDICATOR' parameter of the FM 'HR_INFOTYPE_OPERATION', this parameter indicates a lock set to the particular infotype record and is no way releated to SAP lock.
Please work through the code yourself, debug diligently, provide appropriate and accurate information to community and expect help from the community. good luck
-Rajesh.
‎2011 Jul 15 2:25 PM
After reading this thread, its clear that a BDC creates a PERNR, and then you dequeue it. and then you have a spearate program update pa2006 which throws an error that it cant be locked.
can you try the below two things?
1. Are you able to create an entry from the transaction code PA30 for the new pernr?
2. Just check whether u came out of PA30/PA40 transactions once it is dequeued after creating PERNR.
even thought its not the practice, once this 'BAPI_EMPLOYEE_ENQUEUE' fails, continue the code to
check whether you can dequeue it by using 'BAPI_EMPLOYEE_DEQUEUE', Atleast we will try to understand whether we do really have an issue with locking the pernr.