Skip to end of metadata
Go to start of metadata

DATAg_return TYPE bapireturn1,
          it_p0003  TYPE p0003,
          g_subrc   TYPE sy-subrc.
DATAl_infty       TYPE prelp-infty VALUE '0003',
          l_infty_tab TYPE TABLE OF pa0003.

PARAMETERp_pernr TYPE pa0003-pernr,
                    p_mode TYPE char1.

START-OF-SELECTION.

  it_p0003-infty '0003'.

  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr     p_pernr
      infty     l_infty
    TABLES
      infty_tab l_infty_tab.

  READ TABLE l_infty_tab INDEX INTO DATA(wa_infty).

  it_p0003            wa_infty.
  it_p0003-abwd1 sy-datum.

  PERFORM hr_infotype_operation USING it_p0003 p_mode
                                             CHANGING g_return g_subrc.
  IF g_subrc 0.
    WRITE:'The infotype was updated successfully!'.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  HR_INFOTYPE_OPERATION
*&---------------------------------------------------------------------*
*       Infoype update module
*----------------------------------------------------------------------*
FORM hr_infotype_operation  USING p_p0003 TYPE p0003
                                                        p_p_mode
                                      CHANGING p_p_return
                                                        p_p_subrc.

  DATAl_key TYPE bapipakey.

  CASE p_p_mode.
    WHEN '1'.
      DATA(l_operation'INS'.
    WHEN '2'.
      l_operation 'DEL'.
    WHEN '3'.
      l_operation 'MOD'.
    WHEN OTHERS.
  ENDCASE.

*--Performing Infotype Operations Using FM
  CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
    EXPORTING
      number p_p0003-pernr.

  CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
      infty             p_p0003-infty
      number        p_p0003-pernr
      subtype        p_p0003-subty
      validityend    p_p0003-endda
      validitybegin p_p0003-begda
      record          p_p0003
      operation     l_operation
      tclas             'A'
      dialog_mode '1'
    IMPORTING
      return           p_p_return
      key               l_key.

  p_p_subrc sy-subrc.

  CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
    EXPORTING
      number p_p0003-pernr.

ENDFORM.                    " HR_INFOTYPE_OPERATION