cancel
Showing results for 
Search instead for 
Did you mean: 

error log for fm hr_infotype_operation

Former Member
0 Kudos

Hi all .

I am using the function module 'HR_INFOTYPE_OPERATION

to update an infotype. Its working fine but suppose if some other user has already opend the employee for which the record is being updated - or the employee is locked, the FM do not returns any error message in return table. Please let me know how to trap the errors in this FM.

Also when I check the value of Sy-subrc after this fm runs, every time the value is 0. Please suggest.

Thanks

Ribhu

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I came across with this last few days.

Correct solution is that using Function modules.

Steps:

1.Call FM 'BAPI_APPRAISAL_ENQUE' before doing the Infotype operation .

2. Call FM 'HR_INFOTYPE_OPERTAION'.

3.Call FM 'BAPI_APPRAISAL_DEQUE' after doing the operation.

using bapi return value we will handle the errors like

1.the pernr is alreay locked by xyz user

2.no of succesful records

3.no of failed records

If you need program which I have done , make a reply.

Hope this will help you.

Thanks,

Anil

Former Member
0 Kudos

Hi,

I am using employee enque before hr_infotype_operation

below is the code.

However my problem is still unresolved. when the employee is locked in one session and in other i am using hr_infotype operation, after HR_EMPLOYEE_ENQUEUE, subrc is still 0 only. Please suggest

REPORT ZBDC_0008.

data: begin of p0008 occurs 0.

include structure p0008.

Data: end of p0008.

data begin of return occurs 0.

include structure BAPIRETURN1.

data end of return.

data key like BAPIPAKEY.

P0008-PERNR = '00009600'.

P0008-INFTY = '0008'.

*P0008-SUBTY = '0'.

P0008-ENDDA = '99991231'.

P0008-BEGDA = '20070301'.

*P0008-TRFAR = 'SL'.

*P0008-TRFGB = '01'.

*P0008-TRFGR = 'DIRIT01'.

*P0008-TRFST = '01'.

*P0008-BSGRD = '100'.

*P0008-DIVGV = '86.67'.

*P0008-LGA01 = '1005'.

P0008-ANCUR = 'USD'.

p0008-BET01 = '1022'.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0008-pernr.

wait UP TO 10 seconds.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0008'

NUMBER = P0008-PERNR

  • SUBTYPE =

  • OBJECTID =

LOCKINDICATOR = ''

VALIDITYEND = P0008-ENDDA

VALIDITYBEGIN = P0008-BEGDA

  • RECORDNUMBER =

RECORD = P0008

OPERATION = 'COP'

TCLAS = 'A'

  • DIALOG_MODE = '0'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = return.

KEY = key.

.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = p0008-pernr.

if sy-subrc = 0.

write 'success'.

endif.

former_member31961
Contributor
0 Kudos

Hi,

HR_EMPLOYEE_ENQUEUE has two export parameters RETURN and LOCKING_USER,

if employee is not locked then locking_user and return will be initial.

If employee is locked then RETURN will have error message , LOCKING_USER will have locker user name.

Regards,

Shrinivas

Former Member
0 Kudos

Hi,

I am sending the code which I have done previously,

If it is applicable use this code.

*Enqueue Employee

CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'

EXPORTING

NUMBER = WA_0759_FR-PERNR

VALIDITYBEGIN = SY-DATUM

IMPORTING

RETURN = R_ENQ.

*Error Log

IF R_ENQ-TYPE = C_E OR R_ENQ-TYPE = C_A.

I_LOG_FR-TYPE = R_ENQ-TYPE.

I_LOG_FR-MESSAGE = R_ENQ-MESSAGE.

I_LOG_FR-WS_COLOR = C_C611.

  • APPEND I_LOG_FR.

ELSE.

*Insert Infotype 0759

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = C_0759

NUMBER = WA_0759_FR-PERNR

SUBTYPE = WA_0759_FR-SUBTY

OBJECTID = WA_0759_FR-OBJPS

LOCKINDICATOR = WA_0759_FR-SPRPS

VALIDITYEND = WA_0759_FR-ENDDA

VALIDITYBEGIN = WA_0759_FR-BEGDA

RECORDNUMBER = WA_0759_FR-SEQNR

RECORD = WA_0759_FR

OPERATION = C_INS

TCLAS = C_A

NOCOMMIT = C_X

IMPORTING

RETURN = R_OPER.

IF R_OPER-TYPE NE C_E AND

R_OPER-TYPE NE C_A.

SUCC = SUCC + 1.

  • APPEND I_LOG_FR.

ELSE.

I_LOG_FR-TYPE = R_OPER-TYPE.

I_LOG_FR-MESSAGE = R_OPER-MESSAGE.

I_LOG_FR-WS_COLOR = C_C611.

  • APPEND I_LOG_FR.

ENDIF.

*Dequeue Employee

CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'

EXPORTING

NUMBER = WA_0759_FR-PERNR

VALIDITYBEGIN = SY-DATUM

IMPORTING

RETURN = R_DEQ.

*Error Log

IF R_DEQ-TYPE = C_E OR R_DEQ-TYPE = C_A.

MOVE-CORRESPONDING WA_0759_FR to I_LOG_FR.

I_LOG_FR-EFF_DATE = IT_0759_FR-EFF_DATE.

I_LOG_FR-TYPE = R_DEQ-TYPE.

I_LOG_FR-MESSAGE = R_DEQ-MESSAGE.

I_LOG_FR-WS_COLOR = C_C611.

  • APPEND I_LOG_FR.

ENDIF.

ok

Thanks,

Anil

Former Member
0 Kudos

Hi

Use the Function module HR_MAINTAIN_MASTERDATA directly in your program. Here you also have the option to explicitly lock the PERNR before doing the operations.

One thing to be kept in mind is if the PERNR is locked in one session and the operation is called in another session (for the same User) it will still fail.

Plz do get back if you want more info.

Thanks

Sharath.

Former Member
0 Kudos

Hi,

I am using employee enque before hr_infotype_operation

below is the code.

However my problem is still unresolved. when the employee is locked in one session and in other i am using hr_infotype operation, after HR_EMPLOYEE_ENQUEUE, subrc is still 0 only. Please suggest

REPORT ZBDC_0008.

data: begin of p0008 occurs 0.

include structure p0008.

Data: end of p0008.

data begin of return occurs 0.

include structure BAPIRETURN1.

data end of return.

data key like BAPIPAKEY.

P0008-PERNR = '00009600'.

P0008-INFTY = '0008'.

*P0008-SUBTY = '0'.

P0008-ENDDA = '99991231'.

P0008-BEGDA = '20070301'.

*P0008-TRFAR = 'SL'.

*P0008-TRFGB = '01'.

*P0008-TRFGR = 'DIRIT01'.

*P0008-TRFST = '01'.

*P0008-BSGRD = '100'.

*P0008-DIVGV = '86.67'.

*P0008-LGA01 = '1005'.

P0008-ANCUR = 'USD'.

p0008-BET01 = '1022'.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0008-pernr.

wait UP TO 10 seconds.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0008'

NUMBER = P0008-PERNR

  • SUBTYPE =

  • OBJECTID =

LOCKINDICATOR = ''

VALIDITYEND = P0008-ENDDA

VALIDITYBEGIN = P0008-BEGDA

  • RECORDNUMBER =

RECORD = P0008

OPERATION = 'COP'

TCLAS = 'A'

  • DIALOG_MODE = '0'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = return.

KEY = key.

.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = p0008-pernr.

if sy-subrc = 0.

write 'success'.

endif.

former_member31961
Contributor
0 Kudos

Hi Ribhu,

You have lock Employee explicitly using FM 'BAPI_EMPLOYEE_ENQUEUE' before using HR_INFOTYPE_OPERATION'. Hence you catch catch the error here, if employee is locked sy-subrc will be non zero .

If you lock employee manually (by going into PA30), and then run the FM 'HR_INFOTYPE_OPERATION', the FM doesn't throw error since you only locked the employee / also interestingly it doesnt update the record. I need check why this happens like this way. I will update you soon.

Hope this helps,

Shrinivas

Former Member
0 Kudos

Hi,

I am using employee enque before hr_infotype_operation

below is the code.

However my problem is still unresolved. when the employee is locked in one session and in other i am using hr_infotype operation, after HR_EMPLOYEE_ENQUEUE, subrc is still 0 only. Please suggest

REPORT ZBDC_0008.

data: begin of p0008 occurs 0.

include structure p0008.

Data: end of p0008.

data begin of return occurs 0.

include structure BAPIRETURN1.

data end of return.

data key like BAPIPAKEY.

P0008-PERNR = '00009600'.

P0008-INFTY = '0008'.

*P0008-SUBTY = '0'.

P0008-ENDDA = '99991231'.

P0008-BEGDA = '20070301'.

*P0008-TRFAR = 'SL'.

*P0008-TRFGB = '01'.

*P0008-TRFGR = 'DIRIT01'.

*P0008-TRFST = '01'.

*P0008-BSGRD = '100'.

*P0008-DIVGV = '86.67'.

*P0008-LGA01 = '1005'.

P0008-ANCUR = 'USD'.

p0008-BET01 = '1022'.

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0008-pernr.

wait UP TO 10 seconds.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0008'

NUMBER = P0008-PERNR

  • SUBTYPE =

  • OBJECTID =

LOCKINDICATOR = ''

VALIDITYEND = P0008-ENDDA

VALIDITYBEGIN = P0008-BEGDA

  • RECORDNUMBER =

RECORD = P0008

OPERATION = 'COP'

TCLAS = 'A'

  • DIALOG_MODE = '0'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = return.

KEY = key.

.

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = p0008-pernr.

if sy-subrc = 0.

write 'success'.

endif.