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_INFOTYPE_OPERATION

Former Member
0 Kudos

Hi Experts

I need to enter values of overtime and paid time offs into info types 2001 and 2002

please give me some example how to enter for particular pernr during particular week using <b>HR_INFOTYPE_OPERATION</b>

i tried some ways but it is giving error

Thanks

1 REPLY 1

Former Member
0 Kudos

Check out this sample code


REPORT ZZKNB_BAPI_INFOTYPE_CALL .

* Use 'BAPI_EMPLOYEE_ENQUEUE' to lock the employee before updating
DATA: l_bapireturn LIKE bapireturn1.

DATA: bapipakey_tab LIKE bapipakey OCCURS 0 WITH HEADER LINE.

data: l_p0169 like p0169.

parameters: p_pernr like p0169-pernr default '07000003'.

start-of-selection.

  CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
       EXPORTING
            number = p_pernr
       IMPORTING
            return = l_bapireturn.

  IF l_bapireturn-id NE space.
    WRITE: / l_p0169-pernr, 'Enqueue failed'.
    exit.
  ENDIF.

*-- Suported operations:
*-- change          (operation = 'MOD')
*-- Create          (operation = 'INS')
*-- DELETE          (operation = 'DEL')
*-- CREATESUCCESSOR (operation = 'COP')
  .
  l_p0169-barea = '7A'.
  l_p0169-pltyp = 'RRSP'.
  l_p0169-bplan = 'RRSP'.
  l_p0169-elidt = '20000101'.
  l_p0169-enrty = 'M'.
  l_p0169-perio = '4'.

  CALL FUNCTION 'HR_INFOTYPE_OPERATION'
       EXPORTING
            infty         = '0169'
            subty         = 'RRSP'
            number        = p_pernr
            record        = l_p0169
            validitybegin = '20021001'
            validityend   = '99991231'
            operation     = 'INS'
*           dialog_mode   = '0'  "Use default
*           nocommit      = '1'  "Use default
       IMPORTING
            return        = l_bapireturn
            key           = bapipakey_tab.

  IF l_bapireturn-id NE space.
    WRITE: /   p_pernr,
            20 'Create was unsuccessful',
                l_bapireturn-id,
                l_bapireturn-message+0(40).
  ELSE.
    WRITE: /   p_pernr,
            20 'Create was successful',
                l_bapireturn-id,
                l_bapireturn-message+0(40).
  ENDIF.


* Use 'BAPI_EMPLOYEE_DEQUEUE' to un-lock the employee before updating
  CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
       EXPORTING
            number = l_p0169-pernr
       IMPORTING
            return = l_bapireturn.

HR_PAYROLL_PERIODS_GET	Get the payroll period for a particular date. (provided by Francois Henrotte)

Example:

  DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
        IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE.

  W_BEGDA = '20010101'.
  W_PERNR = '00000001'.

  CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
       EXPORTING
            get_begda       = w_begda
       TABLES
            get_periods     = it_t549q
       EXCEPTIONS
            no_period_found = 1
            no_valid_permo  = 2.
  CHECK sy-subrc = 0.

  CALL FUNCTION 'HR_TIME_RESULTS_GET'
       EXPORTING
            get_pernr             = w_pernr
            get_pabrj             = it_t549q-pabrj
            get_pabrp             = it_t549q-pabrp
       TABLES
            get_zl                = it_zl
       EXCEPTIONS
            no_period_specified   = 1
            wrong_cluster_version = 2
            no_read_authority     = 3
            cluster_archived      = 4
            technical_error       = 5.

NOTE: it_zl-iftyp = 'A'   absence
      it_zl-iftyp = 'S'   at work
		

New ItemHR_READ_INFOTYPE	generic PA infotype read with authorization checks
HR_TIME_RESULTS_GET	Get the time results for a payroll period. (provided by Francois Henrotte)

Example:

  DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
        IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE.

  W_BEGDA = '20010101'.
  W_PERNR = '00000001'.

  CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
       EXPORTING
            get_begda       = w_begda
       TABLES
            get_periods     = it_t549q
       EXCEPTIONS
            no_period_found = 1
            no_valid_permo  = 2.
  CHECK sy-subrc = 0.

  CALL FUNCTION 'HR_TIME_RESULTS_GET'
       EXPORTING
            get_pernr             = w_pernr
            get_pabrj             = it_t549q-pabrj
            get_pabrp             = it_t549q-pabrp
       TABLES
            get_zl                = it_zl
       EXCEPTIONS
            no_period_specified   = 1
            wrong_cluster_version = 2
            no_read_authority     = 3
            cluster_archived      = 4
            technical_error       = 5.

NOTE: it_zl-iftyp = 'A'   absence
      it_zl-iftyp = 'S'   at work