[SAP ABAP] - HR Funtion Module for Get Absence

SE11 -> Structure


  • ZSAPIST_SOPERNR


Field Data Element Data Type  Length Decimal Label Name
SIGN CHAR1 CHAR 1 0 Single-Character Indicator
OPTION CHAR2 CHAR 2 0 Version Number Component
LOW PERNR_D NUMC 8 0 Personnel Number
HIGH PERNR_D NUMC 8 0 Personnel Number


  • ZSAPIST_ABSENCE


Field Data Element Data Type  Length Decimal Label Name
PERNR PERNR_D NUMC 8 0 Personnel Number
BEGDA BEGDA DATS 8 0 Start Date
ENDDA ENDDA DATS 8 0 End Date
SUBTY SUBTY CHAR 4 0 Subtype
ATEXT ABWTXT CHAR 25 0 Text for Attendance/Absence Type
STDAZ STDAZ DEC 5 2 Break after hours
ABWTG ABWTG DEC 6 2 Attendance and Absence Days
KALTG KALTG DEC 6 2 Calendar days
ANZHL KOANZ DEC 7 2 Quota deduction
ETEXT EINHTXT CHAR 20 0 Time/Measurement Unit Text


FUNCTION zsapifm_absence.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(E_HISTORY) TYPE  CHAR1 OPTIONAL
*"  TABLES
*"      FT_PERNR STRUCTURE  ZSAPIST_SOPERNR OPTIONAL
*"      FT_ABSENCE STRUCTURE  ZSAPIST_ABSENCE OPTIONAL
*"  EXCEPTIONS
*"      NO_FOUND
*"----------------------------------------------------------------------

  DATA: t_t554t LIKE STANDARD TABLE OF t554t WITH HEADER LINE,
        t_t538t LIKE STANDARD TABLE OF t538t WITH HEADER LINE.

  DATA : ld_begda LIKE pa0001-begda,
         ld_endda LIKE pa0001-endda.

  ld_begda = '18000101'.
  ld_endda = '99991231'.

  SELECT * FROM t554t INTO TABLE t_t554t
           WHERE sprsl = sy-langu.

  SELECT * FROM t538t INTO TABLE t_t538t
           WHERE sprsl = sy-langu.

  IF e_history EQ 'X'.
    SELECT * FROM pa2001
    INTO CORRESPONDING FIELDS OF TABLE ft_absence
      WHERE pernr IN ft_pernr AND
            begda GE ld_begda AND
            endda LE ld_endda.
  ELSE.
    SELECT * FROM pa2001
    INTO CORRESPONDING FIELDS OF TABLE ft_absence
      WHERE pernr IN ft_pernr AND
            endda EQ ld_endda.
  ENDIF.

  IF ft_absence[] IS NOT INITIAL.

    LOOP AT ft_absence.

      READ TABLE t_t554t WITH KEY moabw = ft_absence-moabw
                                  awart = ft_absence-awart.
      IF sy-subrc = 0.
        ft_absence-atext = t_t554t-atext.
      ENDIF.

      READ TABLE t_t538t WITH KEY zeinh = ft_absence-zeinh.
      IF sy-subrc = 0.
        ft_absence-etext = t_t538t-etext.
      ENDIF.

      MODIFY ft_absence.CLEAR ft_absence.

    ENDLOOP.

  ENDIF.


ENDFUNCTION.


Comments