Wednesday, February 15, 2012

Off topic: how time evaluation (SAP RPTIME00) sets the retrocalculation date for payroll

One insteresting question today: 
How does the TM RPTIME00 time evaluation engine sets the retrocalculation date RRDAT on the IT0003 to trigger a payroll recalculation?

the answer is simple, but as always the thingy is tricky
In form SET_PAYROLL_RECALCULATION. if the retro switch for TM is set the the evaluation period of TM is checked, and a routine checks whether for each recalculated day a change has occurred in the ZL table compared to the existing ZL of the previous calculation.
the oldes change date in ZL i writte to RRDAT of IT0003

the enabling of the retro switch "SW_FUNC-RLG" happens through the statement
CHECK      RPR 
in the Time evaluation schema


Here the routine.
*---------------------------------------------------------------------*
*       FORM SET_PAYROLL_RECALCULATION                              *
*---------------------------------------------------------------------*
*$*$ Bestimmt RR-Datum für L&G von Sicht des RPTIME00
*$*$ Lücke: Falls RR-Datum von L&G schon für die Vorperiode sitzt wird
*$*$     nicht die RPTIME-spezfische Rückrechnungserkennung durchlaufen.
*       Vorgehen:
*       1. Ist die aktuelle Periode von L&G schon abgerechnet?
*          Wenn nein: stop.
*       2. Liegt das RR-Datum-LG vor Beginn der aktuellen Periode?
*          Wenn ja: stop.
*       3. Bestimme den Tag, an dem sich Daten fuer L&G geaendert
*          haben. (FORM CHECK_RECALCULATION)
*$*$ Punkt 5 wird nun in EXPORT_PERSON überprüft, da die RR-Relevanz für
*$*$ L&G auch dann für das Setzen des Matchcode W gebraucht wird, wenn
*$*$ schon ein RR-Datum für L&G gesetzt ist.
**      5. Ist das RR-Datum-LG kleinergleich dem RR-Datum-ZE?
**         Wenn ja: stop.
*       6. Es muss eine RR fuer L&G gesetzt werden.
*---------------------------------------------------------------------*
FORM SET_PAYROLL_RECALCULATION.
  DATA: SET_RECALC_DATE TYPE D.

  CHECK SW_FUNC-RLG EQ '1'.

* Check ob L&G den Monat schon abgerechnet hat:
  CHECK P0003-ABRDT GE ACT_PERIOD-BEGDA.

* Check ob L&G schon eine RR sitzen hat, die vor Beginn der Per. ist:
  CHECK P0003-RRDAT IS INITIAL OR P0003-RRDAT GE PER-BEGDA.

* Ueberpruefen, ob RR zu setzen ist: This one compars the ZL with the original ZL
  PERFORM CHECK_RECALCULATION USING SET_RECALC_DATE.
* nur wenn Datum kleiner als P0003-rrdat
  CHECK SET_RECALC_DATE NE HIGH-DATE.

* This check is now done in EXPORT_PERSON
* check p0003-rrdat gt set_recalc_date or p0003-rrdat is initial.
                                       "XAYP30K136788

* -- RR ist von Sicht des RPTIME00 zu setzen:
* P0003-RRDAT = SET_RECALC_DATE.                             "YLLK63068
* MODIFY P0003 INDEX 1.                                      "YLLK63068
  IF SET_P0003-RRDAT IS INITIAL                             "YLLK63068
      OR SET_RECALC_DATE LT SET_P0003-RRDAT.                "YLLK63068
    SET_P0003-RRDAT = SET_RECALC_DATE.                      "YLLK63068
  ENDIF.                                                    "YLLK63068
ENDFORM.                               "OF SET_RECALCULATION.

Interestingly enough function check RLG has no coding but is handled in a very special way that puzzles me every time i have to look it up. So this time i write it down, so hopefully it will be the last time i have to look it up.

form RPTASI00_FILL_VARIABLES_FROM_F filles the "SW_FUNC" fields dynamically (with assigns)
the table FIELDS that containes information on what field to set is saved on the cluster with the generated TM schema:

  perform clear_variables_from_fields.                     "note757356
  perform get_schema(rpuscgt0)
                    using vschema '1'
                          print sw-schema_update
                          space space
                          returncode.
  read table as-source with key schem = vschema.            "PH4K008260
  if returncode = 0.                                        "NOTE202647
    perform fill_variables_from_fields.                     "PH4K008260
  endif.     

And guess what: the fields table is filled in the generation of the TM schema and written with the generated schema directly to cluster PS.
Here a screen shot.




HTH
happy hacking
cheers