SAP HCM ABAP CLUSTER
From SapWiki
Contents
Lectura de datos de Préstamo
*----------------------------------------------------------------------* * FORM ....... *----------------------------------------------------------------------* * copiado de include MP004541 *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form get_loan_results tables pt_savp structure gt_savp using pf_pernr pf_dlart pf_objps pf_dbtcu changing pfx_opelo pfx_paylo pfx_abrdt p_cuota pfx_subrc. data: ltx_rgdir like pc261 occurs 0 with header line, ltx_rgdir_o like pc261 occurs 0 with header line, lsx_rgdir like ltx_rgdir, lsx_result type pay99_result, lsx_v0 like line of lsx_result-inter-v0, lsx_rt like line of lsx_result-inter-rt, lfx_relid like pcl2-relid, lfx_molga like t500l-molga, lsx_t500l like t500l, lfx_amount like q0045-darbt, lfx_line like sy-tabix, lfx_fday type d, lfx_lday type d, lfx_opecu like q0045-opecu, ls_paper type pc2paper, lf_payment_value_date type datum, ls_loid_33 type pclo_id. "Note 834827 data wa_prest_ipc type zhr_prest_ipc. *##--BEGIN--## clear: pfx_opelo, pfx_paylo, pfx_abrdt, pfx_subrc. call function 'CU_READ_RGDIR_NEW' exporting persnr = pf_pernr check_read_authority = space importing molga = lfx_molga tables in_rgdir = ltx_rgdir exceptions others = 1. if sy-subrc <> 0. move sy-subrc to pfx_subrc. return. endif. move sy-subrc to pfx_subrc. * Limitar directorio de cluster al período seleccionado call function 'CD_SELECT_DATE_RANGE' exporting fpper_begda = g_begda fpper_endda = g_endda tables in_rgdir = ltx_rgdir out_rgdir = ltx_rgdir_o. "take only regular and actual periods loop at ltx_rgdir_o transporting no fields where void = abap_true or payty <> space or srtza <> 'A'. delete ltx_rgdir_o index sy-tabix. endloop. ltx_rgdir[] = ltx_rgdir_o[]. sort ltx_rgdir descending by seqnr. data(l_lines) = lines( ltx_rgdir ). if l_lines = 0. pfx_subrc = 9. return. endif. * get relid select single * from t500l into lsx_t500l where molga = lfx_molga. move lsx_t500l-relid to lfx_relid. data(lflag_loan_exists) = abap_false. data lv_subrc type sy-subrc. loop at ltx_rgdir into lsx_rgdir where fpend >= p0045-begda. "for performance if lflag_loan_exists = abap_true. exit. "stop loop at rgdir, because period was found endif. call function 'PYXX_READ_PAYROLL_RESULT' exporting clusterid = lfx_relid employeenumber = pf_pernr sequencenumber = lsx_rgdir-seqnr read_only_international = 'X' check_read_authority = ' ' changing payroll_result = lsx_result exceptions others = 1. if sy-subrc <> 0. move sy-subrc to pfx_subrc. else. move sy-subrc to pfx_subrc. * get loan result ..... loop at lsx_result-inter-v0 into lsx_v0 where v0typ = 'L'. if pf_dlart = lsx_v0-vinfo+0(4) and pf_objps = lsx_v0-vinfo+4(2). lflag_loan_exists = abap_true. pfx_abrdt = lsx_rgdir-fpend. lv_subrc = 1. loop at lsx_result-inter-rt into lsx_rt where v0typ = 'L' and v0znr = lsx_v0-v0znr and lgart = '/LLB'. if lsx_rt-betrg = 0. "this is a potential period "here the loan is already paid back completely lv_subrc = 1. "this is equal to that no /LLB exists exit. "the loop and check previous period else. * verificar si ya se actualizo por IPC select single * into wa_prest_ipc from zhr_prest_ipc where pernr = pf_pernr and seqnr = lsx_rgdir-seqnr. if sy-subrc <> 0. move: lsx_result-inter-versc-waers to lfx_opecu, lsx_rt-betrg to pfx_opelo. lv_subrc = 0. else. lv_subrc = 1. pfx_opelo = 0. exit. endif. endif. endloop. if lv_subrc = 0. loop at lsx_result-inter-rt into lsx_rt where v0typ = 'L' and v0znr = lsx_v0-v0znr and lgart = '/LRP'. if lsx_rt-betrg = 0. "this is a potential period "here the loan is already paid back completely lv_subrc = 1. "this is equal to that no /LLB exists exit. "the loop and check previous period else. move lsx_rt-betrg to p_cuota. endif. endloop. endif. else. "this loan is not yet processed in payroll move '7' to pfx_subrc. endif. endloop. endif. endloop. endform. " GET_LOAN_RESULTS
Modificar Cluster
- Ejemplo de lectura de cluster con modificacion a tabla BT
CLEAR rgdir. REFRESH rgdir. CALL FUNCTION 'CU_READ_RGDIR_NEW' EXPORTING persnr = i_pernr TABLES in_rgdir = rgdir EXCEPTIONS no_record_found = 1 import_mismatch_error = 2 no_read_authority = 3 OTHERS = 4. check sy-subrc = 0. DELETE rgdir WHERE fpper NE i_fpper. DESCRIBE TABLE rgdir LINES sy-tfill. check sy-tfill > 0. LOOP AT rgdir. ld_pernr = i_pernr. ld_seqnr = rgdir-seqnr. CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING clusterid = 'CL' employeenumber = ld_pernr sequencenumber = ld_seqnr read_only_buffer = ' ' CHANGING payroll_result = ls_result EXCEPTIONS illegal_isocode_or_clusterid = 1 error_generating_import = 2 import_mismatch_error = 3 subpool_dir_full = 4 no_read_authority = 5 no_record_found = 6 versions_do_not_match = 7 OTHERS = 8. * procesar bt loop at ls_result-inter-bt into gs_bt. add i_monto to gs_bt-betrg. modify ls_result-inter-bt from gs_bt. ENDLOOP. check sy-subrc = 0. CALL FUNCTION 'PYXX_WRITE_PAYROLL_RESULT' EXPORTING clusterid = 'CL' employeenumber = ld_pernr sequencenumber = ld_seqnr payroll_result = ls_result EXCEPTIONS illegal_isocode_or_clusterid = 1 error_generating_export = 2 export_error = 3 subpool_dir_full = 4 no_update_authority = 5 incomplete_result_imported = 6 OTHERS = 7. IF sy-subrc <> 0. * error EXIT. ENDIF. CALL FUNCTION 'HR_FLUSH_BUFFER_UPDATE_PCLX' EXPORTING test = ' ' EXCEPTIONS insert_error = 1 no_update_authority = 2 OTHERS = 3. IF sy-subrc <> 0. * error EXIT. ENDIF.
Leer payroll completo
REPORT yleer_cluster. CLASS cl_payroll DEFINITION. PUBLIC SECTION. CLASS-METHODS: leer_payroll IMPORTING i_pernr TYPE p0000-pernr EXPORTING et_payres TYPE STANDARD TABLE EXCEPTIONS no_data. ENDCLASS. CLASS cl_payroll IMPLEMENTATION. METHOD leer_payroll. DATA lt_rgdir TYPE STANDARD TABLE OF pc261. DATA: ls_payres TYPE REF TO data, lt_payres TYPE REF TO data. DATA: l_pernr TYPE p0003-pernr, l_molga TYPE t500l-molga, l_relid TYPE t500l-relid, l_typename TYPE t52relid-typename, l_tabname TYPE t52relid-tabname. FIELD-SYMBOLS <ls_evp> TYPE any. FIELD-SYMBOLS: <ls_payres> TYPE any, <es_payres> TYPE any, <lt_payres> TYPE STANDARD TABLE. CALL FUNCTION 'CU_READ_RGDIR_NEW' EXPORTING persnr = i_pernr IMPORTING molga = l_molga TABLES in_rgdir = lt_rgdir. IF l_molga IS INITIAL. RAISE no_data. ENDIF. SELECT SINGLE relid INTO l_relid FROM t500l WHERE molga = l_molga. * read typename from t52relid. SELECT SINGLE typename tabname FROM t52relid INTO (l_typename, l_tabname) WHERE relid = l_relid. CREATE DATA ls_payres TYPE (l_typename). "PAYCL_RESULT CREATE DATA lt_payres TYPE TABLE OF (l_typename). ASSIGN ls_payres->* TO <ls_payres>. ASSIGN lt_payres->* TO <lt_payres>. LOOP AT lt_rgdir INTO DATA(ls_rgdir). "Read payroll results CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING clusterid = l_relid employeenumber = i_pernr sequencenumber = ls_rgdir-seqnr filter_cumulations = abap_false CHANGING payroll_result = <ls_payres> EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. "Get evp ASSIGN COMPONENT 'EVP' OF STRUCTURE <ls_payres> TO <ls_evp>. <ls_evp> = ls_rgdir. APPEND <ls_payres> TO <lt_payres>. ENDIF. ENDLOOP. et_payres[] = <lt_payres>. ENDMETHOD. ENDCLASS. PARAMETERS p_pernr TYPE p0000-pernr. START-OF-SELECTION. DATA lt_payres TYPE TABLE OF paycl_result. CALL METHOD cl_payroll=>leer_payroll EXPORTING i_pernr = p_pernr IMPORTING et_payres = lt_payres EXCEPTIONS no_data = 1. if sy-subrc <> 0. return. endif.
Función PYXX_READ_RGDIR_PAYRESULTS
DATA: lt_results TYPE table of pay99_result, lt_rgdir type table of pc261. data: l_pernr type pernr_d, l_molga TYPE t500l-molga. l_pernr = i_pernr. CALL FUNCTION 'CU_READ_RGDIR_NEW' EXPORTING persnr = l_pernr check_read_authority = space IMPORTING molga = l_molga TABLES in_rgdir = lt_rgdir EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. RETURN. ENDIF. CALL FUNCTION 'PYXX_READ_RGDIR_PAYRESULTS' EXPORTING clusterid = 'CL' employeenumber = l_pernr read_only_international = 'X' TABLES rgdir = lt_rgdir imported_periods = lt_results EXCEPTIONS import_error = 1 OTHERS = 2.