R/3 provides a variety of indirect valuation modules for determining the entry amounts for wage types. However, in many scenarios, the existing modules may not suffice and you may need to create your own. Moreover, these computed entry amounts are not stored in the same manner as other fields of an infotype. The handling of such data is done via a set of function modules. Learn about the steps required in creating your own customer-specific modules and the basic code that makes them accessible.
Key Concept
The HR module uses the indirect valuation technique for making users’ tasks easier. This technique provides numerous advantages. With direct valuation, the user enters the wage type as well the amount on the infotype screen. In indirect valuation, however, R/3 calculates the value automatically based on predefined formulas or criteria. Indirect valuation is best for computing complex formulas for determining the amount that should be assigned to a particular wage type while maintaining master data.
SAP R/3 provides a variety of indirect valuation modules to help users create error-free entries of allowances and deductions in the Personnel Administration (PA) submodule. The option of activating indirect valuation for a wage type relieves the users from calculating the wage-type amounts manually, which would waste a considerable amount of time.
For example, many allowances are based on percentages of the basic pay. In direct valuation, the user has to calculate the amount for each employee manually before making an infotype entry. Conversely, SAP does this automatically via indirect valuation. The more employees involved, the more time saved.
The problem starts when the criteria for the calculation of a wage-type amount are so complex that the standard modules cannot handle them. The only option left for you is to create an indirect valuation module of your own. This may be confusing for the HR developer, as the concept of these modules is based on Business Add-Ins (BAdIs), object- oriented extensions of user exits. HR consultants and ABAP programmers may also have difficulty developing their own modules since there is little relevant information in standard SAP documentation.
Moreover, users may ask for this computed amount to be displayed in their reports. Examples include the commonly used reports for company summary and list of allowances paid to employees. Most users (and functional consultants) have a common misconception that these indirectly valuated amounts are stored in database tables just like other fields of the infotype. However, they are computed at runtime based on the formulas and the information entered on the infotype screen.
Retrieving their values in programs may therefore be confusing. Unlike other fields of the infotype, R/3 does not even allow you to view the value of an indirectly valuated wage type through the Data Browser. You need to use special statements or function modules for accessing them.
I’ll explain the steps required to create your own indirect valuation module that will satisfy your customer-specific requirements. I will discuss what information related to indirectly valuated data is stored in infotype tables and the way in which it may be used to determine the actual wage type amount. Using a custom ABAP program, functional analysts who have the appropriate security and authorizations can access the indirectly valuated data by following the provided steps.
Before diving into the details, let’s consider an example. Say your company pays a certain allowance based on the grade of its employees. The formula involves a certain percentage of the basic pay that is entered by the user on the infotype screen. A constant amount is then added to the computed percentage value, which is $1,000 in the case of grade ABC and $2,000 for employees with grade XYZ.
This requirement calls for the creation of a new indirect valuation module. I’ll go through the steps that are required and explain the code that makes this possible.
Create a New Indirect Valuation Module
SAP R/3 Releases 4.5 to 4.7 allow you to create your indirect valuation modules via simple configuration settings. This configuration is stored in table T511IV_M. To create your own module, follow these steps:
Step 1. Follow IMG menu path Personnel Management>Personnel Administration>Payroll Data>Indirect Valuation and choose the Create Indirect Valuation Module option. This takes you to the maintenance view of the T511IV_M table that shows the existing indirect valuation modules in your system.
Step 2. Click on the New Entries button. This leads you to the screen in Figure 1. Enter a suitable name and description for your module, ZTEST
and New Indirect Valuation Module
in this example, and press the save icon.

Figure 1
Give a suitable name and text to the newly created module
Step 3. Follow IMG menu path Personnel Management>Personnel Administration>Payroll Data>Indirect Valuation>BAdI: Maintain Indirect Valuation Module. The screen in Figure 2 shows the existing implementations for the BAdI HR_IND_VAL.

