Friday, July 10, 2009

Wage Type Processing Basic Concepts

Wage Type Processing Basic Concepts


Relationship of Payroll Driver, Schema (Functions), Rules (Operations)

Each country payroll version supported by SAP has a program called the "payroll driver" that calculates payrolls. For example, in the U.S., the payroll driver is RPCALCU0, in Mexico it is HMXCALC0, and in Canada RPCALCK0. Each one is different, but they share a common core of functionality. The job of the payroll driver is to process payroll functions as specified in a payroll schema. These payroll functions each perform a specific job, for example - reading data from infotypes, calculating taxes, and processing wage types. Some functions process payroll rules. Rules are a collection of payroll operations. Each operation does a small unit of work, such as multiplying a wage type’s number by a rate to get an amount.

Schemas are edited with transaction PE01, and rules

Figure 1 – Processing relationships

with PE02. Functions and operations are maintained with transaction PE04. To view payroll results,

use transaction pc_payresult (or in earlier R/3 releases go to Tools>Payroll result>Display in the Payroll menu). (See Figure 1.)The standard payroll schema for a country can be derived from table t500l. If the country in table t500l has an X in the Old Naming Conv field, then the schema is HR Country Indicator plus 000. Otherwise, it is the ISO Code plus 00. So the U.S. has schema U000 and for Mexico it is MX00.

Header and Table Wage Type Concept

When calculating payroll, wage types are read from infotypes and the Time Management cluster and stored in an internal table called the Input Table (IT). (See Table 1.) In ABAP terms, this is simply an internal table. Various payroll functions and operations can read and update data in this table. Similar to ABAP internal tables, there is a header row. That header row defines which row of data can be accessed by the payroll operations. After manipulating the data in the header row, you can save the row back to the IT, save it to another payroll table, or ignore it. In Table 1 there are three wage types, and wage type 2100 is currently in the header row. After you are done with wage type 2100, wage type 4200 is moved into the header row.

Table 1

Wage type

Number

Rate

Amount

2100

0

0

100.00

2100

0

0

100.00

4200

0

0

20.00

1500

40

10.30

412.00

Table 1 Input Table

Creating Custom Schemas and Rules

Schema and Rule Naming Conventions

Customer modified schemas and rules need to begin with Z. Many customers simply replace the first letter of the standard schema with a Z – i.e., their modified copy of UAP0 becomes ZAP0. But there can be problems with that convention. For example, you might later implement Canadian payroll and need a modified version of schema KAP0, but ZAP0 is already used for the U.S. For many years, I’ve used a naming convention of Z plus the country identifier and a sequential number for modified rules and schemas. So a modified UAP0 would become ZU01 and a modified KAP0 becomes ZK01.

Editor Documentation

Documentation for the function, operation, schema, and rule editors is available online at http://help.sap.com. Click on SAP R/3 and R/3 Enterprise and then select your release level and language. Then navigate to the Human Resources>HR Tools section.

F1 Help

In the schema and rule editors, place your cursor on a function or operation and press F1 to get help text. A schema or a rule’s documentation is available in the editor via the Goto>Documentation menu. In the schema editor, the F4 key shows possible values for each of the four parameters for whatever function is entered on that line. The same documentation – and more – is available via transaction PDSY.

Creating a Test Schema

For testing purposes, it is useful to have a version of the payroll schema that does not care about the control record (transaction PA03) settings. Bypassing the control record lets you run and save the results for any pay period needed, without having to update the control record. There’s no problem with having such a schema around, since the payroll driver does not save payroll results from a schema that ignores the control record in a production system. For examples, I will show you how to create two schemas – ZUA0, which will be used in production and will check the control record, and ZUAT, which ignores the control record and is used for testing purposes only.

First, create a copy of SAP’s schema UIN0 and name it ZUA2. In the schema editor (transaction PE02) enter schema UIN0, and click the copy button, or Schema>Copy in the menu. Enter ZUA2 for the To schema. Then edit ZUA2 and make the CHECK ABR line executable by removing the asterisk in the D column. (See Figure 2.) The CHECK function is commented out by SAP in the standard schema, so you uncomment it here for use in the main ZUA0 schema.

Figure 2 Making the CHECK ABR line executable

Now copy the SAP-standard schema U000 to ZUA1 and comment out the initialization schema UIN0 (Figure 3).

Figure 3 Comment out the initialization schema UIN0

In the schema editor, create the production schema (don’t copy it from anything) in my example ZUA0. Be sure to check the Schema can be executed checkbox. (See Figure 4.) Only executable schemas can be entered into the payroll driver selection screen.

Figure 4 Check the Schema can be executed checkbox

The production schema ZUA0 is a simple one, just two lines. (See Figure 5.) First, you call the initialization schema, and then you call the main calculation schema ZUA1.

Figure 5 Schema ZUAO

Copy schema ZUA0 to your test schema ZUAT. (See Figure 6.) You want ZUAT to ignore the control record, so have it use schema UIN0 for initialization. Remember that CHECK ABR is commented out in UIN0. Therefore, both the production and test schemas now use the same calculation logic in schema ZUA1 – which keeps them in sync.

Figure 6 Copy schema ZUA0 to test schema ZUAT

Your custom rules for these examples will go in a copy of schema UAP0. Copy UAP0 to ZUA3 and add lines for each of the five examples. (See Figure 7.) Edit schema ZUA1 to COPY ZUA3 instead of COPY UAP0 (not shown).

Figure 7 Add lines for each of the five examples

Schema and Rule Documentation

Creating Documentation Objects

Many customizing objects in Payroll can be documented online in SAP. The documentation is added to a transport so that it can be migrated to each client in the development, QA, and production environments. There are three ways to document an object online in SAP.

When changing schemas and rules, you can go directly to the Documentation section at the first screen of the editor. Or, while editing, use the Goto>Documentation menu. Either method takes you to an editor. The editor shown in Figure 8 is from the Enterprise release, and the appearance and functions can change from one release to another. Rule ZUA0 has no documentation.

Figure 8 Editor from the Enterprise release

Typical documentation might look like what is shown in Figure 9. Another U2 heading was added for Modification History.

Figure 9 Modification History header added

When modifying wage types, constants, and other data via views in transaction SM30 or the IMG, click on the blue i or Info button for documentation. The current documentation is brought up in display mode. Click on the edit button or press F5 to maintain it.

Transaction PDSY is a universal way to access all this documentation, regardless of where it comes from. Via PDSY, you can view and edit documentation, using the same editor, for many different objects. Early releases of R/3 used report RPDSYS00 to view and maintain documentation, but it has been replaced with transaction PDSY. While RPDSYS00 may continue to exist, you cannot be assured it is showing you the most recent documentation.

Document the ‘Why’

Each rule, schema, wage type, and constant can be documented online. Click on the Goto menu and select Documentation. From there, you can enter documentation on why you are making the changes, reference the transport it is assigned to, and perhaps enter other change management information (i.e. issue number, ticket number and so on). The critical part is to define why you are making the change, not just saying what the rule does. Most people who have to come behind you to modify the rule can see what the rule is doing, but may not know why it was done a certain way or if there are other dependencies in the schema. This sort of documentation requires very little effort, and saves much time in the future.

Expanding the Schema and Rules

Report RPDASC00 can be used to pull all the COPY schemas and rules into one list. This is very useful when you are looking for certain things in the schema – for example, where is wage type 0COL used? Running the report as shown in Figure 10 lists all schemas, sub-schemas, rules, and sub-rules for the main schema ZUAT.

Figure 10 Report for main schema ZUAT

Running the Payroll Driver

The payroll driver can be run a number of different ways. From the payroll menu for a specific country, select the Payroll>Start payroll option. Or use transaction PC00_Mxx_CALC, where xx is the country identifier (or MOLGA). The payroll driver can also be executed from transactions SE38 and SA38. Any way you go, this selection screen comes up (using U.S. payroll and the test employee as an example). (See Figure 11.)

Figure 11 Payroll driver selection screen for the United States

If you are using the schema ZUA0 for production payroll, the payroll period is always left at Current period unless you are only running simulations, which tells the payroll driver to get the current pay period from the payroll control record. If you use the test schema ZUAT, you could select Other period and then enter whatever period and year you want to run, and save those results (only in a non-production system). The payroll area in this section is required and tells the payroll driver which payroll area to use for deriving the current period, the period begin and end dates, and other payroll area-related data.

The selection section specifies which groups of employees you include in the payroll run. The payroll area entered here determines which ones are included in the payroll run. These payroll areas need to have the same setup as the one entered at the top of the screen – the same period definition and pay dates, for example.

General program control is used to tell the payroll driver how to run the payroll. Off-cycle payroll uses various reason codes, and those codes can be entered here. If running an off-cycle payroll, you specify the type of payroll and the date of that payroll in the Off-cycle payroll line. The schema line specifies the main schema to use for the calculation. If you want to force a payroll run to go back to a certain date and recalculate everything since then, that date is entered in the Force retro.accounting as of field. And finally, there is an option for a test run – also known as a simulation run.

Each payroll function and operation has the ability to put additional diagnostic information in the payroll log. For testing payroll, it is good to have the log shown. In a production payroll, showing the log for a whole payroll area will severely affect system performance. The log requires a lot of temporary storage and significant processing resources. If the Display log for time management additionally is selected, then you will be able to jump from the payroll log into the day processing (DAYPR function) part of the gross payroll schema UT00. Otherwise, that part of the log is not generated. Display variants can be created to customize the way the payroll log is displayed, and if one has been defined you can select it in the Display variant for log line.

Finally, the remuneration statement parameters are used to define which, if any, HR Form is displayed at the end of the payroll calculation. If a form is specified here and the log is not displayed, then the payroll driver displays the results via that HR Form. If the log is displayed, it first displays the log but also gives you a button at the top to display the HR Form.

Reading the Payroll Driver Log

The payroll log varies from one release to another and from one country to another. It can also vary from one customer to another depending on how the schemas were customized. For these examples, the payroll log follows the standard schema U000 very closely, on the Enterprise release. (See Figure 12.)

Figure 12 Payroll log in Enterprise

The log tells you that one employee was selected, and one employee was successfully calculated. The number of periods calculated may be more than the number of employees, since it counts the current and retrocalculated periods. Employees rejected from payroll would be counted in the Rejected line. The payroll driver rejects employees for two primary reasons – a lack of basic and consistent master data, and customization errors.

Each node can be opened to view deeper levels of processing, until you get down to a particular function and/or rule. To get to my example, you expand the nodes to the point shown in Figure 13.

Figure 13 Expand the nodes

For the PIT function and rule ZUA8, you can see the Input, Processing, and Output sections. These sections vary by function and operation, but are vital to testing and troubleshooting. If you double-click the PIT function, the payroll driver displays the contents of the input, processing, and output sections together in one list. Or you can double-click any one section to see its contents alone. Likewise, you can further expand each section to see individual components – in this case, wage types.

In many of the detailed lists, you can see two icons – a green plus sign with a down arrow and a red minus sign with an up arrow (Figure 14). These icons control the level of detail that is displayed in the list. Click the green plus to see more detail and the red minus to see less.


