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

[ABAP] Modify Infotype

METHOD operate_it.

    DATA ls_return TYPE bapireturn1.
    DATA key       TYPE bapipakey.

    CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
      EXPORTING
        number = is_2002-pernr
      IMPORTING
        return = ls_return.
    IF ls_return IS NOT INITIAL.
      RAISE EXCEPTION TYPE zcx_xxx MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number.
    ENDIF.

    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
      EXPORTING
        infty         = '2002'
        number        = is_2002-pernr
        subtype       = is_2002-subty
        objectid      = is_2002-objps
        lockindicator = is_2002-sprps
        validityend   = is_2002-endda
        validitybegin = is_2002-begda
        recordnumber  = is_2002-seqnr
        record        = is_2002_chg
        operation     = iv_actio          "MOD,INS,DEL
        tclas         = 'A'
        dialog_mode   = '0'
      IMPORTING
        return        = ls_return
        key           = key.
    IF ls_return IS NOT INITIAL.
      RAISE EXCEPTION TYPE zcx_xxx MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number.
    ENDIF.

    CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
      EXPORTING
        number = is_2002-pernr.

ENDMETHOD.

[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         = 6
                                    infty         = '0001'
                                    begda         = '01011900'
                                    endda         = '31129999'
                                    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 ).