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: 

Issue in hiring process using FM HR_PAD_HIRE_EMPLOYEE and HR_INFOTYPE_OPERATION

Former Member
0 Kudos
2,846

Hi All,

I am facing some issue using the FM HR_PAD_HIRE_EMPLOYEE and HR_INFOTYPE_OPERATION for hiring process.

My requirement is to hire an employee using the FM HR_PAD_HIRE_EMPLOYEE for infotypes 0000, 0001, 0006 and 0007.

Then once hired we have to individually create other infotypes for the hired emplyee - 0002, 0185, 0077, 0196, 0198, etc.

The hiring process using FM HR_PAD_HIRE_EMPLOYEE is working fine but after that i am not able to use the FM HR_INFOTYPE_OPERATION for generating other infotypes. The FM HR_INFOTYPE_OPERATION throws a short dump. Separately this FM working fine in separate programs for same hired employee.

Is there any configuration needed to be done.Would appreciate some sample code and guidance for using this issue. Its a very urgent requirement

with regards

Jayachandran Nair.

9 REPLIES 9

former_member201275
Active Contributor
0 Kudos
1,035

When you run HR_PAD_HIRE_EMPLOYEE in the first place you have to also include infotype 0002!

0 Kudos
1,035

Hi,

Did you checked in debugging whether you can see the pernr created in IT0000 before you call HR_INFOTYPE_OPERATIONS?

Former Member
0 Kudos
1,035

Hi,

My requirement is to create the infotype 0000, 0001 using HR_PAD_HIRE_EMPLOYEE.

And second process is to create other infotypes such as 0002, 0185, 0077, 0008, 0009, 0196, 0198,

0041, 0019, 0105 and 9000.

And the employee is getting created in PA0000 and PA0001 using HR_PAD_HIRE_EMPLOYEE. I checked this in debugiing mode. But after that when I use HR_INFOTYPE_OPERATION to create other infotypes, its giving a dump.

Here is the sample code I used:

DATA: GT_RETURN  TYPE HRPAD_RETURN_TAB,

       GT_BAPIKEY TYPE HRPAD_BAPIPAKEY_TAB,

       GS_BAPIKEY TYPE BAPIPAKEY.

DATA: GT_PRELP1   TYPE PRELP_TAB,

       GS_PRELP1   LIKE LINE OF GT_PRELP1,

       GT_PRELP2   TYPE PRELP_TAB,

       GS_PRELP2   LIKE LINE OF GT_PRELP2.

DATA: GT_P0001 TYPE TABLE OF P0001,

       GS_P0001 LIKE LINE  OF GT_P0001,

       GT_P0006 TYPE TABLE OF P0006,

       GS_P0006 LIKE LINE  OF GT_P0006,

       GT_P0007 TYPE TABLE OF P0007,

       GS_P0007 LIKE LINE  OF GT_P0007.

GS_P0001-PERNR = ''.

GS_P0001-BEGDA = '20150101'.

GS_P0001-ENDDA = '99991231'.

GS_P0001-INFTY = '0001'.

GS_P0001-WERKS = 'D4'.

GS_P0001-BTRTL = '42'.

GS_P0001-PERSG = 'A'.

GS_P0001-BUKRS = 'FGOM'.

GS_P0001-PERSK = '01'.

GS_P0001-GEBER = 'B10'.

GS_P0001-GSBER = '1107'.

GS_P0001-ZZWBS = ''.

GS_P0001-ZZPCT = '0039'.

GS_P0001-ABKRS = '06'.

APPEND GS_P0001 TO GT_P0001.

CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP_TAB

   EXPORTING

     PNNNN_TAB = GT_P0001

   IMPORTING

     PRELP_TAB = GT_PRELP1.

DATA: LV_PERNR TYPE PERNR_D,

       GV_OK    TYPE  BOOLE_D.

