Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_EMPLOYEE_ENQUEUE not working

Former Member
0 Likes
2,119

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,539

hi,

what do you mean by not work?

do you get an error message?

Read only

0 Likes
1,539

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

Read only

0 Likes
1,539

Where do you get the error?

Rob

Read only

0 Likes
1,539

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.

Read only

0 Likes
1,539

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

Read only

0 Likes
1,539

Hi,

You are inserting a new record in PA0006. If teh pernr doesnt exist already, how will you lock it?

operation     = 'INS'

Read only

0 Likes
1,539

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

Read only

0 Likes
1,539

Well, I count four operations and you still haven't told us after which one you get the error.

Rob

Read only

0 Likes
1,539

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.

Read only

Shahid
Product and Topic Expert
Product and Topic Expert
0 Likes
1,539

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.