Figure 14 Green and red icons control level of detail

Understanding Which Wage Types Are Processed

A rule can also filter wage types, or it can process all wage types. It can filter by employee-subgroup grouping and by wage type. This is an attribute of the rule, and different logic can be executed for each set of filtered wage types. In Figure 15, you tell the editor you want to edit the section of the rule that will process wage type 0BAS for all employee subgroup groupings. To see all the various wage types a rule is set up for, click the overview button once you are editing the rule. The various sections can be managed by the Edit>ES Grouping wage or time type menu path inside the rule. If the employee subgroup grouping or wage type are set to asterisks, then they are valid for all values.

Figure 15 Select the section of the rule that will process wage type 0BAS

The rule’s treatment of wage types is also affected by how it is called by the function. The rule gets its wage types from the function, so the function controls what the rule can process. Parameter 2 has the following values:

  • GEN – Only access the ‘****’ wage type section of the rule.
  • Pxx – Like GEN but brings along the value of the processing class ‘xx’.
  • Exx – Same as Pxx except for evaluation classes.
  • (blank) – Access the section of the rule that corresponds to the current wage type

Parameter 3 can have two values:

  • NOAB – Only access the ‘*’ employee subgroup grouping section of the rule.
  • (blank) – Access the rule specifically for each employee subgroup grouping

The employee subgroup grouping for personnel calculations rules is maintained via view v_503_b.

Example 1 – Calculating a COLA Wage Type

The first example multiplies wage type 0BAS by 0.15 and puts the result into wage type 0COL. Figure 16 shows the IT before rule ZUA1.

Figure 16 IT before rule ZUA1

Figure 17 shows the processing section for rule ZUA1, showing calculation done on wage type 0BAS.

Figure 17 Processing section for rule ZUA1

See Figure 18 for the IT after rule ZUA1 was processed, showing the new wage type 0COL with the same A and AP splits as wage type 0BAS, and 0.15 in the NUM field to reflect the percentage used in calculation.

Figure 18 IT after processing of rule ZUA1

Example 2 - Restricting COLA to Specific Groups of Employees

Rule ZUA3 shows how to restrict COLA based on personnel area and employee subgroup. The calculation is the same – 15 percent of wage type 0BAS is put into wage type 0COL. The IT is the same as rule ZUA1, both before and after processing. The difference is in the processing section (Figure 19).

Figure 19 Processing section for rule ZUA3

If the employee is in personnel area ACAF, then you look at which employee subgroup they are in (OUTWP operation with the PERSB option). If they are in employee subgroup PS, then you calculate COLA.

For employees who are not in personnel area ACAF, or are in ACAF but not employee subgroup PS, you perform the ADDWT * operation. This copies wage type 0BAS from the header row to the IT. If you didn’t do this, that wage type would be dropped from the payroll calculation at this point.

Example 3 - Bracketed Calculations & Flat-Amount Override

The third example shows how to use the AMT operation to make decisions based on a wage type’s value. A nested decision structure is used calculate COLA with various rates. If wage type 0COL already has a value then you keep that amount instead of doing the calculation. Since you ran out of room in the variable key in rule ZUA4, you break the logic into two rules, calling rule ZUA5 from ZUA4 when needed. The IT before processing is the same as in the previous examples, but the processing is significantly different (Figure 20).

Figure 20 Processing using AMT operation

Notice how the PIT function starts with rule ZUA4, branches to ZUA5 and then returns. When wage type 0COL is entered via infotype 2010, the rule’s behavior changes. The IT before processing now has 0COL in it (Figure 21).

Figure 21 IT with 0COL

The processing section now sees 0COL and simply passes it on to the outgoing IT table (Figure 22).

Figure 22 Outgoing IT table with 0COL

Notice that if wage type 0COL is entered for someone who is not in personnel area ACAF and employee subgroup PS, then it would be paid anyway. Rules ZUA4 and ZUA5 are processed only for wage type 0BAS. So if wage type 0COL existed in the IT before this rule, it would simply be passed on to the next function. This can be restricted by customizing views v_511_b, v_503_g and v_001p_k so that 0COL cannot be entered for this combination of personnel areas and employee subgroups.

Example 4

Hard-coding amounts and wage types into rule is a bad practice. Example 4 is the same calculation logic as Example 3, but the amounts are moved into constants, and use a processing class to specify the COLA wage base.

Table t511k, or view v_t511k, holds payroll constants. These constants are date-effective, and are read with the end-date of the pay period being calculated.

First you set up the new processing class. For customer-defined processing classes, start with 99 and work down. For this case, use processing class 90. In the IMG, go to the section for processing and evaluation classes (Figure 23).

Figure 23 IMG section for processing and evaluation classes

Execute the Maintain processing classes and their specifications item, and create processing class 90. Note that you can click on the blue "i" icon to document the processing class (Figure 24).

Figure 24 Click on the blue "i" icon to document the processing class

Select the processing class 90 row and then double-click on Processing class specifications. Here is where you define each value of processing class 90 (Figure 25). You can also document each value. Then go to view v_512w_o to set wage type 0BAS processing class 90 equal to 1.

Figure 25 Set wage type 0BAS processing class 90 equal to 1

Now you create the constants in t511k (using transaction sm30 and view v_t511k). Each constant can be documented (Figure 26).

Figure 26 Creating constants

Rule ZUA3 also changes since you now have to execute a rule for a specific processing class. Use the P90 value for parameter 1 (line 150). (See Figure 27.)

Figure 27 Use the P90 value for parameter 1 (line 150)

