Abrechnungsresultate für die Inperiode lesen
Hier werden die Abrechnungsresultate der Inperiode gelesen für die Lohnart /102 für die letzten 12 MT
"=======================================================================
"
Durchschnittlicher AHV-pflichtiger
" Bruttomonatslohn während der letzten 60 Monate
" / Lese Abrechnungsresultate der letzten 60 Monate
"=======================================================================
DATA: lf_line_rt TYPE p LENGTH 4.
DATA: lf_datum_fr TYPE sy-datum.
DATA: lf_lgbet TYPE maxbt.
DATA: lt_payroll_result TYPE TABLE OF paych_result.
DATA: lt_payroll_result_act TYPE TABLE OF paych_result.
DATA: ls_payroll_result TYPE paych_result.
DATA: ls_rt TYPE pc207.
DATA: lt_tab_output TYPE TABLE OF p02rpluvgc2_alv1.
DATA: ls_output LIKE LINE OF lt_tab_output.
DATA: lf_inper_act TYPE paper.
DATA: lf_inper_lst TYPE paper.
CLEAR: lf_line_rt, lf_datum_fr, lf_lgbet, lt_payroll_result,
lt_payroll_result_act, ls_payroll_result, ls_rt, lt_tab_output,
ls_output, lf_inper_act, lf_inper_lst.
CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'
EXPORTING
months = '-11'
olddate = <fs_0600>-fire_date
IMPORTING
newdate = lf_datum_fr.
CLEAR: lt_payroll_result.
"lese die Abrechnungsergebnisse der letzten 12 Monate für die Inperiode
lf_inper_act = <fs_0600>-fire_date(6).
lf_inper_lst = lf_datum_fr(6).
CALL FUNCTION 'HR_GET_PAYROLL_RESULTS'
EXPORTING
pernr = <fs_0600>-pernr
* permo = '01'
pabrj = lf_datum_fr(4)
pabrp = lf_datum_fr+4(2)
pabrj_end = <fs_0600>-fire_date(4)
pabrp_end = <fs_0600>-fire_date+4(2)
inper_lst = lf_inper_lst
inper_act = lf_inper_act
* actual = 'A'
* WAERS =
* ARCH_TOO =
TABLES
result_tab = lt_payroll_result
EXCEPTIONS
no_results = 1
error_in_currency_conversion = 2
t500l_entry_not_found = 3
period_mismatch_error = 4
t549q_entry_not_found = 5
internal_error = 6
wrong_structure_of_result_tab = 7
OTHERS = 8.
IF sy-subrc = 0.
" Zählen der Zeilen einer Tabelle
lf_line_rt = lines( lt_payroll_result ).
ENDIF.
"get all actual results for current in-period
CLEAR lt_payroll_result_act.
LOOP AT lt_payroll_result INTO ls_payroll_result.
IF ls_payroll_result-evp-srtza = 'A'.
APPEND ls_payroll_result TO lt_payroll_result_act.
ENDIF.
ENDLOOP.
LOOP AT lt_payroll_result INTO ls_payroll_result.
"Nur für Lgart /102
LOOP AT ls_payroll_result-inter-rt INTO ls_rt
WHERE lgart = '/102'.
"Personalnummer holen
CLEAR ls_output.
MOVE-CORRESPONDING ls_rt TO ls_output.
ls_output-pernr = <fs_0600>-pernr.
"Periode holen
ls_output-inper = ls_payroll_result-inter-versc-inper.
ls_output-fpper = ls_payroll_result-inter-versc-fpper.
ls_output-srtza = ls_payroll_result-evp-srtza.
"Lohnartentext holen
SELECT lgtxt FROM t512t INTO ls_output-lgtxt
UP TO 1 ROWS
WHERE
lgart = ls_output-lgart AND
sprsl = sy-langu AND
molga = langu.
ENDSELECT.
"Lohnarten und Splits
ls_output-lgcnt+0(4) = ls_output-lgart.
ls_output-lgcnt+5(2) = ls_output-cntr2.
ls_output-lgcnt+8(2) = ls_output-cntr3.
ls_output-cntr23+0(2) = ls_output-cntr2.
ls_output-cntr23+3(2) = ls_output-cntr3.
"P oder A ( P Werte abziehen)
IF ls_output-srtza EQ 'P'.
ls_output-betrg = ls_output-betrg * -1 .
ls_output-anzhl = ls_output-anzhl * -1 .
ls_output-betpe = ls_output-betpe * -1 .
"Mache ein A aus den P?
* IF p_s_prev NE 'X'.
ls_output-srtza = 'A'.
* ls_output-inper = lf_inper_act.
* ENDIF.
ENDIF.
" Erstelle Tabelle
COLLECT ls_output INTO lt_tab_output.
" Addiere Gesamtbetrag
lf_lgbet = lf_lgbet + ls_output-betrg.
ENDLOOP.
ENDLOOP.
output-monthly_salary = lf_lgbet.
Klasse
METHOD get_payroll_result.
*-----------------------------------------------------------------------
* Methode:
*-----------------------------------------------------------------------
* DOKUMENTATION ZUR METHODE:
*
* ZWECK: /102 Lohnkomulation Inperiode für AGB
*-----------------------------------------------------------------------
* DOKUMENTATION ZU ERSTELLUNG:
*
* ERSTELLUNG:
*
* 29.05.2020 Michel Regotz
* Durchschnittlicher AHV-pflichtiger
* Bruttomonatslohn während der letzten 12 Monate
* / Lese Abrechnungsresultate der letzten 12 Monate
*
*-----------------------------------------------------------------------
* AENDERUNGSKONTROLLE:
*
* <Änderungs_ID>
* <Datum>, <Vorname, Name des Entwicklers>,
* <kurze Beschreibung der Aenderung bzw. Hinweis zu CRQ-Nr.>
*
*-----------------------------------------------------------------------
*IV_PERNR TYPE PERNR_D Personalnummer
*IV_FIRE_DATE TYPE P02_FIRE_DATE Austrittsdatum
*IV_MONATE TYPE AMMRH_BI Anzahl Intervallmonate für Basisbetrachtung
*value( RV_BETRG ) TYPE MAXBT Personalabrechnung: Betrag
"=======================================================================
" Durchschnittlicher AHV-pflichtiger
" Bruttomonatslohn während der letzten 12 Monate
" / Lese Abrechnungsresultate der letzten 12 Monate
"=======================================================================
DATA: lf_line_rt TYPE p LENGTH 4.
DATA: lf_datum_fr TYPE sy-datum.
DATA: lf_lgbet TYPE maxbt.
DATA: lt_payroll_result TYPE TABLE OF paych_result.
DATA: lt_payroll_result_act TYPE TABLE OF paych_result.
DATA: ls_payroll_result TYPE paych_result.
DATA: ls_rt TYPE pc207.
DATA: lt_tab_output TYPE TABLE OF p02rpluvgc2_alv1.
DATA: ls_output LIKE LINE OF lt_tab_output.
DATA: lf_inper_act TYPE paper.
DATA: lf_inper_lst TYPE paper.
CLEAR: lf_line_rt, lf_datum_fr, lf_lgbet, lt_payroll_result,
lt_payroll_result_act, ls_payroll_result, ls_rt, lt_tab_output,
ls_output, lf_inper_act, lf_inper_lst.
"Nimmt das Datum und verkleinrt die Jahres anzahl
CALL FUNCTION 'RE_ADD_MONTH_TO_DATE'
EXPORTING
months = iv_monate
olddate = iv_fire_date
IMPORTING
newdate = lf_datum_fr.
CLEAR: lt_payroll_result.
"lese die Abrechnungsergebnisse der letzten 12 Monate für die Inperiode
lf_inper_act = iv_fire_date(6).
lf_inper_lst = lf_datum_fr(6).
CALL FUNCTION 'HR_GET_PAYROLL_RESULTS'
EXPORTING
pernr = iv_pernr
* permo = '01'
pabrj = lf_datum_fr(4)
pabrp = lf_datum_fr+4(2)
pabrj_end = iv_fire_date(4)
pabrp_end = iv_fire_date+4(2)
inper_lst = lf_inper_lst
inper_act = lf_inper_act
* actual = 'A'
* WAERS =
* ARCH_TOO =
TABLES
result_tab = lt_payroll_result
EXCEPTIONS
no_results = 1
error_in_currency_conversion = 2
t500l_entry_not_found = 3
period_mismatch_error = 4
t549q_entry_not_found = 5
internal_error = 6
wrong_structure_of_result_tab = 7
OTHERS = 8.
IF sy-subrc = 0.
" Zählen der Zeilen einer Tabelle
lf_line_rt = lines( lt_payroll_result ).
ENDIF.
"get all actual results for current in-period
CLEAR lt_payroll_result_act.
LOOP AT lt_payroll_result ASSIGNING FIELD-SYMBOL(<ls_payroll_result>).
IF <ls_payroll_result>-evp-srtza = 'A'.
APPEND <ls_payroll_result> TO lt_payroll_result_act.
ENDIF.
ENDLOOP.
LOOP AT lt_payroll_result ASSIGNING <ls_payroll_result>.
"Nur für Lgart /102
LOOP AT <ls_payroll_result>-inter-rt INTO ls_rt
WHERE lgart = '/102'.
"Personalnummer holen
CLEAR ls_output.
MOVE-CORRESPONDING ls_rt TO ls_output.
ls_output-pernr = iv_pernr.
"Periode holen
ls_output-inper = <ls_payroll_result>-inter-versc-inper.
ls_output-fpper = <ls_payroll_result>-inter-versc-fpper.
ls_output-srtza = <ls_payroll_result>-evp-srtza.
"Lohnartentext holen
SELECT lgtxt FROM t512t INTO ls_output-lgtxt
UP TO 1 ROWS
WHERE
lgart = ls_output-lgart AND
sprsl = sy-langu AND
molga = iv_langu.
ENDSELECT.
"Lohnarten und Splits
ls_output-lgcnt+0(4) = ls_output-lgart.
ls_output-lgcnt+5(2) = ls_output-cntr2.
ls_output-lgcnt+8(2) = ls_output-cntr3.
ls_output-cntr23+0(2) = ls_output-cntr2.
ls_output-cntr23+3(2) = ls_output-cntr3.
"P oder A ( P Werte abziehen)
IF ls_output-srtza EQ 'P'.
ls_output-betrg = ls_output-betrg * -1 .
ls_output-anzhl = ls_output-anzhl * -1 .
ls_output-betpe = ls_output-betpe * -1 .
"Mache ein A aus den P?
* IF p_s_prev NE 'X'.
ls_output-srtza = 'A'.
* ls_output-inper = lf_inper_act.
* ENDIF.
ENDIF.
" Erstelle Tabelle
COLLECT ls_output INTO lt_tab_output.
" Addiere Gesamtbetrag
lf_lgbet = lf_lgbet + ls_output-betrg.
ENDLOOP.
ENDLOOP.
rv_betrg = lf_lgbet.
ENDMETHOD.