Figure 2
Existing implementations of BAdI HR_IND_VAL
Step 4. Click on the create icon. A pop-up screen appears. Type a suitable name for your BAdI implementation, Z_MY_FIRST_BADI
in this case, and press Enter to see the screen in Figure 3.

Figure 3
Name the implementation of the BAdI
Step 5. Enter a suitable short text for your BAdI implementation. In the Type section of the Attributes tab, enter the name of the indirect valuation module created in Step 1 in the Filter values field (in this case, ZTEST
).
Step 6. Click on the Interface tab to view the name of the method that incorporates the functionality. In the case of the indirect valuation scenario, it is DO_INDIRECT_VALUATION.
Step 7. Double-click on the method name DO_INDIRECT_VALUATION. This takes you to the editor for entering the method code. Write the appropriate code in the method and then activate it, which I explain in the “Write the Code” section.
Step 8. Use the wage-type characteristics to assign the indirect valuation module to the wage type for which you want the indirect valuation option to be activated. The wage-type characteristics screen allows you to specify the properties of a wage type such as the permissible input combination (number or amount) and the minimum and maximum values. The indirect valuation module is also entered on this screen. Follow the IMG menu path Personnel Management>Personnel Administration>Payroll Data>Recurring Payments and Deductions>Wage Types>Check Wage Type Catalog>Check Wage Type Characteristics.
Note
Since BAdIs are object-oriented extensions of user exits, some coding statements are not applicable in the context of object-oriented programming.
The DO_INDIRECT_VALUATION Method Code
The code of the DO_INDIRECT_VALUATION method is executed each time the user maintains the relevant wage type (via transaction PA30) in the infotype entry screen and presses Enter or click on the Save button. The method interface provides a lot of useful information that is related to the employee and the wage type record in question. Effective BAdI programming lies in using the available information in the best possible manner. Use your business process knowledge to determine what criteria or conditions exist and where (in what infotype) they reside. Then use the available parameters to retrieve data that helps to formulate the given criteria.
Your business process may demand that a certain formula for wage-type computation be applicable when a particular set of conditions is true. The available information may be used to determine whether such conditions exist or not. They may help you in writing the code that best fulfills your users’ requirement. For example, your business may require that a certain formula for calculating a particular wage-type amount is applicable only to those employees that belong to a certain grade.
It is a good idea to become familiar with the parameters (information) that are available when the method is called. Table 1 shows the parameters of the DO_INDIRECT_VALUATION method. Let’s go through some of the important parameters that this method provides.
MODULE_SPEC |
Module variant |
MOLGA |
Country grouping |
TCLAS |
Transaction class (HR master/applicant data) |
PERNR |
Personnel number |
INFTY |
Infotype number |
LGART |
Wage type |
BEGDA |
Start date |
PNNNN |
Current infotype record |
LGART_TAB |
Wage type table |
VALUATION_INPUT |
Entry values |
VALUATION_OUTPUT |
Values to be output |
|
Table 1 |
Parameters of the DO_INDIRECT_VALUATION method and their meanings |
MODULE_SPEC: For each module, you may define a number of variants, each of which implies a slight change in the criteria or formula for the wage-type valuation. The wage-type characteristics table provides a variant field for assigning the relevant variant to a particular wage type, along with the module field (see step 8 of previous section). The MODULE_SPEC parameter specifies the variant that is assigned to the wage type in question.
PERNR: The PERNR field contains the number of the employee whose master data is being maintained. You may use the personnel number field to read additional information stored in all infotypes of the given employee.
INFTY: This four-character field denotes the infotype in which the user is creating the entry; for example 0014, 0015, etc.
VALUATION_INPUT: The user may or may not enter a number on the infotype screen upon which the computation is performed. Any information that is entered by the user is made available at the time of method call via the structure VALUATION_INPUT. If the user enters any value on the number (ANZHL) field of the infotype screen, the number field of VALUATION_INPUT is populated with this value in order to perform wage type valuation.
VALUATION_OUTPUT: This is the final output structure. As the name implies, it contains the values that are required to populate the fields on the infotype screen, after performing the computation, such as wage type amount (BETRG) and currency (WAERS).
Write the Code
The following steps are all required to write the code, shown in Figure 4, for your BAdI implementation.
METHOD IF_EX_HR_INDVAL~DO_INDIRECT_VALUATION. DATA: VALUATION TYPE PADIV_VALUATION_STRCT. DATA: I0008 LIKE P0008 OCCURS 0 WITH HEADER LINE. DATA: SUBRC LIKE SY-SUBRC. DATA: LI TYPE I. DATA: TRFGR LIKE P0008-TRFGR, BASIC LIKE P0008-BET01. VALUATION = VALUATION_INPUT. CALL FUNCTION ‘HR_READ_INFOTYPE’ EXPORTING PERNR = PERNR INFTY = ‘0008’ BEGDA = PNNNN-BEGDA ENDDA = PNNNN-ENDDA IMPORTING SUBRC = SUBRC TABLES INFTY_TAB = I0008 EXCEPTIONS INFTY_NOT_FOUND = 1 OTHERS = 2 . DESCRIBE TABLE I0008 LINES LI. READ TABLE I0008 INDEX LI. TRFGR = I0008-TRFGR. BASIC = I0008-BET01. …………………… CASE TRFGR. WHEN ‘ABC’. VALUATION-AMOUNT = (( VALUATION-NUMBER / 100 ) * BASIC ) + 1000. WHEN ‘XYZ’. VALUATION-AMOUNT = (( VALUATION-NUMBER / 100 ) * BASIC ) + 2000. ENDCASE. …………………… VALUATION_OUTPUT = VALUATION. ENDMETHOD.
|
Figure 4 |
COMPLETE LISTING code |
Step 1. Access the data entered on the infotype screen. As already mentioned, your wage type calculation may or may not require the data entered (by the user) on the infotype screen. In case the entered information is required, the parameter VALUATION_INPUT is used. Declare a variable similar to the VALUATION_INPUT, as shown below:
DATA: VALUATION TYPE PADIV_
VALUATION_STRCT.
Then, populate this structure by the values contained in the structure VALUATION_INPUT as follows:
VALUATION = VALUATION_INPUT.
Step 2. Gather the relevant information for developing the formula. As already mentioned, a lot of useful information is provided by the method interface. This may be helpful in devising the conditions or checks upon which the wage-type computation criteria (formula) is based.
It may be possible that the values required for the wage-type criteria are allowances that are also indirectly valuated. In such cases, you may determine their values by using special function modules. (I’ll discuss this later.)
Step 3. Apply the necessary formula for wage-type calculation. The next step involves applying the relevant computation formula to determine the wage-type amount. This formula may involve the calculation of an amount based on the percentage of another allowance such as basic pay. Moreover, the calculation may or may not include the values entered on the infotype entry screen. A simple formula may look as follows:
VALUATION-AMOUNT = Basic * VALUATION-NUMBER / 100.
You may include checks based on the variants for your module. For example, you may have variants A and B for your module, each having a different calculation criterion as shown below:
CASE MODULE_SPEC.
WHEN ‘A’.
VALUATION-AMOUNT = Basic *
VALUATION-NUMBER / 100.
WHEN ‘B’.
VALUATION-AMOUNT = 2 * Basic * VALUATION-NUMBER / 100.
ENDCASE.
……………………
Step 4. Store the computed result in VALUATION_OUTPUT. Once you are done with the wage-type amount computation, the final step involves assigning the computed values to the VALUATION_OUTPUT.
VALUATION_OUTPUT = VALUATION.
After the executing the above statement, the contents of the structure VALUATION_OUTPUT is assigned to the corresponding fields of the infotype screen and displayed to the user.
Consider the indirect valuation example based on employee grade, mentioned at the beginning of the article. The code of the method in this case is shown in Figure 4.
The percentage entered in the number (ANZHL) field of the infotype screen is read into the structure VALUATION. Function module HR_READ_INFOTYPE is used to read the grade and basic pay of the given employee from infotype 0008. For simplicity’s sake, I assume that no multiple subtypes exist in infotype 0008.
A CASE
statement then runs the appropriate formula for the grade to which the employee belongs. Finally, the computed wage type amount is assigned to the structure VALUATION_OUTPUT for display to the user.
Points to Consider
Since the coding portion involves working in an object-oriented environment methodology, some ABAP statements (or constructs) that are applicable in normal reporting may not be allowed within the code of the DO_INDIRECT_VALUATION method. A simple example is the declaration of an internal table. The following statement is allowed:
DATA : MTTAB TYPE STANDARD TABLE OF MYTYPE.
However, the following style of table declaration is prohibited:
DATA : BEGIN OF MYTAB OCCURS 0,
FIELD1,
FIELD2,
END OF MYTAB.
While reading infotypes or time-dependent tables, avoid hard-coding dates. A device that programmers fall prey to is using the infinity date 99991231 while formulating SELECT
queries. Consider a scenario where infotype 0008 is used to calculate the value of an indirectly valuated wage type, such as:
…………………………..
SELECT * FROM PA0008 WHERE ENDDA EQ ‘99991231’.
…………………………..
The problem with this approach is that when the user tries to view an older (other than the latest) indirectly valuated wage type record of the infotype, the system always calculates the amount based on the latest information stored in infotype 0008, thus showing an erroneous result. Rather, the system should calculate the values based on the infotype 0008 record that is valid on the date of the current infotype record.
A better approach is to avoid using the infinity date (31.12.9999) in your SELECT
statements by replacing them with the start and end dates of the current infotype record, as shown below:
……………………………..
SELECT * FROM PA0008 WHERE BEGDA LE PNNNN-ENDDA
AND ENDDA GE PNNNN-BEGDA.
………………………………
For reusability and modularity purposes, you may prefer defining a function module within the method that carries out the computation of the amount for the wage type in question:
………………..
VALUATION = VALUATION_INPUT.
CALL FUNCTION ‘ZMYFUNCTION’
EXPORTING
PERNR = PERNR
LGART = LGART
CHANGING
AMOUNT = VALUATION-AMOUNT
CURRENCY = VALUATION-CURRENCY
NUMBER = VALUATION-NUMBER
UNIT = VALUATION-UNIT.
VALUATION_OUTPUT = VALUATION.
Troubleshooting Tips
If you try to create a wage type record and your method calculates a wrong amount, you need to check whether the formula specified in the DO_INDIRECT_VALUATION method is being executed correctly. Proceed as follows:
Step 1. Call transaction SE19. Type the name of the BAdI implementation created (in this case, Z_MY_FIRST_BADI
) in the Implementation field and click Display.
Step 2. Click on the Interface tab. Then click on the name of the method DO_INDIRECT_VALUATION. The code of your method appears.
Step 3. Place the cursor on the first line of the code written in the method. Set a breakpoint at the first statement by clicking the stop icon. Alternately, you may also write the statement BREAK
followed by the user name before the first statement (for example, BREAK JOHN
).
Step 4. Call transaction PA30 and choose the Create option. Enter the appropriate values and press Enter. The program stops in the debugging mode if you’ve set a breakpoint, as mentioned in step 3.
Step 5. Execute each line of the program by pressing F5. This allows you to monitor the values of the variables involved in the wage type computation, thus helping you track the cause of the error.
Read Indirectly Valuated Data
The data that is derived from indirect valuation does not reside in programs as do other fields of an infotype. The SAP R/3 system stores a zero (0.00) value in the amount field of the relevant infotype record. Moreover, the system also sets an indicator field INDBW in the database table PANNNN to I for that infotype record, indicating the presence of an indirectly valuated wage type. For example, the value of wage type 6204 is computed based on the number entered on the screen in the Number column of Figure 5, 20.00 in this case.

Figure 5
Data Browser entry for an indirectly valuated wage type
Whenever a user displays an indirectly valuated infotype record via transaction PA30 or PA20, the system calls the code of the DO_INDIRECT_VALUATION method to carry out computation and determine the relevant amount.
The problem starts when you need to fetch this data in custom programs and queries. In this case, simple SELECT
or PROVIDE
statements alone may not suffice. SAP provides a variety of function modules for this purpose (Table 2). You may use these function modules in order to fetch indirectly valuated data for wage type records stored in infotypes 0008, 0014, and 0015.
RP_EVALUATE_INDIRECTLY_P0008 |
Read basic pay infotype |
RP_EVALUATE_INDIRECTLY_P0014 |
Read allowances/deductions |
RP_EVALUATE_INDIRECTLY_P0015 |
Read one-time allowances/deduction |
RP_EVALUATE_INDIRECTLY_P0052 |
Read wage maintenance infotype |
|
Table 2 |
Function modules for accessing indirectly valuated data |
These function modules read the module name and variant assigned to a particular wage type and then execute the relevant method of the BAdI implementation to determine the wage-type amount.
Let’s see how your custom ABAP program uses the function module calls (Figure 6). Suppose that at a given point of the program, the header row of table P0014 contains the infotype row whose indirectly valuated data is to be accessed. For efficiency’s sake, use the field INDBW to run the code only for wage types that involve indirect valuation because you do not want to run the code otherwise.
IF P0014-INDBW EQ ‘I’. …………………………. DATA : BEGIN OF ITAB1 OCCURS 0, SEQNR(3), LGART TYPE LGART , OPKEN TYPE OPKEN , INDBW TYPE INDBW , ANZHL TYPE ANZHL , MODNA TYPE MODIB , MOD01 TYPE MODKO , BETRG TYPE WERTV9, WAERS TYPE WAERS , END OF ITAB1. ………………………………………… MOVE-CORRESPONDING P0014 TO ITAB1. APPEND ITAB1. ………………………………………… CALL FUNCTION ‘RP_EVALUATE_INDIRECTLY_P0014’ EXPORTING PBEGDA = P0014-BEGDA PMOLGA = SY-MOLGA PPERNR = PERNR-PERNR TABLES PTBINDBW = ITAB1. IF SY-SUBRC <> 0. ELSE. CLEAR ITAB1. READ TABLE ITAB1 INDEX 1. WRITE :/ ITAB1-LGART, ITAB1-AMOUNT. ENDIF. ENDIF.
|
Figure 6 |
An excerpt from a coding scenario that reads a single wage type |
To increase performance, an IF
statement uses field INDBW to restrict the function call only for wage types whose values have been valuated indirectly. An internal table ITAB1 is declared to store the results generated by the function module call. A MOVE-CORRESPONDING
statement populates the internal table with the information available (e.g., the wage-type number and the value entered in the number field). Next, the function module RP_EVALUATE_INDIRECTLY_P0014 computes the wage-type amount. Finally, a READ
statement reads the first line of the internal table ITAB1, which is then displayed via a WRITE
statement.
The function modules may also be used in SAP Query for determining the amount of an indirectly valuated wage type. As I showed in my SAPexperts infotype text article, “Use Clusters to Access Infotype Texts,” this involves the creation of an additional field and then writing the code (calling the function module) in the additional field code.
Note
You may apply these function modules on all indirectly valuated modules regardless of whether they are standard or custom-developed. They may also read data valuated indirectly via standard modules such as SUMME or CONST.
Rehan Zaidi
Rehan Zaidi is a consultant for several international SAP clients (both on-site and remotely) on a wide range of SAP technical and functional requirements, and also provides writing and documentation services for their SAP- and ABAP-related products. He started working with SAP in 1999 and writing about his experiences in 2001. Rehan has written several articles for both SAP Professional Journal and HR Expert, and also has a number of popular SAP- and ABAP-related books to his credit.
You may contact the author at erpdomain@gmail.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.