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

Problem performing HR_MAINTAIN_MASTERDATA

brunoambrozio
Participant
0 Likes
1,486

Hi,

We have developed a program to change the cost center of an employee.

This program is composed by 2 steps: the first one is updating the relationships and the second one is executing a personnel action.

The problem we are facing is, when the personnel action  is executed (with  HR_MAINTAIN_MASTERDATA FM) after the relationships updating sometimes (yes, sometime) the following error is returned: "The employee cannot be locked". However, after receiving this error, if we execute again the program, the process is finished with success and all relationships and infotypes are updated.

Unfortunatelly, in some cases, the manager can change the job as well as the cost center and for this reason, before executing the personnel action, we need the relationships updated.

I believe that, this message is related the delay that SAP has after performing RH_UPDATE_DATABASE to update the database.

These 2 phases are developed as bellow:

1 - Clear the buffer (HR_PSBUFFER_INITIALIZE FM).

2 - Lock the employee

3 - Update relationships ( RH_CUT_INFTY FM)

4 - RH_UPDATE_DATABASE (i_task = 'S')  -> we have tried putting SET UPDATE TASK LOCAL before this FM, but without success

5 - Execute personnel action (HR_MAINTAIN_MASTERDATA FM) -> THE PROBLEM IS THROWN HERE

6 - Unlock the employee

7 - UPDATE a Z table.

CALL FUNCTION 'RH_UPDATE_DATABASE'

     EXPORTING

       vtask     = 'S' (We've tried = 'D', but without success)

     EXCEPTIONS

       corr_exit = 1

       OTHERS    = 2.

CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'

     EXPORTING

       pernr           = wa_colaborador_proposto-pernr

       massn           = lv_medida

       actio           = 'COP'

       tclas           = 'A'

       begda           = i_begda

       endda           = i_endda

       werks           = wa_colaborador_proposto-werks

       persg           = wa_colaborador_proposto-persg

       persk           = wa_colaborador_proposto-persk

       plans           = wa_colaborador_proposto-plans

       dialog_mode     = i_tipo_exec

       no_enqueue      = '' (We've tried = 'X', but without success)

       luw_mode        = '1'

     IMPORTING

       return          = wa_return

       return1         = wa_return1

       hr_return       = wa_hr_return

     TABLES

       proposed_values = it_proposed_values.

Actually, we have tried many other parameter options, but all of them without success. Has someone any tip to solve this issue?

Thanks.

Bruno

2 REPLIES 2
Read only

Former Member
0 Likes
990

Hi Bruno,

I just noticed your post because I cannot get my RH_CUT_INFTYP Functional Module to work.  If yours is working could you perhaps send me a sample of your code?

As for your Problem, you might have already resolved it , but if not I use the FM  HR_INFOTYPE_OPERATION and not the HR_MAINTAIN_MASTERDATA that you have mentioned.  I have no problems with it

  CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
      INFTY         = '0015'             "InfoType 15
      NUMBER        = c_pernr       "Employee #
      SUBTYPE       = rec-subty     "Subtype
      VALIDITYEND   = rec-begda     "End Date
      VALIDITYBEGIN = rec-begda     "Begin Date
      RECORD        = P0015         "Record to chg/ins or del
      OPERATION     = operation     "MOD, INS or DEL
      TCLAS         = 'A'
      DIALOG_MODE   = '0'
      NOCOMMIT      = p_test        "if X then don't commit
    IMPORTING
      RETURN        = BAPIRETURN1.

Read only

0 Likes
990

I solved my problem bu using RH_CUT_INFTY_GENERIC and it worked (this was to delimit the hrp1000 object).  I hope you were able to solve yours.