Tuesday, April 29, 2025

DeCouple Framework - ABP HR - Terminating Employee

 Terminating an employee is considering IT0 and IT 1
Hence inserting an entry in both infotype (while IT 0 will have inactive status and Temination Action type and Reason), works

DATA li_iread TYPE REF TO if_hrpa_plain_infotype_access.

cl_hrpa_masterdata_factory=>get_plain_infotype_access(

  IMPORTING plain_infotype_access = li_iread     ).

" * Message handler

DATA lo_mhand TYPE REF TO if_hrpa_message_handler.

DATA lo_mlist TYPE REF TO cl_hrpa_message_list.

FREE lo_mlist.


CREATE OBJECT lo_mlist.

lo_mhand = lo_mlist.


DATA: ls_p0000 TYPE p0000, s_p0001 TYPE p0001.

li_iread->read_single(

  EXPORTING tclas           = cl_hrpa_tclas=>tclas_employee

            pernr           = '00050002'

            infty           = '0000'

            subty           = ''

            objps           = '*' "lc_objps_all

            sprps           = if_hrpa_read_infotype=>unlocked

            begda           = '19000101'

            endda           = '99991231'

            mode            = if_hrpa_read_infotype=>last_intersecting_record

            no_auth_check   = if_hrpa_boole_d=>true

            message_handler = lo_mhand

  IMPORTING pnnnn           = ls_p0000  ).


ls_p0000-begda = sy-datum.

ls_p0000-massn = '06'.

ls_p0000-massg = '06'.

ls_p0000-stat2 = '0'.

li_iread->insert( EXPORTING tclas = cl_hrpa_tclas=>tclas_employee

                            no_auth_check   = if_hrpa_boole_d=>true

                            message_handler = lo_mhand

                  CHANGING  pnnnn           = ls_p0000    ).

li_iread->read_single(

  EXPORTING tclas           = cl_hrpa_tclas=>tclas_employee

            pernr           = '00050002'

            infty           = '0001'

            subty           = ''

            objps           = '*' "lc_objps_all

            sprps           = if_hrpa_read_infotype=>unlocked

            begda           = '19000101'

            endda           = '99991231'

            mode            = if_hrpa_read_infotype=>last_intersecting_record

            no_auth_check   = if_hrpa_boole_d=>true

            message_handler = lo_mhand

  IMPORTING pnnnn           = ls_p0001  ).

ls_p0001-begda = sy-datum.

li_iread->insert( EXPORTING tclas = cl_hrpa_tclas=>tclas_employee

                            no_auth_check   = if_hrpa_boole_d=>true

                            message_handler = lo_mhand

                  CHANGING  pnnnn           = ls_p0001    ).

li_iread->if_hrpa_buffer_control~flush( no_commit = abap_false ).

DATA lt_mlist TYPE hrpad_message_tab.

lo_mlist->get_message_list(

  IMPORTING messages = lt_mlist ).

0 comments: