Wednesday, May 24, 2023

OOPS ABAP HR Decouple Framework

 How to Read Infotype (in oops)

DATA: lo_infotype TYPE REF TO cl_hrpa_read_infotype,

       li_infotype TYPE REF TO if_hrpa_read_infotype,

       lt_pri_infty TYPE pnnnn, "primary infotype

       lt_sec_infty TYPE pnnnn, "secoundary infotype

       lv_has_data TYPE boole_d,

       lv_has_auth TYPE boole_d.

 

// Initialization of the object

 TRY.

 CALL METHOD cl_hrpa_read_infotype=>get_instance

 *  EXPORTING

 *    masterdata_buffer =

   IMPORTING

     infotype_reader   = li_infotype.

  CATCH cx_hrpa_violated_assertion.

 ENDTRY.

 // Read method to get infotype data - METHOD: READ_SINGLE

 TRY.

 CALL METHOD li_infotype->read_single

   EXPORTING

     tclas         = 'A' "employee

     pernr         = '00012345'

     infty         = '0001'

     subty         = space

     objps         = space

     sprps         = ''

     begda         = '19000101'

     endda         = sy-datum

     mode          = '3'

     no_auth_check = space

   IMPORTING

     pnnnn         = lt_pri_infty

     pnnnn2        = lt_sec_infty

 *    pref          =

     data_exists   = lv_has_data

     missing_auth  = lv_has_auth.

  CATCH cx_hrpa_violated_assertion .

 ENDTRY.

 // Read method to get infotype data - METHOD: READ

 // Manipulate Data as needed

   CLEAR lt_infotype.

   CALL METHOD lr_infotype_reader->read

     EXPORTING

       tclas         = 'A'

       pernr         = lv_pernr

       infty         =  '0001'

       begda         = iv_begda

       endda         = iv_endda

       no_auth_check = abap_true

     IMPORTING

       infotype_tab  = lt_infotype

       data_exists   = lv_data_exists

       missing_auth  = lv_missing_auth.

 // Manipulate data

   LOOP AT lt_infotype INTO ls_infotype.

     CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn

       EXPORTING

         prelp = ls_infotype

       IMPORTING

         pnnnn = ls_p0001.

        APPEND ls_p0001 TO lt_p0001.

   ENDLOOP. 

Wednesday, May 10, 2023

OOPS ABAP HR: Pay Result (US)

Get Data from Payroll (US Payroll)

Step 1: Data declaration 

data: ls_rgdir type pc261

(lo_payresult_access) = NEW cl_hr_pay_access( ),

lo_emp_pay_result type ref to cl_hr_pay_result,

lo_emp_pay_result_us type ref to cl_hr_pay_result_us.


Step 2. Get data from table HRPY_RGDIR

Get the records from table HRPY_RGDIR and store the data in an internal table lt_rgdir[]

with needful where clause(s).


Step 3: Use class CL_HR_PAY_ACCESS and CL_HR_PAY_RESULT

LOOP the internal table lt_regdir[] to assigned fields symbol <fs_rgdir>

ls_rgdir = <fs_rgdir>.

call method lo_payresult_access->read_pay_result (by paasing ls_rgdir)

Get the result in object lo_emp_pay_result.

Use the object lo_emp_pay_result for RT/TCRT/CRT table to read or loop.


RT Result will be found (for all countries):

lo_emp_pay_result->inter-rt[].

Wide cast to US data (as needed only for MOLGA US

lo_emp_pay_result_us ?= lo_emp_pay_result.


US Garnishment result will be found in:

lo_emp_pay_result_us->natio-grdoc[] and lo_emp_pay_result->natio-grrec[]

ENDLOOP.