Application Development 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: 

HR_MAINTAIN_MASTERDATA

former_member431450
Participant
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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

former_member188685
Active Contributor
0 Kudos

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        =
          .

Former Member
0 Kudos

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