Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Read infotype records

* Read multiple infotype records
DATA: ls_p0001 TYPE p0001,
      lt_p0001 TYPE TABLE OF p0001.

* Initialise Infotyp reader 
cl_hrpa_read_infotype=>get_instance( IMPORTING infotype_reader = DATA(lr_infotype_reader) ).

* Read Infotyp 1
lr_infotype_reader->read( EXPORTING tclas         = 'A'
                                    pernr         = 1
                                    infty         = '0001'
                                    begda         = if_hrpa_read_infotype=>low_date
                                    endda         = if_hrpa_read_infotype=>high_date
                                    no_auth_check = abap_true
                          IMPORTING infotype_tab  = DATA(lt_infotype)
                                    data_exists   = DATA(lv_data_exists) ).

LOOP AT lt_infotype INTO DATA(ls_infotype).
  cl_hr_pnnnn_type_cast=>prelp_to_pnnnn( EXPORTING prelp = ls_infotype
                                         IMPORTING pnnnn = ls_p0001 ).
  APPEND ls_p0001 TO lt_p0001.
ENDLOOP.

cl_demo_output=>display( lt_p0001 ).
* Read single infotype record
DATA: ls_p0001 TYPE p0001.

* Initialise Infotyp reader
  cl_hrpa_read_infotype=>get_instance( IMPORTING infotype_reader = DATA(lr_infotype_reader) ).

* Read Infotyp 1
  lr_infotype_reader->read_single( EXPORTING tclas         = 'A'
                                             pernr         = 1
                                             infty         = '0001'
                                             subty         = space
                                             objps         = space
                                             sprps         = if_hrpa_read_infotype=>unlocked
                                             begda         = '20200101'
                                             endda         = '20200131'
                                             mode          = if_hrpa_read_infotype=>first_record_containing_begda
                                             no_auth_check = abap_true
                                   IMPORTING pnnnn         = ls_p0001 ).

cl_demo_output=>display( ls_p0001 ).