CALL FUNCTION 'HR_PAD_HIRE_EMPLOYEE'

   EXPORTING

     EMPLOYEENUMBER  = LV_PERNR

     HIRINGDATE      = '20150101'

     ACTIONTYPE      = '01'

     REASONFORACTION = '01'

     PNNNN_TAB       = GT_PRELP1

     NOCOMMIT        = ''

   IMPORTING

     RETURN_TAB      = GT_RETURN

     BAPIPAKEY_TAB   = GT_BAPIKEY

     IS_OK           = GV_OK.

IF GT_BAPIKEY IS NOT INITIAL.

   READ TABLE GT_BAPIKEY INTO GS_BAPIKEY INDEX 1.

   LV_PERNR = GS_BAPIKEY-EMPLOYEENO.

  

ENDIF.

*    lv_pernr = '00000192'.

     gs_p0006-pernr = lv_pernr.

     gs_p0006-begda = '20150101'.

     gs_p0006-endda = '99991231'.

     gs_p0006-infty = '0006'.

     gs_p0006-anssa = '1'.

     gs_p0006-ort01 = 'KUL'.

     gs_p0006-land1 = 'MY'.

     DATA: W_BAPIRETURN LIKE BAPIRETURN1.

     DATA: w_bapipakey LIKE bapipakey OCCURS 0 WITH HEADER LINE.

* Lock the pernr

     CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

       EXPORTING

         number = lv_pernr

       IMPORTING

         return = w_bapireturn.

     IF w_bapireturn IS INITIAL.

* Insert record to infotype 0002

       CALL FUNCTION 'HR_INFOTYPE_OPERATION'

         EXPORTING

           infty         = gs_p0006-infty

           number        = gs_p0006-pernr

           record        = gs_p0006

           validitybegin = gs_p0006-begda

           validityend   = gs_p0006-endda

           operation     = 'MOD'

           TCLAS         = 'A'

           nocommit      = 'X'

           DIALOG_MODE   = '0'

         IMPORTING

           return        = w_bapireturn

           key           = w_bapipakey.

       IF w_bapireturn IS INITIAL.

         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

       ENDIF.

     ENDIF.

     IF w_bapireturn-type NE 'E'.

*    WA_NOTIFY-NSTATUS = 'S'.

     ELSE.

*    WA_NOTIFY-NSTATUS = 'R'.

*    WA_NOTIFY-NREASON = W_BAPIRETURN-MESSAGE.

     ENDIF.

*  APPEND WA_NOTIFY TO TA_NOTIFY.

* Unlock the pernr

     CLEAR: w_bapireturn.

     CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

       EXPORTING

         number = lv_pernr

       IMPORTING

         return = w_bapireturn.


Kindly let me know if I am missing out something here.

0 Kudos
1,035

That is correct it will create an employee but you will not be able to add further infotypes unless you include infotype 0002 in the 'HR_PAD_HIRE_EMPLOYEE' function.

0 Kudos
1,035

Hi,

I think you are missing the mandatory parameters in IT0006.

I don't see the subty, zipcode, state, etc which are mandatory are not filled before calling HR_INFOTYPE_OPERATION.

If you are inserting, use INS and not MOD.

And you mentioned no_commit = 'X'.


Former Member
0 Kudos
1,035

Hi Glen,

I am able to create the all infotypes separately after employee hire using FM HR_PAD_HIRE_EMPLOYEE. During employee hire I didnt include 0002, only 0000 and 0001 was included.

My question is why cant I hire employee and create infotypes in same program. As if now I have to call another program to generate infotypes after employee hire.

Report ztest_jaya1.

lv_pernr = '00000000'.

GS_P0001-PERNR = '00000000'.

GS_P0001-BEGDA = '20140101'.

GS_P0001-ENDDA = '99991231'.

GS_P0001-INFTY = '0001'.

GS_P0001-WERKS = 'D4'.

GS_P0001-BTRTL = '42'.

GS_P0001-PERSG = 'A'.

GS_P0001-BUKRS = 'FGOM'.

GS_P0001-PERSK = '01'.

GS_P0001-GEBER = 'B10'.

GS_P0001-GSBER = '1107'.

GS_P0001-ZZWBS = ''.

GS_P0001-ZZPCT = '0039'.

