Through this document I'll show you how to debug the payroll process, focusing in payroll driver debugging. You'll find here some tips and tricks that will help you save time.
As a prerequisite to understand this blog you should have a basic debugging knowledge.
Here are some interesting links for general debugging:
Table of content
Using hard break-points to debug the Schema.
Whenever you can modify the system you are analyzing (e.g. you are debugging a development system), and you have authorization to modify rules and schemas you can set a hard break-point.
For this, you have to modify your user-profile and set an ABAP prefix (AB4).
Once you have a prefix of your own, you can set a break-point at a certain point in a Schema by editing the Schema (Trx PE01). For this you'll use the payroll function BREAK followed by your ABAP prefix.
Example: Set a break-point in Schema E000:
If you run your payroll driver, the debugger will stop just before EANT schema.
Now you can go to the next payroll function by exiting function break (F7).
Then press key F5 and set a soft break-point at PERFORM as-funktion.
You can display the current function to be processed by displaying in your debugger screen table AS (Header).
Table AS contains the Schema and its header contains the current function in the schema being processed (AS-FUNCO).
Now you can stop right before next function to be processed in schema by pressing F8.
In this case, you are about to debug function P0092. To get inside it just press F5.
In this case the function code to be debugged is very short. Go to the next function by pressing F8.
Of course you could have set a soft break-point directly at function P0092--- pe04.
You can set a break-point in a payroll rule, as well. For this you'll use the payroll operation BREAK, followed by your ABAP prefix.
When a pernr is rejected in the payroll log.
Just set a break-point in the command "reject". Start payroll processing in debugging mode /H, then go to... finally press F8 key, you'll reach the reject command. After that you have to take a look at "Calls" to guess where the error is coming from.
For example, you run the payroll drive and get a log like this:
Go back to the selection-screen and start payroll in debugging mode with /H.
Now you are debugging the payroll and you need to reach the point of rejection:
Stop it at the reject command:
Then press F8 so that the command "Reject" is reached:
Now press the "Calls" icon:
The following routines:
Are common to all the rejections so they will not add any value info, so we go to the first relevant form:
Double-clicking on it we get to the ABAP code and set a break-point just before the error process is triggered (Or maybe analyzing the ABAP code that triggers the error is enough):
When you start payroll again you'll be able to debug the code that triggered the rejection which will help you identifying the cause of the error.
Find out at which point of the payroll Schema, a Wage Type is generated or a WT is set to a specific value
Watch-points will help you a lot on this. If for example you find that WT /341 equals 1.375,00 EUR at the final payroll results and you want to know where in the payroll schema WT /341 amount was set to 1.375,00 EUR.
Start payroll in debugging mode by going to the payroll driver selection-screen and setting /H at the ok-code. Then press F8 to start the program.
Now create a watchpoint.
And fill the required condition.
Create a second watchpoint because the condition is: it-lgart = /341 and it-betrg = 1.375,00
Now both condition have to be linked by the "And" operator.
Now continue by pressing F8. The program will stop when the watchpoint condition is fulfilled.
You'll notice that in the watchpoint condition I used WT table IT instead of table RT. If I had set the same condition for table RT, the program would have stopped later on in the schema when WT /341 is collected to be stored in table RT which is useless. Sometimes, WTs are directly created in table RT so in that cases, setting the condition for table RT might be useful. Many times, WTs are created within a rule operated by function PIT or PRT. In that case, you'd better set the condition for table OT (OT-LGART, OT-BETRG...). If you do so, the program will be stopped at the relevant operation within the rule. To see which rule is it, look internal table AS header. To know what operation is it, display the structured field OP.
By the way, if a WT is set to a specific value in a PIT rule and instead of setting the watchpoint at OT table you do it at IT table, the watchpoint will stop at the end of the rule as you can see in the code below:
LOOP AT it.
using it-lgart calcmolga.
MOVE ccycl TO i52c5.
MOVE-CORRESPONDING it TO i52c5.
ot = it.
PERFORM ot-in-it-append. "append statt collect, beinhaltet refresh ot.
ENDFORM. "END OF FUPIT
So it's more accurate to set the watchpoint at table OT than at table IT in these cases, but remember that rules are flexible and there are operations to append WTs directly to table IT.
Problems with Retros
When there are many retro periods in the payroll run you are analyzing, the same piece of code will be reached once and again and you have to press the F8 key a lot of times before you reach the point you where the issue arises. Table APER manages the periods processed in a payroll run and it's header holds the currently processed period. In the following pic you can see that period 01.2008 is being processed in a payroll run started from in-period 01.2009.
You can use APER-PAPER and APER-IAPER as watchpoint conditions so if for example you set a break-point at function EST00 (Which calculates Spanish taxes) and there are 10 retro periods to be calculated and you want to debug just the current period:
1. Deactivate (Not delete) the break-point at function EST00.
2. Set APER-PAPER = APER-IAPER as a watchpoint condition.
As an alternative to using table APER, you can assign a counter to the break-point so that it stops only after "n" occurrences:
e.g. Stop in function EST00 after EST00 being processed 13 times:
Finally, when the APER-PAPER is set to the payroll period you want to analyse (beause the watchpoint stopped), activate the break-point and go ahead: F8.
Reaching a payroll function or operation once the debugger has started
Payroll functions are coded as form FUXXXX being XXXX the name of the function. e.g. function wpbp is coded as form fuwpbp. Payroll Operations are coded as OPXXX being XXXX the name of the operation. Knowing this makes easy to reach any Function / Operation.
Then press F8 key and you get to the beginning of the routine.
How to debug a Personnel Calculation Rule
You already know that a PCR or cycle is not working as desired but do not know at what point of the rule the problem is. When a PCR is processed, a sequence of payroll operations will be processed. You can see how a rule works processing one operation in each step and monitor the intermediate results. Then you may realize the problem is that the rule is not correct or you can debug inside the operation.
Firstly, you have to reach the rule you are going to debug. For that you can set a hard break-point as stated at the beginning of this document or a watchpoint (AS-PARM1 = XXXX where XXXX is the name of the rule) AND ( OT-LGART = YYYY where YYYY is the WT to be processed by the PCR). It is important that both watchpoint conditions are linked by the condition AND
We are going to debug PCR ESPB at Payroll Schema E000 for payroll driver RPCALCE0.
Going to the payroll log we see that WT S121 is calculated at PCR ESPB:
So now, let´s start the debugger and set the watchpoint condition AS-PARM1 = ESPB and OT-LGART = S121, here is how your debugger screen will look when the watchpoint conditions are reached:
Rule ESPB is processed by PIT Function which means that table WTs in table IT will be processed in a loop. Each time a WT is processed the table IT header will be copied to auxiliary table OT and within the PCR processing the individual operations will normally put their results in table OT. At the end of the PCR processing, table OT will substitute table IT. Relevant fields for IT and OT are ( LGART, BETRG. BETPE, ANZHL...).
Now go inside PERFORM regel by pressing F8 and search PERFORM boper with the arrow down
-> Set a break-point on PERFORM boper.
Make sure you display at the bottom of the debugger screen the fields you want to monitor:
You can also display the current operation at the header of table OP or i52c5-op1.
Now you can deactivate the watchpoint.
Click in F8 every time you want to go to the next operation (And F5 if you want to take a deeper look as to how the operation works internally):
It might happen that you set a breakpoint at a certain part of the code where the payroll execution goes through again and again. For example in retrocalculation or in case your break-point is in a routine that is placed inside a loop. E.g. you placed a break-point inside a piece of code that is executed within a loop and you want the debugger to stop only the 10th time that the break-point is reached. You can specify a counter for your break-point.
Click on the break-point button:
Set 10 times in the count. field.
Of course, if the break-point is reached less than 10 times, it will never stop, but you are supposed to know th number of times the break-point will be reached before hand.
When an issue happens for a specific pernr
The issue only happens with a specific pernr X, however if you run payroll driver for the pernr X individually, you don't get the error.
1. (Optional) You can set the break-point beforehand in the piece of code you want to debug.
2. (Conditional) If you didn't do step (1) start payroll driver with /H.
3. (Conditional) If you did step (1) deactivate all break-points.
4. Set a watch-point with condition pernr-pernr = X.
5. (Conditional). If you did step (1) Activate all break-points, otherwise set a break point in the piece of code you want to debug.
Can all this be applied to the Time Evaluation?.
Yes, RPTIME00 works with the rules in the same way as the payroll drivers RPCALCX0 / HXXCALC0. In this case you may find useful to know that PER play the same role as table APER for payroll. Therefore you can use the header of PER to stop the processing at a specific day:
e.g. Set a watchpoint at PER-BEGDA = 20080901 or ACDATE = 20080901.
Good to know:
You can expand the payroll an time schema by running program RPDASC00.
Skipping blocks of code:
As you can see in the picture below, in new releases you can skip a piece of code by placing the cursor in the code line you want to jump:
This is not a feature valid only for payroll or HCM module. Skipping a block code is usefull:
* If you have an error and you suspect which the code responsible for the error is. Just skip it and you'll know if your suspicion ins true or not. If the code was introduced by an SAP note, you may have found a side-effect. And it's not good to modify a standard program just to do this kind of tests.
* After a long debug session you executed a part of the code that was important without pay attention. In this case you may jump back to a code line thta was already executed as long as you do not jump between differente subroutine levels.
The following SAP related note is interesting:
Some useful places to set a break-point:
In the following wiki article you will find some hints: