[SAP ABAP] - HR Funtion Module for Get Asignment History

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_ASSIGN 
 

Field Data Element Data Type  Length Decimal Label Name
PERNR PERNR_D NUMC 8 0 Personnel Number
CNAME CNAME CHAR 25 0 Address Supplement (c/o)
BEGDA BEGDA DATS 8 0 Start Date
ENDDA ENDDA DATS 8 0 End Date
MASSN MASSN CHAR 2 0 Action Type
MNTXT MNTXT CHAR 30 0 Name of action type
MASSG MASSG CHAR 2 0 Reason for Action
MGTXT MGTXT CHAR 30 0 Name of reason for action
PLANS PLANS NUMC 8 0 Position
PLSTX SHORT_D CHAR 12 0 Object Abbreviation
WERKS PERSA CHAR 4 0 Personnel Area
PBTXT PBTXT CHAR 30 0 Personnel Area Text
BTRTL BTRTL CHAR 4 0 Personnel Subarea
BTRTX BTRTX CHAR 15 0 Personnel Subarea Text
ABKRS ABKRS CHAR 2 0 Payroll Area
ABKTX ABKTX CHAR 20 0 Payroll Area Text
SCHKZ SCHKN CHAR 8 0 Work Schedule Rule
ZTERF PT_ZTERF NUMC 1 0 Employee Time Management Status
ZTEXT DZETXT CHAR 50 0 Text for time recording status (IT Planned Working Time)


 FUNCTION zsapifm_assign.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(E_HISTORY) TYPE  CHAR1
*"     REFERENCE(E_OVERSEAS) TYPE  CHAR1
*"     REFERENCE(E_SECONDMENT) TYPE  CHAR1
*"  TABLES
*"      FT_PERNR STRUCTURE  ZSAPIST_SOPERNR
*"      FT_ASSIGN STRUCTURE  ZSAPIST_ASSIGN
*"----------------------------------------------------------------------


  DATA : lt_i0007 LIKE p0007 OCCURS 0 WITH HEADER LINE,
         lt_i0001 LIKE p0001 OCCURS 0 WITH HEADER LINE,
         lt_t555v LIKE t555v OCCURS 0 WITH HEADER LINE.

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

  RANGES : lr_massn FOR pa0000-massn.

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

  IF e_overseas EQ 'X'.

    lr_massn-sign = 'I'.
    lr_massn-option = 'EQ'.
    lr_massn-low = 'Z1'.
    APPEND lr_massn.

    lr_massn-sign = 'I'.
    lr_massn-option = 'EQ'.
    lr_massn-low = '2'.
    APPEND lr_massn.

  ENDIF.

  IF e_secondment EQ 'X'.

    lr_massn-sign = 'I'.
    lr_massn-option = 'EQ'.
    lr_massn-low = 'Z3'.
    APPEND lr_massn.

    lr_massn-sign = 'I'.
    lr_massn-option = 'EQ'.
    lr_massn-low = 'Z4'.
    APPEND lr_massn.

  ENDIF.

  SELECT * FROM t555v INTO TABLE lt_t555v
           WHERE sprsl = sy-langu.

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

  IF ft_assign[] IS NOT INITIAL.

    LOOP AT ft_assign.
      REFRESH : lt_i0001, lt_i0007.
      CLEAR : lt_i0001, lt_i0007.

*Org Assignment
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          tclas           = 'A'
          pernr           = ft_assign-pernr
          infty           = '0001'
          begda           = ft_assign-begda
          endda           = ft_assign-endda
        TABLES
          infty_tab       = lt_i0001
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.

      READ TABLE lt_i0001 INDEX 1.

      CALL FUNCTION 'ZSAPIFM_GET_TEXT'
        EXPORTING
          e_werks       = lt_i0001-werks
          e_btrtl       = lt_i0001-btrtl
          e_abkrs       = lt_i0001-abkrs
          e_plans       = lt_i0001-plans
*          e_persg       = ft_om-persg
*          e_persk       = ft_om-persk
          e_begda       = lt_i0001-begda
          e_endda       = lt_i0001-endda
       IMPORTING
         i_pbtxt       = ft_assign-pbtxt
         i_btrtx       = ft_assign-btrtx
         i_abktx       = ft_assign-abktx
         i_plstx       = ft_assign-plstx.
*         i_pgtxt       = ft_om-pgtxt
*         i_pktxt       = ft_om-pktxt.

*Get WS & Time Management
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          tclas           = 'A'
          pernr           = ft_assign-pernr
          infty           = '0007'
          begda           = ft_assign-begda
          endda           = ft_assign-endda
        TABLES
          infty_tab       = lt_i0007
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
*Work schedule
      READ TABLE lt_i0007 INDEX 1.
      ft_assign-schkz = lt_i0007-schkz.
      ft_assign-zterf = lt_i0007-zterf.
*TM Status
      READ TABLE lt_t555v WITH KEY zterf = ft_assign-zterf.
      IF sy-subrc = 0.
        ft_assign-ztext = lt_t555v-ztext.
      ENDIF.

      MODIFY ft_assign.
      CLEAR ft_assign.

    ENDLOOP.

  ENDIF.

ENDFUNCTION.






Comments