When payroll runs, the processing section for rules ZUA6 and ZUA7 look much the same as before, except you see constants and processing classes (Figure 28).

Figure 28 Processing section for rules ZUA6 and ZUA7 with constants and processing classes

Example 5

The last example involves the handling of wage type splits. Some of the splits have documentation, others don’t. When viewing the RT table with the pc_payresult transaction (or the Display Results option in the Tools menu in Payroll), select a split value with your cursor and then press F1 for help. This gives you the full name for the split indicator. Some documentation is also available in transaction PDSY, using operations ELIMI and SPLIT. See Table 2 for common split indicators.

Table 2 - Common Split Indicators

Split indicator

Links to table in payroll results

Description

A

N/A

This is the ES grouping for the wage type, and it is matched up to an ES grouping section of a payroll rule for processing

AP

WPBP

Table WPBP holds basic data from infotypes 1, 7, and 8.

C1, C2, C3

Country-dependent

This varies by country, but it is typically used to link a wage type to tax authorities. In the U.S., split C1 links the wage type to a tax authority in table TAX

KoRe

C1

Cost assignment overrides can be entered for wage types and time data, and that override data is stored in table C1.

vTvn

V0

The variable assignment type (vT) and number (vn) link a wage type to table V0, and the purpose varies per country. In the U.S., this is the link to a benefit plan.

Table 2 Common split indicators

In the article in the August/September 2003 issue of HR Expert, I gave an example of an employee changing cost centers in the middle of a pay period. This causes wage type 0BAS to split – allocating a certain amount to each cost center via the AP split. The challenge, though, is to calculate COLA for each split value, based on the whole-period amount of 0BAS. To do this, you create another wage type to hold the whole-period amount. When you cumulate to that wage type – 9COL – you eliminate the splits, and that is what causes it to store the amount for the whole period. By using 9COL and processing class 90, you can now have multiple wage types cumulate to the COLA wagebase, which is more realistic.

The other thing you did was to move the 0COL wage type from infotype 2010 to infotype 14. This was so that you could allocate the 0COL wage type across the multiple splits. Infotypes differ on how they work with splits. (See Table 3.)

Table 3 – how Infotypes 2010, 15 and 14 handle splits

Infotype

Split Handling

2010

Allocates the AP split based on whatever day it falls within the pay period. For example, the pay period is Jan 16 to Jan 31, and it splits on Jan 20. So Jan 16 to Jan 19 is AP split = 01, and Jan 20 to Jan 31 is split AP=02. If the infotype 2010 wage type is dated Jan 19, it will be assigned to AP split 01; if infotype 2010 is dated Jan 20 it is assigned to AP split 02.

15

When read into payroll the AP split is eliminated, so its AP split is blank. For accounting and reporting purposes, it will be assigned to the last organization assignment (table WPBP in particular), but for payroll operations it is not associated with either split.

14

If processing class 10 is set to something other than zero, then it will be split across the pay periods. Otherwise it is handled like infotype 15. So if there is an AP split in the period, infotype 14 will create multiple wage types in the IT – one for each AP split.

Table 3 How infotypes 2010, 15, and 14 work with splits

The behavior of each infotype can be customized in the payroll rules that are processed when functions P2010, P0015, and P0014 are executed. The logic listed in Table 3 is the standard logic from SAP (for the U.S.) – it could be customized in your system. So to get COLA in my example to work for splits, I moved 0COL to infotype 14 and set its processing class 10 to a 1. In this case, processing class 10 is used to tell payroll to allocate wage types across payroll splits.

Now, instead of cumulating the COLA wage base to wage type 9COL, you could cumulate it into a payroll variable. This is similar to a wage type, but it is not stored in the payroll result. Instead of doing ADDWT 9COL, you would do ADDWT&9COL. The "&" adds it to the ‘variable’ table VAR. To retrieve the value of the variable, you would do AMT=& 9COL. There are good and bad points with variables. The good point is that they are easily created dynamically in the payroll rules. The bad parts are that they do not have splits on them so you can not track values per split indicator, they are not stored in the payroll result so it makes auditing and explaining calculations more difficult, and if you do not clear them (ZERO=& 9COL for example), then the values from one gross-to-net loop flow into the next loop.

Period 2 had a split in it – a new event (infotype 0000) was processed on 1/20/03. Base pay was pro-rated, giving two wage types 0BAS to deal with (Figure 29).

Figure 29 0BAS with two wage types

In the processing section of rule ZUA8, you can see that it was called once for each 0BAS (Figure 30).

Figure 30 Processing section of rule ZUA8 called once for each 0BAS

For each of those executions, the same logic is performed. First, check to see if the current wage type has a processing class 90 of 1. Then, check to see if the employee is in a valid personnel area and employee subgroup. If it passes those two tests, then it first passes the current wage type along into the output – you don’t want to lose the base pay wage types. Eliminate all the splits and add the wage type to the output as 9COL. Wage type 9COL then has no splits for the whole pay period, and holds the sum of all wage types whose processing class 90 equals 1. (See Figure 31.)

Figure 31 Wage Building wagetype 9COL

You can see that even though 0BAS had splits, wage type 9COL in the resulting IT does not have splits, and represents the sum of the two (Figure 32).

Figure 32 IT representing the sum of the splits

Now that you have the whole-period amount for the COLA wage base, you can process COLA for each of the wage base components. Rule ZUAA is also processed for all wage types that have processing class 90 equal to 1. In this case, that is the two wage types 0BAS. Each one is processed as shown in Figure 33.

Figure 33 Processing of 0BAS wage types

First, set the amount equal to 0COL to see if there is an override COLA amount. The AMT operation looks for wage type 0COL in the IT where the split indicators in the IT are the same as in the header of the IT. So wage type 0BAS is in the header with an AP split of 01. It looks for wage type 0COL with a split AP of 01 in the IT. This is why you read 0COL into the IT via infotype 14 and processing class 10 = 1.

If the amount is equal to zero, then you don’t have a 0COL wage type. Now, eliminate the splits on 0BAS in the header row, and go look for 9COL in the IT. If you find 9COL, then test the amount to see what wage bracket you fit into. Then restore the original splits and reset the amount in the header back to the original amount – i.e., from the 9COL amount to the 0BAS amount. Now you are back to the original 0BAS in the header row. Multiply that amount by the COLA rate (constant ZR003) and create wage type 0COL with the result. Wage type 0COL in this case has all the same attributes – including the split values – as wage type 0BAS. So the COLA amounts are split and allocated in the same manner as the wage types making up the COLA wage base (Figure 34).

Figure 34 COLA amounts split and allocated in the same manner as the wage types making up the COLA wage base.

Steve Bogner is managing partner at Insight Consulting Partners and has been working with SAP HR since 1993. He has consulted various public, private, domestic, and global companies on their SAP HR/Payroll implementations; presented at the SAP user’s group ASUG; and been featured on the SkyRadio Network program regarding SAP HR. You may reach Steve via email at sbogner@insightcp.com.

SCHEMAS, FUNCTIONS & WAGETYPES

SCHEMAS AND FUNCTIONS