GS_P0001-ABKRS = '06'.

APPEND GS_P0001 TO GT_P0001.

CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP_TAB

   EXPORTING

     PNNNN_TAB = GT_P0001

   IMPORTING

     PRELP_TAB = GT_PRELP1.

CALL FUNCTION 'HR_PAD_HIRE_EMPLOYEE'

   EXPORTING

     EMPLOYEENUMBER  = LV_PERNR

     HIRINGDATE      = '20140101'

     ACTIONTYPE      = '01'

     REASONFORACTION = '01'

     PNNNN_TAB       = GT_PRELP1

     NOCOMMIT        = ''

   IMPORTING

     RETURN_TAB      = GT_RETURN

     BAPIPAKEY_TAB   = GT_BAPIKEY

     IS_OK           = GV_OK.

IF GT_BAPIKEY IS NOT INITIAL.

   READ TABLE GT_BAPIKEY INTO GS_BAPIKEY INDEX 1.

   LV_PERNR = GS_BAPIKEY-EMPLOYEENO.

   EXPORT pernr FROM lv_pernr TO MEMORY ID 'LV_PERNR'.

   SUBMIT ztest_jaya AND RETURN.

ENDIF.


Report ztest_jaya.

DATA: gt_p0006 TYPE STANDARD TABLE OF p0006,

       gs_p0006 LIKE LINE OF gt_p0006.

DATA: lv_pernr TYPE pernr-pernr.

IMPORT pernr TO lv_pernr FROM MEMORY ID 'LV_PERNR'.

     gs_p0006-pernr = lv_pernr.

     gs_p0006-begda = '20150101'.

     gs_p0006-endda = '99991231'.

     gs_p0006-infty = '0006'.

     gs_p0006-anssa = '1'.

     gs_p0006-ort01 = 'KUL'.

     gs_p0006-land1 = 'MY'.

     DATA: w_bapireturn LIKE bapireturn1.

     DATA: w_bapipakey LIKE bapipakey OCCURS 0 WITH HEADER LINE.

* Lock the pernr

     CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

       EXPORTING

         number = lv_pernr

       IMPORTING

         return = w_bapireturn.

     IF w_bapireturn IS INITIAL.

       CALL FUNCTION 'HR_INFOTYPE_OPERATION'

         EXPORTING

           infty         = gs_p0006-infty

           number        = gs_p0006-pernr

           record        = gs_p0006

           validitybegin = gs_p0006-begda

           validityend   = gs_p0006-endda

           operation     = 'INS'

           nocommit      = ''

         IMPORTING

           return        = w_bapireturn

           key           = w_bapipakey.

       IF w_bapireturn IS INITIAL.

        

       ENDIF.

     ENDIF.

* Unlock the pernr

     CLEAR: w_bapireturn.

     CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

       EXPORTING

         number = lv_pernr

       IMPORTING

         return = w_bapireturn.


In ztest_jaya program i am able to create all the infotypes using HR_INFOTYPE_OPERATION. But the same is not working when i try to create the infotypes in same program after employee hire.

Thanks Regards

0 Kudos
1,035

Hi,

Incase, if it is waiting for commit work, can you try once by passing commit work and wait.

Another way is check via HR_READ_INFOTYPE for IT0001, whether record exists.

If not, then do commit work and wait for 10 seconds. DO the loop till it finds the records and then proceed further with HR_INFOTYPE_OPERATION.

Former Member
0 Kudos
1,035

Hi,

I have already tried bapi_transaction_commit and wait statement. It doesn't make any difference.

The issue still persists. I got some information from some other source that there might be a issue with the buffers thats being used common to both FM.

I am trying to figure out the issue with this buffers.

Thanks and regards

PatrickXYZ
Discoverer
0 Kudos
1,035

Hi,

you can directly add other inftoype data (such as, IT0002, IT0006, IT0008 (with IT0105) to the prelp_structure and pass it to the function module HR_PAD_HIRE_EMPLOYEE.

No need to do another call of HR_INFOTYPE_OPERATION.


Best regards

Patrick