Quantcast
Channel: SCN: Message List - ABAP Development
Viewing all articles
Browse latest Browse all 10425

Re: Issue in hiring process using FM HR_PAD_HIRE_EMPLOYEE and HR_INFOTYPE_OPERATION

$
0
0

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.


Viewing all articles
Browse latest Browse all 10425

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>