In SAP Payroll, functions provide the high-level logic for payroll calculations. Functions perform general processing – such as calculating payroll taxes on a given set of wages, reading wagetypes from specific infotypes, calculating benefits premiums, and storing the results of the payroll calculation. There are dozens of functions in SAP payroll, some are country-specific and others are not. Each function is defined and documented via transaction PE04; you can also view the function documentation via transaction PDSY in releases 4.5 and greater, or with report RPDSYS00 in earlier versions.
In SAP HR terms, a payroll function is not the same as an ABAP function. A payroll function does consist of ABAP code, but it is not executed in the same way an ABAP function would be. Payroll functions are executed within a schema by the payroll driver program (let's assume RPCALCU0).
A schema is just a collection of functions executed in a specific order – each one passing its results on to the next. Schemas are always created and edited via transaction PE01, but are actually stored as a collection of rows in tables T52C0 (SAP standard schemas) and T52C1 (customer-created schemas and modified SAP-standard schemas). The payroll driver reads the lines in T52C0/T52C1 and executes the functions one by one.
So how do we make the leap from a payroll function stored in a table to the execution of ABAP code to get the work done? In transaction PE04 you can see the ABAP code associated with every function. The function name in the schema correlates to an ABAP form – for example payroll function WPBP maps to the ABAP form 'fuwpbp'; function USTAX maps to form 'fuustax'. So when the payroll driver is executing the schema, it takes the function name from the current row in schema, puts an 'fu' on the beginning of the name, and then does a 'perform' statement on it. It's a very simple and elegant design.
SCHEMAS AND FUNCTIONS

In SAP Payroll, functions provide the high-level logic for payroll calculations. Functions perform general processing – such as calculating payroll taxes on a given set of wages, reading wagetypes from specific infotypes, calculating benefits premiums, and storing the results of the payroll calculation. There are dozens of functions in SAP payroll, some are country-specific and others are not. Each function is defined and documented via transaction PE04; you can also view the function documentation via transaction PDSY in releases 4.5 and greater, or with report RPDSYS00 in earlier versions.
In SAP HR terms, a payroll function is not the same as an ABAP function. A payroll function does consist of ABAP code, but it is not executed in the same way an ABAP function would be. Payroll functions are executed within a schema by the payroll driver program (let's assume RPCALCU0).
A schema is just a collection of functions executed in a specific order – each one passing its results on to the next. Schemas are always created and edited via transaction PE01, but are actually stored as a collection of rows in tables T52C0 (SAP standard schemas) and T52C1 (customer-created schemas and modified SAP-standard schemas). The payroll driver reads the lines in T52C0/T52C1 and executes the functions one by one.
So how do we make the leap from a payroll function stored in a table to the execution of ABAP code to get the work done? In transaction PE04 you can see the ABAP code associated with every function. The function name in the schema correlates to an ABAP form – for example payroll function WPBP maps to the ABAP form 'fuwpbp'; function USTAX maps to form 'fuustax'. So when the payroll driver is executing the schema, it takes the function name from the current row in schema, puts an 'fu' on the beginning of the name, and then does a 'perform' statement on it. It's a very simple and elegant design.

WAGETYPES

In a broad sense, a wagetype simply holds a piece of data – a rate, number, and/or amount. But more specifically, a wagetype has dozens of attributes that control how it is manipulated and processed. In the end though, it ends up as an object in the payroll results database that stores a rate, number, and/or amount.
The most typical use of a wagetype is to store the amounts of earnings, deductions and taxes in an employee's paycheck. A person's base pay is stored in a wagetype, the amount of their United Way deduction is stored in a wagetype, and their taxable wages & taxes are stored in wagetypes. Wagetypes, as the primary data element for employee paychecks, are also mapped to FI/CO accounts to record the debits and credits resulting from the paycheck and reported on the W-2 and other tax forms.
Wagetypes can also be used to store statistical data – such as the number of hours worked in a pay period, the average weekly wages for the past six months, or the amount of wages eligible for a profit sharing calculation. Wagetype attributes are stored in several tables, but the central table is T512W. Much more time will be spent on various aspects of T512W.
There are three categories of wagetypes – model, technical, and user. Model wagetypes are delivered by SAP for customers to use as guidelines for creating their own wagetypes. They always start with a letter and SAP may add, delete or update them in system upgrades or HRSP's. Technical wagetypes always start with the '/' symbol, and are delivered by SAP. They are intended for very specific standard processing in payroll, and while you can modify them, SAP may also update them during upgrades or HRSP's. So if you ever (I mean EVER) change a technical wagetype, check it after each upgrade or HRSP to make sure it still has the attributes you want. And never delete a technical wagetype. User wagetypes always start with a number – and these are wagetypes that SAP does not change during upgrades & HRSP's. OK, SAP rarely changes them in upgrades and HRSP's. User wagetypes are for all the company-specific payroll payments and deductions.
RULES AND OPERATIONS

A long-time client of ours once created a screen-saver message that stated 'Payroll Rules!'. Those of us who were experienced SAP Payroll analysts or consultants immediately saw the double meaning, and corny humor, in that message. Rules contain the most basic logic used in SAP Payroll. Where a schema is a collection of functions, a rule is a collection of operations. An operation is a very basic piece of logic that is used, mostly, to manipulate wagetypes. For example, operation MULTI multiplies the number and rate fields of a wagetype to determine the amount to pay an employee. Operation OUTWP retrieves specific data about an employee so that another operation can make a decision on how to process it. For example, if the work contract on infotype 1 is UA then do 'x', if it is UB then do 'y', otherwise do 'z'.
Operations can also be viewed in transactions PE04 and PDSY, and are edited with transaction PE02. Where a function's ABAP equivalent form starts with 'fu', an operation's ABAP form starts with 'op'. For example, operation MULTI would have an ABAP form 'opmulti'. Rules, like schemas, are stored in a table – rules are stored in T52C5.
The more senior SAP consultants who have been working with computer systems for many years often find similarities between payroll rules and programming mainframe computers in Assembly language. While there is nothing fancy about operations, when used correctly together they can be very powerful.
Hopefully we've presented a good but brief overview that makes sense. In our next SAP Payroll Technical Basics article we will get into more detail on the common functions used in SAP's payroll schema.
Central Functions in the Payroll Schema
Previously we presented an overview of the foundation of payroll processing - the basic structure of schemas, rules, function and operations. Now let's take a look at the major functions in the payroll schema.
Functions can have up to four parameters, and usually the SAP documentation does a good job telling you what each parameter does. Documentation for functions and operations can be found via transactions PDSY or PE04.
COPY This is the same as 'include' in ABAP and other programming languages. COPY just inserts the schema contained in parameter 1 when payroll is executed. Good programming style and good schema configuration style are basically the same - put commonly used logic in an 'include' so that it can be used in several places and to improve readability.
BLOCK As of release 4.0 the schema log is organized in a collapsible tree structure. BLOCK BEG starts a node and BLOCK END ends the node. Everything between BEG and END is contained within the node. BLOCK BEG/END can be nested several levels deep. Again, place the BLOCK BEG/END functions appropriately to make the log easy to read.
IF/ELSE/ENDIF There are two ways to specify the true/false condition for an IF function. SAP has several built-in conditions that you can use in parameter 2 (IF NAMC in schema U000). You can also specify a custom rule in parameter 1, and in the rule perform whatever logic you want. In the rule you use operation SCOND to set the true/false switch for the IF function.
Pxxxx The payroll driver & schema read and process data from many infotypes. The common way of doing this is with infotype-specific functions - named as 'P' and the four-digit infotype number. So, P0014 reads and processes data from infotype 14, P0168 processes life insurance plans from infotype 168 and P2010 reads in additional payments from infotype 2010. Many of these functions, but not all, allow you to futher refine the processing with a payroll rule. Schema UAP0, for example, shows that P0014 is processed futher by rule U011. Function P0168 is one of those that does not use a rule (in some older releases it does) - you specify options in parameter 1 instead (see schema UBE1).
Some infotypes are used in payroll, but do not have a Pxxx function. Examples include infotypes 207, 208, 209 and 210 which are all read and processed in the main tax function USTAX. Infotypes 0, 1, 7, and 8 are processed by function WPBP.
PIT PIT is an acronym for Process Input Table, and is one of the most used and most powerful functions in payroll. When wagetypes are read into payroll by the Pxxx functions, they are stored in an internal table called IT - Input Table. PIT loops through that table and applies logic contained in rules. So for each wagetype in the IT, it will apply the logic from a rule.
The goal of PIT is to move wagetypes out of the IT and into the RT - Results Table. Most often, the rules called by PIT will change some attributes of the wagetype and then transfer it from the IT to the RT. The wagetype can also be left in the IT and even moved to other tables. We'll cover those possibilities when we reiew how operations work.
A good example of PIT is in schema UAL0 - PIT X023. When the payroll driver gets to this point in the schema, PIT will look at each wagetype in the IT, and rule X023 tells it to do certain things depending on the wagetype's value in processing class 20. Values 3, 4, 5, 6, 9 and B will move the wagetype to the RT, while values 1, 7, and 8 leave it in the IT. Value 2 has no operation, essentially eliminating the wagetype from the IT.
PRT PRT is short for Process Results Table. Although most wagetype processing happens via PIT, there are several occasions where you want to process the wagetypes that have already been transferred to the Results Table (RT). PRT work much the same as PIT, looping through the RT and applying logic from a rule.
In schema UTX0, PRT is used to process tax wagetypes that are already in the RT. Function UTX0 (US tax function) returns its wagetypes directly to the RT, so any processing on tax wagetypes has to be done with a PRT function.
ACTIO The ACTIO function processes a payroll rule, but it does not loop through a wagetype table. Instead it can loop over the different workplace/basic pay records and process the rule for each one. For example, suppose the employee had two infotype 1 records for the current pay period. ACTIO would have two records to loop through.
Schema UTX0 again has a good example of ACTIO using rule UWH1 to calculate the number of working hours in the pay period.

Commonly Used Operations in SAP Payroll
Previously we presented an overview of the foundation of payroll processing and information on the central functions in the payroll schema. So you know the structure of payroll processing and the major functions - now we will look at payroll operations, where most of the real work gets done. This subject area is very large and we are only scratching the surface here.
Like functions, documentation for operations can be found via transactions PDSY or PE04. Operations can be placed in two broad groups - those that make decisions and those that manipulate wagetypes. Some of them fit into both groups.
Manipulating Wagetypes
Working with wagetypes in a rule is sort of like working with internal tables in ABAP. The function that called the rule (PIT, PRT, P0014 or whatever) loops through the table, placing each row, one at a time, in a 'header' space. You work with the wagetype in that header space, and when finished add it back to the table.
MULTI, DIVID These operations let you multiply two fields of a wagetype and store it in a third. The fields you can work with are AMT, RTE and NUM. MULTI RNA would multiply the rate by the number and store the result in the amount field. DIVID ANA would divide the amount field by the number and store it back in the amount field.
NUM, RTE and AMT These are very basic and powerful operations that manipulate the content of their respective fields. The F1 help documentation is very useful since there are so many ways to use these operations. On a basic level, you set values like NUM=1 or AMT=2.50 - though that it is bad practice to do this. Use constants instead - create a constant in T511K called ZNUM and then do NUM=KZNUM (set number field to the constant ZNUM). Since constants are date-effective and rules are not, this will give you more flexibility when the number has to change.
You can set the field of the wagetype in the header equal to the corresponding field of another wagetype - AMT=E9XXX sets the amount equal to the amount field of wagetype 9XXX in the RT. AMT< 9XXX sets the amount field to 9XXX in the IT only if it is less than what is already in the amount field (takes the minimum of the two values).
Finally, you can use arithmetic on the values. RTE*100 multiplies the contents of the rate field by 100 and stores it back in the rate field. AMT*KZNUM multiplies the amount by whatever is in constant ZNUM.
ADDWT So by now we've set the values of our wagetype using MULTI, DIVID, AMT, RTE and NUM. ADDWT transfers the wagetype in the header to some other table - enabling us to save all that work before the next wagetype goes to the header. The basic idea is that you transfer the wagetype to another table, with or without changing the wagetype number. ADDWTE* adds the wagetype to the RT without changing the wagetype number. ADDWTE9XXX transfers it to the RT and renames it to 9XXX. Again, the F1 help documentation will tell you all the tables that you can transfer to.
ELIMI and RESET Splits are attributes of wagetypes that link them to some other table in payroll. Sometimes you have to remove certain splits when doing work in a rule - that's what ELIMI does (ELIMInate splits). After you eliminate splits on a wagetype, within the same rule you can restore them with RESET. Generally you should avoid eliminating splits - it can lead to problems in pro-ration and reporting. So use with caution and test your work well.
FILLF This simple operation resets the value of a wagetype field. For example, FILLF A resets the amount back to what it was when the rule was first called.
So, here's how you would put these all together to calculate a deduction that is fixed percentage of base pay (there are several ways to do this, here's just one). Let's assume base pay is in the IT, the percentage is stored as a whole number in constant ZNUM, and you've made a rule that has a section for wagetype **** and for base pay, '0BAS' in this case. The deduction will be 4XXX. So in the schema we will do a PIT on rule Z001: PIT Z001. In the rule:
Wagetype ****: ADDWT * (if it's not 0BAS we just want to pass it on without changing it)
Wagetype 0BAS: ADDWT *, NUM=KZNUM, MULTI ANA, AMT/-100, ADDWT 4XXX (pass 0BAS on to the output table so we don't lose it, set the number field equal to constant ZNUM, multiply the number by the amount, divide the amount by -100 since we store the percentage as a whole number and we want deductions to be negative, and store the result as wagetype 4XXX)
Making Decisions
Many times we only want to take action if certain conditions exist - for example we only want to calculate deduction 4XXX for certain types of employees. For these cases, decision operations let us choose when to take that action.
Decisions put their results into what is called the variable key - think of this like a case statement with wildcards. If I put the company code in the variable key, then the line that has 1234 will execute for company code 1234, 2*** will execute for any company that begins with 2, and **** will execute for companies that match neither.
OUTWP This operation lets us make decisions based on various data elements in the WPBP table in payroll - roughly the infotype 0 and 1 data. There are many elements to look at, via the F1 help documentation. As an example, you could look at the company code via OUTWPCOMPY - this puts the contents of the company code field into the variable key.
VAKEY Like OUTWP this places certain data in the variable key - see the F1 help documentation for all the possibilities.
NUM, RTE and AMT Here they are again, as decisions. If I say AMT?0, it will compare the value in the amount field to zero and return either >, <, or =. Or you could compare it to a constant or another wagetype using the same concepts mentioned above.
VWTCL This operation returns the value of a certain processing class for the current wagetype. For example, VWTCL 93 places in the variable key the value of processing class 93. Rule X023 is a good example of how processing class values are used.
In our previous example we calculated deduction 4XXX for every person who had base pay wagetype 0BAS. Using OUTWP you could decide to calculate it only for people in certain personnel areas/subareas, or for certain employee subgroups for example. Let's say that you only want to calculate it when someone has entered wagetype 4XXX in infotype 14 or 15. Assume here that the wagetype is entered in the infotype with something required in the number field. Here are the steps you could do:
Wagetype 0BAS: ADDWT *, NUM= 4XXX, do a decision on NUM?0 and if = then do nothing, otherwise (the * condition) do NUM=KZNUM, MULTI ANA, AMT/-100, ADDWT 4XXX. Depending on how your wagetype splits are setup at this point, you might want to ELIMI R just before NUM=4XXX and RESET R before ADDWT 4XXX.
As mentioned earlier, this is just a scratch on the surface. When configuring payroll you can not focus exclusively on just one piece of the puzzle - understanding how all the pieces are related will lead to the best configuration. There are many ways you can combine functions, operations, processing classes, and constants. SAP has created a powerful and flexible configuration model for payroll. When used correctly it gets a lot of work done well, but when done incorrectly it leads to confusion and instability. So test and document your configuration well!

Function Creation - SAP

During the execution of payroll, 'Personnel Calculation Schema' (created using Transaction: PE01) is used to calculate the employee's salary. The schema comprises of funtions (created using Transaction: PE04), inorder to incorporate cutomer specific calculation routines during execution of payroll, SAP allows you to create payroll functions in customer namspace (Starting from Y or Z).

Step by Step creation of SAP Payroll Funcitons:

1) Follow the menu path
Human Resources>>Time Management>>Administration>>Tools>>Funtions/Operations
or transaction PE04. Enter a four digit name for e.g ZIABC, and press the create
button, enter the description. On creation the system proposes the name of
the routine use it, or enter a name of your choice by selecting the option 'Self-defined'.

2) During the execution of payroll some tables are filled with wage types and there amounts
to make these tables available to your routine enter the name of the table for e.g (RT or
CRT) in the input parameters, and to make the changes done to the data in the tables
avaiable to the payroll enter the name of the table in the Output parameters as well.

Input Parameters
----------------
Ctry Num Object Name
----------------------------------------------------------------
99 1 RT
99 2 CRT

and same shall be done in the Output Paramters if required.

3) Create an include in the program PCBURZ990 (using Transaction:
SE38), in which create a subroutine with the name supplied by SAP or the
name selected by you during Funtion creation,
in our case, it is FUZIABC.
Note: The program PCBURZ990 is in SAP Namespace, so an Access Key
will be required before you can proceed. But it will not be overwritten during any upgrade. *Example of the subroutine
*-------------------------

