SAP HCM ABAP CLUSTER
Contents
- 1 Lectura de datos de Préstamo
- 2 Modificar Cluster
- 3 Leer payroll completo
- 4 Función PYXX_READ_RGDIR_PAYRESULTS
- 5 Función HR_CL_READ_RGDIR_PAYRESULTS (nómina chilena)
- 6 Ejemplo para leer nómina mensual(usada en recibos de sueldo)
- 7 Function Modules for Selecting Payroll Results
- 8 Clase CL_HRPAYES_PAYROLL_READER
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.
Función HR_CL_READ_RGDIR_PAYRESULTS (nómina chilena)
DATA: lt_paycl_results TYPE TABLE OF paycl_result. * Read Payroll Results CALL FUNCTION 'HR_CL_READ_RGDIR_PAYRESULTS' EXPORTING pernr = pernr-pernr begda = l_begda endda = l_endda TABLES paycl_result = lt_paycl_results EXCEPTIONS error_in_cu_read_rgdir = 1 error_in_cd_select_date_range = 2 error_in_cd_select_srtza = 3 error_in_cd_select_void = 4 error_in_cd_select_payty_range = 5 error_in_cd_select_payid_range = 6 error_in_cd_select_fpper = 7 error_in_cd_select_permo = 8 error_in_cd_select_abkrs = 9 error_in_cd_select_juper = 10 error_in_read_rgdir_payresults = 11 error_incorrect_date_range = 12 error_incorrect_fpper_range = 13 error_others = 14 OTHERS = 15. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. LOOP AT lt_paycl_results ASSIGNING <ls_result> WHERE evp-payty IS INITIAL. ct_ort = <ls_result>-inter-rt. EXIT. ENDLOOP. FORM get_mes_completo USING p_pernr p_begda CHANGING p_betrg p_f. DATA lt_results TYPE hrpaycl_tab_of_results. DATA ls_result TYPE paycl_result. CALL FUNCTION 'HR_CL_READ_RGDIR_PAYRESULTS' EXPORTING pernr = pernr-pernr TABLES paycl_result = lt_results EXCEPTIONS OTHERS = 15. DATA(l_lines) = lines( lt_results ). CHECK l_lines > 0. DO. IF l_lines = 0. EXIT. ENDIF. ls_result = lt_results[ l_lines ]. l_lines = l_lines - 1. CHECK ls_result-evp-fpbeg < p_begda. READ TABLE ls_result-inter-rt INTO DATA(ls_rt) WITH KEY lgart = '/TTK'. "Días trabajados IF sy-subrc = 0. IF ls_rt-anzhl >= 30. p_f = abap_true. READ TABLE ls_result-inter-rt INTO ls_rt WITH KEY lgart = '/315'. "Base seg.desempleo empr. IF sy-subrc = 0. p_betrg = ls_rt-betrg. ENDIF. EXIT. ENDIF. ENDIF. ENDDO. ENDFORM.
Ejemplo para leer nómina mensual(usada en recibos de sueldo)
* ver include RPCEDS09 FORM FILL_EVP TABLES eval_results TYPE pay_t_eval_period "WOG note 760945 iabkrs type hrpy_tt_abkrs "VKIK016676 USING VALUE($PAPER) VALUE($PERMO) VALUE($PAYTY) VALUE($PAYID) VALUE($BONDT) VALUE($MC_INCL) $RC. "VKIK032705 DATA: RGDIR_LINE TYPE PC261. * ejemplo con nómina mensual enero 2020 RGDIR_LINE-BONDT = $BONDT. "00000000 RGDIR_LINE-INPER = $PAPER. "202001 RGDIR_LINE-IPERM = $PERMO. "01 RGDIR_LINE-PAYTY = $PAYTY. "space RGDIR_LINE-PAYID = $PAYID. "space RGDIR_LINE-VOID = CD_C-VOID_FALSE. "space CALL FUNCTION 'HRO1_FILL_EVAL_DIR' EXPORTING PAYROLL_DIR = RGDIR[] RGDIR_LINE = RGDIR_LINE IABKRS = IABKRS[] "VKIK016676 en este ejemplo tabla vacía ALL_RESULTS_OF_RUN = $MC_INCL "VKIK032705 en este ejemplo = space IMPORTING * EVAL_DIR = EVP[] "WOG note 760945 eval_tab = eval_results[] "! PAYR_DIR = RGDIR[] EXCEPTIONS NO_EVALUATED_PERIODS = 1 OTHERS = 2 . $RC = SY-SUBRC. IF $RC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. "FILL_EVP
Function Modules for Selecting Payroll Results
The employee’s payroll directory is always transferred to the function modules using the table RGDIR. The modules then transfer the payroll records which satisfy the specified selection criteria using a table whose type corresponds to that of the RGDIR but which has a different name. The selection parameters differ according to the function of the module. For more information, read the module documentation. All module names begin with ‘CD_’.
Explanation of Individual Fields
For-Information The FPPER, FPBEG, FPEND, BONDT, PAYTY, PAYID, ABKRS, PERMO, PAYDT, JUPER fields contain information on the period for which payroll is run.
In-Information The INPER, IPEND, INPTY, INPID, IABKRS, IPERM fields contain information on the period in which payroll is run.
SEQNR The field is used as a key to uniquely identify the payroll record. This field also defines the sequence of payroll results (history).
Control Indicator (SRTZA) Control indicator Meaning
- A Current
- P Previous
- O Old
Function Module: CD_EVALUATION_PERIODS
This module transfers the payroll results to a payroll run as ‘A’ records (current). It also transfers the accompanying ‘P’ records (previous). This is the module most frequently used in evaluation programs.
Function Module: CD_READ_PREVIOUS
This module transfers a previous payroll record for a payroll record; this is the newest record for the payroll period (or daily payroll run) which was written before the transferred payroll record and contains the same FOR data as the transferring record.
Function Module: CD_READ_PREVIOUS_ORIGINAL
This module reads the previous original payroll result.
Ejemplo 1
TYPES: BEGIN OF tinper_directory_entry. TYPES: iperm LIKE pc261-iperm, inper LIKE pc261-inper, inpty LIKE pc261-inpty, inpid LIKE pc261-inpid, inocr LIKE pc261-inocr, ipend LIKE pc261-ipend, END OF tinper_directory_entry. TYPES: tinper_directory TYPE tinper_directory_entry OCCURS 0. DATA: inper_directory_entry TYPE tinper_directory_entry, inper_directory TYPE tinper_directory. FORM read_cluster TABLES p_rgdir STRUCTURE pc261 p_coava STRUCTURE pc2co_ava USING p_pernr LIKE pernr-pernr p_molga LIKE t500l-molga CHANGING p_waers LIKE pc202-waers. . REFRESH: p_rgdir, p_coava, inper_directory. CLEAR: p_rgdir, p_coava, inper_directory_entry, inper_directory. CALL FUNCTION 'CU_READ_RGDIR' EXPORTING persnr = pernr-pernr IMPORTING molga = molga TABLES in_rgdir = p_rgdir EXCEPTIONS no_record_found = 1 OTHERS = 2. IF sy-subrc <> 0. ENDIF. LOOP AT p_rgdir WHERE ipend BETWEEN pn-begda AND pn-endda AND void IS INITIAL. MOVE-CORRESPONDING p_rgdir TO inper_directory_entry. COLLECT inper_directory_entry INTO inper_directory. ENDLOOP. LOOP AT inper_directory INTO inper_directory_entry. CLEAR evp_inper. REFRESH evp_inper. CALL FUNCTION 'CD_EVALUATION_PERIODS' EXPORTING bonus_date = inper_directory_entry-ipend inper_modif = inper_directory_entry-iperm inper = inper_directory_entry-inper pay_type = inper_directory_entry-inpty pay_ident = inper_directory_entry-inpid TABLES rgdir = p_rgdir evpdir = evp_inper EXCEPTIONS no_record_found = 1 OTHERS = 2. IF sy-subrc <> 0. EXIT. ENDIF. LOOP AT evp_inper INTO evp WHERE fpend BETWEEN pn-begda AND pn-endda. IF evp-srtza EQ 'P'. MOVE-CORRESPONDING inper_directory_entry TO evp. "important ENDIF. APPEND evp. ENDLOOP. ENDLOOP. DESCRIBE TABLE evp LINES evp_number_lines. CHECK evp_number_lines GT 0. LOOP AT evp. PERFORM data_cluster TABLES evp p_coava USING evp-fpper CHANGING p_waers. ENDLOOP. ENDFORM. " read_cluster *&--------------------------------------------------------------------* *& Form data_cluster *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * -->P_EVP text * -->P_COAVA text * -->P_FPPER text *---------------------------------------------------------------------* FORM data_cluster TABLES p_evp STRUCTURE pc261 p_coava STRUCTURE pc2co_ava USING p_fpper LIKE evp-fpper CHANGING p_waers TYPE waers. DATA: ls_coava LIKE pc2co_ava OCCURS 0 WITH HEADER LINE. CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING clusterid = import_relid employeenumber = pernr-pernr sequencenumber = p_evp-seqnr read_only_international = ' ' check_read_authority = ' ' CHANGING payroll_result = 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. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE. p_waers = result-inter-versc-waers. CLEAR ls_coava. REFRESH ls_coava. LOOP AT result-nat-coava INTO ls_coava WHERE ( indcl EQ '02' OR indcl EQ '08' ) AND pyper EQ p_fpper. MOVE ls_coava TO p_coava. APPEND p_coava. ENDLOOP. SORT p_coava BY abkrs indcl indcm pyper inper fpper begda endda awart. "+ DELETE ADJACENT DUPLICATES FROM p_coava. ENDIF. ENDFORM. " data_cluster
Ejemplo 2
*Sample Report REPORT rpttmwbs. DATA: rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE. DATA: evpdir LIKE rgdir OCCURS 0 WITH HEADER LINE. DATA: previous_results LIKE rgdir OCCURS 0 WITH HEADER LINE. DATA: calcd TYPE c. DATA: in_entry LIKE pc261. DATA: out_entry LIKE pc261. INCLUDE rpcccd09. CALL FUNCTION 'CU_READ_RGDIR' EXPORTING persnr = '00021218' TABLES in_rgdir = rgdir EXCEPTIONS no_record_found = 1 OTHERS = 2. * Read RGDIR CALL FUNCTION 'CD_EVALUATION_PERIODS' EXPORTING bonus_date = '00000000' inper_modif = '02' inper = '199603' pay_type = cd_c-regular pay_ident = ' ' TABLES rgdir = rgdir evpdir = evpdir * IABKRS = EXCEPTIONS no_record_found = 1 OTHERS = 2. * output: * 00006 * 00007 * 00008 * Read regular payroll results for January * A results (original result plus retroactive calculations) * and P results LOOP AT evpdir WHERE srtza = cd_c-actual. * Only current results (00007 and 00008) CALL FUNCTION 'CD_RETROCALC_PERIOD' EXPORTING entry = evpdir IMPORTING calcd = calcd EXCEPTIONS OTHERS = 1. * Determine, whether original result CHECK calcd = ' '. * Special processing: Only the original period * March is processed (seqnr 00008). in_entry = evpdir. CALL FUNCTION 'CD_READ_PREVIOUS_ORIGINAL' EXPORTING in_record = in_entry IMPORTING out_record = out_entry TABLES rgdir = rgdir EXCEPTIONS OTHERS = 1. * out_entry now contains the previous results * Input 00008 ----> Output 00006 ENDLOOP. LOOP AT evpdir WHERE srtza = cd_c-actual. in_entry = evpdir. CALL FUNCTION 'CD_READ_PREVIOUS' EXPORTING in_record = in_entry TABLES rgdir = rgdir out_rgdir = previous_results EXCEPTIONS no_record_found = 1 OTHERS = 2. * Input 00007 ---> 00006 * Input 00008 ---> no record found * Output structure is a table, since there can be * several previous results: for example, if legal person * changes, and is retroactively deleted ENDLOOP.
Clase CL_HRPAYES_PAYROLL_READER
FORM is_last_period_huelga USING pv_inicio_abs TYPE begda CHANGING cv_last_period_huelga TYPE abap_bool cv_beg_imp_peri TYPE d cv_end_imp_peri TYPE d. STATICS lo_payreader TYPE REF TO cl_hrpayes_payroll_reader. STATICS lv_last_pernr TYPE pernr_d. DATA lv_act_days TYPE p. DATA lv_huelga_days TYPE p. DATA lv_prev_m_begda TYPE dats. DATA lv_prev_m_endda TYPE dats. DATA lt_all_rgdir TYPE h99_clst_t_rgdir. DATA lt_prev_m_rgdir TYPE h99_clst_t_rgdir. DATA lv_exist_bases TYPE abap_bool. DATA lv_previous_month TYPE dats. DATA lt_rgdir TYPE hrpy_tt_rgdir. DATA lt_payes_result TYPE if_hrpayes_payroll_reader=>ty_t_payes_result. DATA ls_payes_result TYPE payes_result. DATA ls_rt TYPE pc207. DATA ls_aper TYPE pc2aper. DATA lv_read_only_buffer TYPE abap_bool. DATA lv_relid TYPE relid_pcl. DATA lo_hr_molga TYPE REF TO cl_hr_molga. FIELD-SYMBOLS <ls_rgdir> TYPE pc261. IF lv_last_pernr <> pernr-pernr. CREATE OBJECT lo_payreader EXPORTING iv_pernr = pernr-pernr. lv_last_pernr = pernr-pernr. ENDIF. * getting first and last day of the month before absence lv_prev_m_endda = pv_inicio_abs. lv_prev_m_endda+6(2) = '01'. lv_prev_m_endda = lv_prev_m_endda - 1. lv_prev_m_begda = lv_prev_m_endda. lv_prev_m_begda+6(2) = '01'. * Checking if exist retrocalculation LOOP AT aper[] INTO ls_aper WHERE paper = lv_prev_m_endda(6) AND calcd = abap_true AND ocrsn IS INITIAL AND occat IS INITIAL. READ TABLE rgdir[] ASSIGNING <ls_rgdir> WITH KEY seqnr = ls_aper-seqnr. IF sy-subrc = 0 AND <ls_rgdir> IS ASSIGNED. APPEND <ls_rgdir> TO lt_rgdir[]. ENDIF. ENDLOOP. IF lt_rgdir[] IS INITIAL. * getting payroll result from previous month from cluster lo_payreader->get_rgdir( EXPORTING iv_fpbeg = lv_prev_m_begda iv_fpend = lv_prev_m_endda iv_srtza = 'A' iv_reorg_rgdir = abap_true IMPORTING et_rgdir = lt_rgdir[] ). IF lt_rgdir[] IS INITIAL. cv_last_period_huelga = abap_false. RETURN. ENDIF. lv_read_only_buffer = abap_false. ELSE. lv_read_only_buffer = abap_true. CALL FUNCTION 'HR_COPY_TBUFF_TO_BUFFER' EXPORTING clusterid = 'RE' TABLES buffer = tbuff[] buffer_directory = buffer_dir[] EXCEPTIONS error_buffertab = 1. IF sy-subrc <> 0. RETURN. ENDIF. ENDIF. lo_payreader->get_pay_result_table( EXPORTING it_rgdir = lt_rgdir[] iv_read_only_buffer = lv_read_only_buffer IMPORTING et_payes_result = lt_payes_result[] ). IF lt_payes_result[] IS INITIAL. cv_last_period_huelga = abap_false. RETURN. ENDIF. * getting number of active days(3AN), number of days of huelga * 3AH and checking if there is no SS bases in previous month LOOP AT lt_payes_result[] INTO ls_payes_result. LOOP AT ls_payes_result-inter-rt[] INTO ls_rt WHERE lgart = '/3AN' OR lgart = '/3AH' OR lgart = '/3Z2' OR lgart = '/3Z3'. CASE ls_rt-lgart. WHEN '/3AN'. lv_act_days = lv_act_days + ls_rt-anzhl. WHEN '/3AH'. lv_huelga_days = lv_huelga_days + ls_rt-anzhl. WHEN '/3Z2' OR '/3Z3'. lv_exist_bases = abap_true. ENDCASE. ENDLOOP. ENDLOOP. IF lv_huelga_days = lv_act_days AND lv_act_days <> 0 AND lv_exist_bases = abap_false. cv_last_period_huelga = abap_true. ENDIF. * Check if absence occurs in the period calculated PERFORM is_absence_after_strike USING pv_inicio_abs ab-oendd aper-begda pnpxabkr CHANGING cv_last_period_huelga cv_beg_imp_peri cv_end_imp_peri. ENDFORM.