ABAP: Code example to read infotype 0041

Here is a code example to ready infotype 0041 information, but it can be used to any pattern of grouped fields.

    types:
       begin of lty_dt_type,
        dar01 type datar,
        dat01 type dardt,
        dar02 type datar,
        dat02 type dardt,
        dar03 type datar,
        dat03 type dardt,
        dar04 type datar,
        dat04 type dardt,
        dar05 type datar,
        dat05 type dardt,
        dar06 type datar,
        dat06 type dardt,
        dar07 type datar,
        dat07 type dardt,
        dar08 type datar,
        dat08 type dardt,
        dar09 type datar,
        dat09 type dardt,
        dar10 type datar,
        dat10 type dardt,
        dar11 type datar,
        dat11 type dardt,
        dar12 type datar,
        dat12 type dardt,
       end of lty_dt_type,

       begin of lty_dan,
         dar type datar,
         dat type dardt,
       end of lty_dan.

    field-symbols:
           <lfs_dan>       type any,
           <lfs_dan_typed> type lty_dan.

    data: go_infty        type ref to if_hrsen_read_infotype
          lw_dt_type      type lty_dt_type,
          l_inc           type i,
          lw_p0041        type p0041.

    go_infty = cl_hrsen_read_infotype_fmri=>get_instance( ).
 
          CALL METHOD go_infty->read_single
            EXPORTING
*             tclas         = 'A'
              pernr         = <fs_nonexcluded_list>-pernr
              infty         = '0041'
              subty         = space
              objps         = space
              begda         = att_run_date
              endda         = att_run_date
*             no_auth_check = SPACE
            IMPORTING
              pnnnn         = lw_p0041
*             data_exists   =
*             missing_auth  =
            EXCEPTIONS
              e_assertion   = 1
              OTHERS        = 2.
 
          IF sy-subrc <> 0.
*           Implement suitable error handling here
            MESSAGE e016(pn)
              WITH 'Error executing class cl_hrsen_read_infotype_fmri'(083).
          ENDIF.
 
          MOVE-CORRESPONDING lw_p0041 TO lw_dt_type.
 
          ASSIGN lw_dt_type(10) TO <lfs_dan> RANGE lw_dt_type.
 
          WHILE sy-subrc = 0.
            l_inc = sy-index  - 1.
            ASSIGN <lfs_dan> INCREMENT l_inc TO <lfs_dan_typed> CASTING.
            IF <lfs_dan_typed> IS INITIAL.
              EXIT.
            ENDIF.
 
            IF <lfs_dan_typed>-dar = 'XX'.
              lv_start_of_leave = <lfs_dan_typed>-dat.
            ENDIF.
 
            IF <lfs_dan_typed>-dar = 'YY'.
              lv_end_of_leave = <lfs_dan_typed>-dat.
            ENDIF.
          ENDWHILE.
 
          IF lv_start_of_leave IS NOT INITIAL
            AND lv_start_of_leave <= lv_year_begin
 
            AND lv_end_of_leave IS NOT INITIAL
            AND lv_end_of_leave > lv_year_end.
 
            CONTINUE.
          ENDIF.

Leave a Reply