FORM FUZIABC.
*enter the code
ENDFORM.
4) After this activate the program the Funtion and add it in the schema used for payroll processing.

Getting started with SAP BW (BI)

As this is the first post in this blog, I would like (with your permission) to start with a personal note. I have been with Business Intelligence since year 2000. I worked on a plethora of tools, but never met a fascinating and complex tool like SAP Business Intelligence (aka SAP BW). After almost two years of working with BW on a daily basis, I can surely admit that moving into SAP BW was the wisest professional decision I made to date.

Why you should consider moving into SAP BW ?

Good question. And here’s why:

  1. SAP BW is interesting. Business Intelligence in general and SAP BW in particular spans both the functional and technical domains. No matter if you are a business savvy kind of fellow who’s into processes or a geek who’s into programming, you’ll have plenty to interesting tasks in the SAP BW field.
  2. SAP BW is lucrative. With that said, it is worth noting, that BW is a relatively mature tool, so the big majority of SAP customers already implemented it. Nowadays, BW projects are focused on either upgrading the system to higher versions or implementing reporting solutions for new functional domains.

How do I get started with SAP BW ?

Many people ask questions in the SDN forums about the best way to get started with SAP BW. As someone that got started two years ago, I would like to provide my two cents on this:

  1. Read Data warehousing books written by Ralph Kimball or Bill Inmon in order to familiarize yourself with the basic concepts of data warehousing. This is the foundation of the entire thing.
  2. Follow the SAP training materials on BW Data Warehousing, BW Reporting and BW Modeling. In case your company doesn’t fund training, propose them to fund SAP books instead. There are several books that can help you a lot when getting started. I have prepared an Amazon List that lists the most useful books I used in my BW learning process.
  3. After you have a solid BW knowledge, start to review the help.sap.com site.
  4. If you don’t have an SDN account, create one ASAP. SDN is an excellent one stop shop for all your SAP BW needs. Start to review SDN white papers (start with the BI Modeling white paper ), Webcasts, read the forums.
  5. Download the Netweaver 2004S SP11 ABAP Sneak preview. Setup is fairly easy (but make sure that your computer meets the hardware requirements). I recommend that you follow Manfred Lutz’s blog series on setting up NW 2004S ABAP Sneak preview. I wrote a quick how to guide that will help you to get started with your first BI data model. You can find it at:How to guide. More to come on that end :)
  6. Get familiar with the basics of ABAP programming. I recommend on two books that are indispensable here: one is Horst Keller’s ABAP Objects and the second is Dirk Herzog’s book on ABAP for BW (the best 85 bucks you will ever spend for a BI book).
  7. People ask about the importance of SAP Functional knowledge for the BI developer. Well, I think functional ECC knowledge is nice to have, however I would recommend to go deeper into SAP ECC functional domains once you are given your first assignment. Same goes for web programming. I don’t recommend that you start to polish your JavaScript, before securing your first assignment.
  8. Last but definitely not least is the certification question. Although I value certifications, I believe that practical experience and ability to think out-of-the-box, are more important. Bottom line: aim for an assignment, don’t waste your hard earned dollars in getting certified, as it rarely helps in finding your first gig.

That’s it, I believe you are ready to go. Good luck!