Master the Art of Writing Time PCRs
I have come across many queries in SAP Community Network where SAP HCM consultants would like to acquire the skillset to write Time PCRs. This knowledge artifact is an attempt from my side to impart this knowledge based on my experience of working in Time management over 7 years and writing Time PCRs in various SAP HCM projects.
However, before I go any further, let me be frank that there are no shortcuts to this. There isn’t any tonic available in the market that you take a couple of shots of it and overnight, you become an expert in writing Time PCRs.
It will require persistent and diligent efforts, analytical bent of mind and patience and if you are game for it, this knowledge artifact is definitely for you.
Unlike other modules in SAP HCM where you have to mostly update configuration tables, Time Management and Payroll require you to map customer scenarios using PCRs, operations and functions and this is what makes these two modules very complex. However, once you have mastered the art of writing custom PCRs, you will realize that SAP has provided such a robust and flexible option in terms of PCRs to meet various client requirements. I refer to PCR Writing as functional coding and it is similar to ABAP coding.
A Personnel Calculation Rule (PCR) is called within a schema for executing subtasks using various operations. Each step within a PCR corresponds to an operation and there can be sub PCRs too. A PCR will be processed by a function.
Below is an example of a PCR MODT being processed by function MOD in standard schema TM00.
You can access, create, modify or delete PCR using TCode PE02.
Each PCR has below sub-objects:
- Source Text – This displays the PCR in tree structure or table view and has two options – ESGrp Grouping and Wage/Time type. Below is the screenshot of the PCR in tree structure. The operations are highlighted in red box. Hence, PAYTP and MODIF are two examples of time operations.
- Attribute – The attributes section display the text of the PCR, program class (T – Time Management, C – Payroll), Country Grouping, Person Responsible, Changes only by Person Responsible Checkbox, Created On and Last Change By date. Please refer below the screenshot of the same:
- Documentation – This displays the documentation of the PCR and explains the functionality and usage of this PCR.
We never modify standard PCRs delivered by SAP. If we have to make any changes to standard PCR, we copy the standard PCR to a custom PCR and make changes to the custom PCR. Also, we comment out the standard PCR in the schema and replace it with the custom PCR. It is recommended to use codes starting with Z or Y for custom PCRs.
Probable Roadmap towards Becoming an Expert in Writing Time PCRs
When I had started my career in Time Management and Payroll, I went to a colleague of mine and asked him about the best way to learn these two complex modules. I wanted to get rid of the fear of time evaluation and payroll run log. His answer was a very simple one. Execute time evaluation for an employee and go through each node in the time evaluation log to understand how time data is getting processed by each function, PCR and operation. In hindsight, I can say that it was the best thing he advised me to do. And this is what I did. I ran time evaluation for an employee and went through the entire processing log one by one and in the process, I got myself educated on a number of standard functions, PCRs and operations. While I was doing this activity, I used to maintain a document to record the meaning and usage of the standard functions, PCRs and operations I came across. Of course, there were few complex things which were not clear and I used to go to him to get them clarified.
There was one important piece I had missed in this and that was the understanding of time types. Since I didn’t have sound understanding of time types, I was not good in writing new Time PCRs from scratch. I was, however, good in resolving support tickets which required analyzing the time evaluation log and changing or fixing existing PCRs. Hence, I had become like a car mechanic who could fix issues in a defective car and bring it back to shape. But I was still not good enough to create a new car on my own. Hence, it is very important that consultants get an understanding of time types if they wish to learn to write PCRs on their own.
Step 1: Understand Time Types – The DNA of Time PCRs
The first step involves developing an understanding of the functionality of time types. Without this, you will never be able to map complex time scenarios in Time PCRs. I have written a knowledge artifact regarding the same which will help you get this understanding. Please go through the below document.
Step 2: Run Time Evaluation and study the Time Evaluation Log
Why am I asking you to go through this step? This is the best way to get an understanding of how time data gets processed in time evaluation. You will be going through each node and in the process, get an understanding of the usage of each function, PCR and operation. Don’t worry if things are not clear at the first instance itself for all the nodes in time evaluation log. But do continue this for the entire log. You can try various scenarios like capturing an attendance in IT2002, capturing absence in IT2001, capturing time events in IT2011, not capturing any data at all anywhere (positive time evaluation will result in error and negative time evaluation will get evaluated normally) and then running the time evaluation and studying the time evaluation log. You can go through the documentation of functions and operations and PCRs using TCode PE04 and PE02 respectively.
While I was doing the above activity, I used to maintain a spreadsheet with the codes of functions, PCRs and operations and their usage in separate worksheets. This helped me to do a quick review of what these functions, PCRs and operations were meant for, whenever required.
Taking cue from P.K. Agrawal’s book on Time Management, there are five different types of operations:
- Operations that provide information for Decision Making in PCRs
- Operations that change contents of Internal Tables
- Operations that change Overall Status
- Operations that change contents of Database Tables
- General Operations
Below screenshot shows these operations arranged in the above 5 categories:
I would recommend that you create 5 worksheets in a spreadsheet based on the above categories and capture the definition and usage of each of the above operations as you study the time evaluation log. Idea should be to capture the gist of the usage and not the entire content available in the documentation. And, you should go through this list often and revise so that you develop a good understanding of the usage of each operation.
The most commonly used operations in Time PCRs are OUTWP, TABLE, VARAB, VARPR, VARST, ADDDB, ADDMB, COLER, COLOP, FILLP, HRS, TFLAG, GCY and PCY and I would recommend that you study them first and understand them. You can also use the “Where Used” functionality in TCode PE04 to find out PCRs where the given operations are being used.
I always had a confusion regarding when to use GCY and PCY as both of them seemed to call another sub-rule. I was able to figure this out later on. GCY is used when you want to branch on to a new sub-rule from one rule and you will be processing only this sub-rule going forward. PCY is used when you want to process multiple sub-rules simultaneously from one rule.
You may also find that you have exhausted the maximum no. of operations that can be used in a PCR. In such a scenario, you will use the last operation (GCY or PCY as the case may be) in the PCR to move on to a new sub-PCR or another employee subgroup grouping of the same PCR.
Taking cue from P.K. Agrawal’s book on Time Management, there are three different types of functions:
- Functions that set a switch: These functions can be called at any position within the schema and they are called again while the current schema is being executed. Such functions don’t get processed in IF, ELSE and ENDIF loop. Examples are like OPPT, CHECK, EXPRT etc.
- Functions that import data: Examples are P2001, P2011, P2002 and so on.
- Functions that process a PCR:
- Functions for processing status information like ACTIO.
- Functions for processing internal tables like PTIPA, PTIP.
- Functions with fixed processing like PBRKS.
Let me explain you the usage of common functions which process PCRs.
- RTIP: It is used to read entries in Table TIP. Entries in Table TIP won’t get changed.
- RTIPA: It is used to read entries in Table TIP only if there is an absence for the given day. Entries in Table TIP won’t get changed.
- PTIP: It is used to process entries in Table TIP. Entries in Table TIP may get changed.
- PTIPA: It used to process entries in Table TIP only if there is an absence for the given day. Entries in Table TIP may get changed.
- ACTIO: It can be used to process any time PCR if there is no need to read or process Table TIP.
While using functions RTIP, RTIPA, PTIP and PTIPA to process a PCR, please use GEN in parameter 3 (beside the PCR) in the respective line of the schema if you are not processing the PCR for a specific time type.
While working on a requirement for one of my clients, I chanced upon a standard function PZL which gives a lot of flexibility to process wage types in Table DZL. Using this function, I was able to round off overtime hours generated in wage type from Table T510S. I was also able to split overtime hours after it has breached a given threshold limit in a month.
You can refer the below documents where function PZL has been used:
Step 3: Develop Clarity of Thought on the Requirements and visualize design
It is one of the most important activities that each consultant must do while trying to write a new PCR. One must have clarity of thought on the requirements. Because only then, you will be able to design the right PCR to meet the requirements. I discovered this technique fortuitously.
Every PCR goes through the below stages and each stage has few typical queries:
- What data needs to be processed?
- Where does the data come from?
- For whom the data needs to be processed?
- How does the data need to be processed?
- What should be the outcome of this processing?
- Where the processed data needs to be stored?
For each stage, depending on the activity, you may require different operations. Use the above questions to find the operations which will help you design the PCR. For example, a particular PCR needs to be processed for employees belonging to Personnel Area 1000 only. In such a case, it is the 1st question in the processing stage and you will use operation OUTWP as a decision operation to filter out the employees belonging to Personnel Area 1000.
When you have to write a custom PCR, you should try to understand the requirements functionally before trying to figure out the operations to use. You should think of the complete design in a way that if this requirement was being handled by someone else, then you should be able to explain the step by step process of how the solution should work. You should ask the above questions which will help you zero down on the operations to use or direct you to look for the right operations from the list you have prepared.
Frankly speaking, I discovered this accidently, while trying to build my first solution independently using PCRs and time types. Below is the document regarding my first solution:
I would recommend you to go through it so that you get an idea about the challenges faced when you are developing a solution using PCRs independently for the first time.
There may be situations when no standard operation can handle the client’s requirements. In such a case, you may go for development of a custom operation.
Step 4: Practice already built Standard and Custom PCRs
Practice, Practice and Practice!!! There is no substitute to this.
Yes, that’s the mantra to get into the groove of writing PCRs. Develop your confidence and understanding of the PCRs by creating simple Standard and Custom PCRs which are already built.
Some of the simple standard PCRs which you can practice are MODT, TD20, TD10 and TE20. If you wish to practice simple custom PCRs, you can refer to the below blogs:
Once you have mastered the simple PCRs and created them on your own, you can move on to medium and high complexity PCRs. Some of the medium and high complexity standard PCRs which you can practice are TE30, TO01, TO02, TW31, TW32, TW33, TW34, TW35, TW36, TO20 and TO21. If you wish to practice medium and high complexity custom PCRs, you can refer to the below blogs:
Please ensure that you run time evaluation and validate that PCRs created by you are behaving as expected. It is very important that you go through the processing log of the PCR to validate its functioning.
Step 5: Moment of Truth – Build your own solution using custom PCRs
After you have gone through the above steps, you will definitely become comfortable in writing custom PCRs. But the moment of truth will come when you are able to do end to end design and build of a solution using custom PCRs independently. That moment will slowly and steadily build your confidence and help you to design more solutions with custom PCRs for various client requirements. And as you go on writing more PCRs, you will finally realize that writing PCR comes to you naturally.
The above steps are simply guidelines to help new consultants wanting to master the art of writing time PCRs. For some of them, the learning curve may be faster and not all steps may be needed. Some who may have attended SAP training may do it even quicker.
I hope consultants will benefit by the approach highlighted in this blog. It will require continued perseverance and patience to reach the goal. Remember that Rome wasn’t built in a day.
RPTIME00 Future Ahead?
SAP is rapidly changing quite a few things in SAP HCM space after acquiring SuccessFactors and one of the things which may get impacted is time evaluation solution. As per the blog – (RP)TIME to Say Good Bye? – published by Sven Ringling yesterday, SAP may soon sound the death bell for RPTIME00 program and time evaluation solution. If that indeed happens to be the case in future, it will be really unfortunate for SAP to do away with a time tested, highly flexible and robust time evaluation solution. And that would mean that my blog will also become redundant
Till that point of time, where customers continue to use time evaluation and new consultants are willing to acquire the art of writing Time PCRs, I hope this knowledge artifact will be useful and relevant.
You can also refer to other knowledge artifacts created by me at the below link: