SAP ABAP HR: Function Module "BAPI_EMPLOYEE_ENQUEUE"

BAPI_EMPLOYEE_ENQUEUE and BAPI_EMPLOYEE_DEQUEUE are standard Function modules to lock / unlock employees so that their records can be changed while they are not accessible to others for change. The user who has locked an employee can only unlock it.

I took the below excerpt from standard program HIECPAC0 (Report to change Payroll area for multiple employees) to showcase the use of function modules BAPI_EMPLOYEE_ENQUEUE to lock and BAPI_EMPLOYEE_DEQUEUE to unlock an employee (PERNR) so that its infotype 0001 can be updated :

      call function 'BAPI_EMPLOYEE_ENQUEUE'
             exporting
                  number = pr-pernr
             importing
                  return = return.

        if return-type = 'A' or return-type = 'E'.
            .............................
            .............................
            .............................

      call function 'HR_INFOTYPE_OPERATION'
         exporting
           infty                  = '0001'
           number                 = i0001-pernr
*            SUBTYPE                =
*            OBJECTID               =
*            LOCKINDICATOR          =
          validityend             = i0001-begda
          validitybegin           = i0001-endda
*            RECORDNUMBER           =
           record                 = i0001
           operation              = 'COP'
*            TCLAS                  = 'A'
*            DIALOG_MODE            = '0'
*            NOCOMMIT               =
*            VIEW_IDENTIFIER        =
*            SECONDARY_RECORD       =
        importing
          return                 = return
          key                    = key .
            .............................
            .............................
            .............................
      call function 'BAPI_EMPLOYEE_DEQUEUE'
           exporting
              number = pr-pernr.

    
Function modules HR_EMPLOYEE_ENQUEUE and HR_EMPLOYEE_DEQUEUE serve the same purpose as the pair of BAPI_EMPLOYEE_ENQUEUE  and BAPI_EMPLOYEE_DEQUEUE but the later are recommended. An excerpt from a standard function module HRCM_EMPLOYEE_ENQUEUE shows its use :

*     try to enqueue employee
      CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
        EXPORTING
          number       = emp_info_table-pernr
        IMPORTING
          return       = return
          locking_user = l_locking_user.
*      CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
*           EXPORTING
*                number = emp_info_table-pernr
*           IMPORTING
*                return = return.


BAPI_EMPLOYEE_ENQUEUE can also be used to lock a PERNR in the same way as shown above in the commented code.

The corresponding function modules to unlock an employee(PERNR) are : 
  • HR_EMPLOYEE_DEQUEUE
  • BAPI_EMPLOYEE_DEQUEUE

In case of Applicants, the respective function modules to lock / unlock them are : 
  • BAPI_APPLICANT_ENQUEUE
  • BAPI_APPLICANT_DEQUEUE

Featured Post

Top 5 Reasons you should be on Google+: [1] Immersive Look-and-Feel

Updated on August 5, 2017  due to remarkable changes in the landscape of Google+ making the post up-to-date and current. Enjoy the updated...