PU12 Interface tool
PU12 Interface tool: PU12 is a tool to transfer data from the application components in Human Resources (HR)
to a third-party system. The data is retrieved from Personnel Administration (PA-PA) or Payroll (PY) or
Time Management components, or from all three.
We use the Interface Toolbox to retrieve data from Human Resources for further processing in a third-party
system. The third-party system can be a payroll system used outside of the SAP System. This can be useful if,
for example, we run gross payroll in our enterprise and the net payroll takes place in a third-party system.
Alternatively, we can use the Toolbox to import results based on personnel numbers from the third-party
system and use them for payroll in the SAP System.
This document describes the steps for creating interfaces using PU12 tool with detailed screen shots for following scenarios:
- Personnel Administration (PA-PA) without change validations. (Part1)
- Personnel Administration (PA-PA) with change validations.(Part2) – http://scn.sap.com/docs/DOC-56426
- Payroll (PY) without change validations.(Part3)
We use the following application components in enterprise:
- Personnel Administration (PA-PA)
- Time Management (PT)
- Payroll (PY)
PU12 Interface for (PA-PA) without change validations:
Interface Format: The interface format contains the objects that we want to export from the Human
Resources Application component (HR) to a third-party system.
The interface format is the basis for data export with the Interface Toolbox. We use the interface format to
determine which HR data we want to select, and also how this selection should take place. When we define
an interface format, we can access all employee data for the following application components:
- Personnel Administration (PA-PA)
- Time Management (PT)
- Payroll (PY)
Using our defined interface format as a basis, the Interface Toolbox will ultimately generate a program using
the Advanced Business Application Programming language (ABAP). We use this program to export the data.
The system processes the data quickly and effectively during the export.
Process flow diagram:
Interface format steps:
1. 1. Execute transaction code PU12 for creating interface format.
The interface toolbox involves following three tabs:
· Export tab: It is used to execute the interface and read respective results.
· Export History tab: It is used to see the log, and results of previously executed runs.
· Configuration tab: This is used for interface development.
2. 2. Configuration tab details:
· Interface Format: This is the place where we specify input layout of interface which includes data required by interface for e.g. Tables, info types and fields.Conversions, Restrictions, Change validations and other configurations are also handled here in order to pick the right data for the interface.
· File Layout: In File Layout we will specify the output structure of interface that is we will specify which fields will be part of output file, their respective widths, order and frequency (e.g. for each employee).
· Create: Used to create new Interface Format or File Layout.
· Change: Used to change existing Interface Format or File Layout.
· Display: Used to display existing Interface Format or File Layout.
· Copy: Used to create new Interface Format or File Layout by copying existing Interface Format or File Layout.
· Generate: Used to generate ABAP code for Interface Format or File Layout. It is implemented once all the changes of Interface Format or File Layout are completed. Ideally, we need to generate the Interface Format and File Layout every time we do a change in any of them, so that it generates fresh ABAP code for the configuration and we do not get any error.
1. 3. Create a test interface format ‘YIN3’ as shown below:
2. 4. Enter respective country grouping as shown below.
Note: One PU12 interface format is only for one country. Hence if we are dealing with multiple countries, we need to create respective multiple interface formats. This step cannot be undone or changed later on, so if you chose a wrong country then you will have to delete the interface and create it again from scratch. File format can be reused for other countries as it does not require country grouping while creation.
3. 5. Select Master data option for PA as shown below:
6. In this step select the info types that will be required by interface. As part of this example we will consider IT 2, 6, 7, 9 and 21.
5. 7. Enter program and include names that it will generate for the interface format. Click on suggest values button, or you can chose a name according project naming convention.
This is a test interface hence we are changing ‘Z’ to ‘Y’ for main program and includes.
6. 8. Interface format is as shown below:
7. 9. Now choose the fields that will be required by the interface and remove all unwanted fields. Select the fields by double clicking and use the delete button to remove them as shown below:
8. 10. For this test interface we have selected following fields:
9. 11. Table Entries : Here we specify which entries to pick, all of them are self-explanatory, and we will chose 2nd option for all the 5 infotypes.
10. 12. Conversions : Using this icon conversion can be done on field level. Click on the field and then click on the conversions icon. There are three kinds of conversions that we can implement for any field selected.
Types of Conversion:
· Constant Conversion.
· Table Value Conversion.
· User exit Conversion.
· Constant conversion: This will give us a way to convert the values in the infotypes fields to constant values that we will provide in a table format.
For e.g.: a constant conversion on FAMST field of infotype 0002 as shown below.
· Table value conversion: It looks into a database table for and matches values of infotype field mimicking a SELECT statement’s where clause and picks up the corresponding values. For e.g. consider country field of the infotype 0006 as shown below.
Through above conversion we will pick up the description of the country from table T005U.
· User Exit conversion: This is where a custom code logic will be involved, if above two methods cannot give the required conversion. We will need to create a custom program with a subroutine in it. It is important to specify the type of the program as ‘subroutine pool’.
Specify the program name and form routine in below pop-up:
Code snapshot for User Exit:
1. 13. Restrictions : Here we restrict records that the interface will fetch from infotypes; it is like a where clause of select statement and only constant restrictions are allowed in this case. For e.g. Restriction on infotype 0006 to get the specific subtype ‘1’ and ‘2’ as shown below.
2. 14. Attributes: A very important place where we specify the general settings of the interface as shown below.
· Interface without payroll: Determines the relationship between the export program and the payroll program.
1. If you do not select this option, system executes export program after payroll program. The export program refers to results of payroll program. That is
· The export program determines the payroll period from the payroll results generated in the payroll program.
· The export program only selects an employee if a payroll result exists for that employee for the period to be exported.
2. If you select the attribute, the export program is processed without the payroll program. The export program generates the payroll period independently. Any existing retroactive accounting data is taken into account in payroll.
· The export program evaluates the entry in the Earliest Master Data Change field in the Payroll Status infotype (0415) during the generation of the payroll periods.
· After a successful export, the export program updates the Payroll Status infotype (0415).
o The following fields are updated:
o Field: Exported until
o Field: Earliest MD Change
· The export program updates match code W. Match code W is the list of all personnel numbers rejected during the export.
No retroactive accounting:
1. If you Flag the attribute, the interface format does not perform retroactive accounting. Retroactive changes in HR master data are not exported. The system always only exports the current payroll period.
2. The toolbox only evaluates the parameter for HR master data (infotypes) interface types. The attribute Interface without Payroll must be flagged.
· Check control record:
1. If you flag the attribute, the export program checks the Payroll Control Record. The system only exports payroll areas with the active status Released for Payroll in the payroll control record for the correct payroll period. This means that no changes can be made to the HR master data during data export. This guarantees the following:
· Export of consistent datasets to the third-party system.
· Changes to the HR master data are not lost during data export.
· The correct payroll period is selected.
2. If you do not flag the attribute, the export program does not check the payroll control record.
Indirect valuation of wage types:
If you select this attribute, the Interface Toolbox performs an indirect valuation for wage types in the Basic Pay (0008), Recurring Payments and Deductions (0014), Additional Payments (0015), and Additional Off-Cycle Payments (0267) infotypes.
· Interface Format: New Change Validation
· If you flag the attribute, the new variant is used to determine the predecessor of the payroll period (comparison period). We recommend this variant.
Advantages: Every change is only sent once for each payroll period. These changes are no longer sent in the case of subsequent exports that follow the first export. This is in contrast to the old variant. The toolbox always sends retroactive changes.
Note: During the first export after a change covering several periods, the changes are sent for every payroll period affected by the change.
· If you do not flag this attribute, the old variant is used to determine the predecessor of the payroll period.
Disadvantages: Changes are sent several times when there are several exports for a payroll period. Under certain conditions the toolbox does not send retroactive changes.
Do not save to cluster IF: Causes the system not to update the interface results on the cluster IF (Interface Format). This cluster object is found in the database object PCL2 (Payroll). For the personnel numbers selected, it contains the contents of all the table objects from the interface format at the time of export.
· If you do not select the attribute, the export program updates the interface results in the cluster IF. The change validation and wage type options for retroactive accounting depend on the interface results being saved. Both functions can only work without errors, if the interface results were saved in the cluster IF.
· If you select the attribute, proceeding data exports should have no influence on the current export. This means that you cannot use the change validation and wage type functions for Retroactive Accounting.
· Dependencies: If you change the attribute, you must regenerate the export program.
To ensure that the export program works correctly, you only need to save the current interface result for the payroll period. The functions Change Validation and Wage Type Options are integrated for retroactive accounting (R1 to R4).You can activate the attribute to save memory space. Dependencies: If you change the attribute, you must regenerate the export program.
3. 15. Save the interface format and go back to the main screen.
4. 16. Generate the ABAP program for interface format as shown below:
5. 17. Program generated successfully as shown below:
We have created the interface format using above steps (1 to 17). The export program is generated successfully as shown above.
File Layout: The file layout describes the structure of the export file, in particular the sequence and length of the field objects.The File Layout function allows you to convert the export file format, which is known as the SAP export file format, into any user-defined file format. An interface format is assigned to each file layout.
File layout steps:
The default output for PU12 interface tool is a text file and we will need to define a file layout of our exported data.
1. 1. Create a custom file layout as shown below:
Provide the interface format created in above steps. In this step, the interface format is linked with File Layout.
2. 2. Create a Block as shown below:
Note: Blocks are at the top level of file layout hierarchy and they do not contain any data by themselves. They contain further structures which also do not contain any data. Each structure can contain fields which actually contain data in them. It is important to use these as per our logic for the requirement.
Processing time of a block: This option determines the processing time for a Block. During block processing by the Interface Toolbox, various processing times occur. At one particular processing time, the Toolbox processes all the blocks you have assigned to this time.
Select a processing time for block processing:
· Start of File:The Toolbox processes these blocks at the start of the file to be converted. This processing time exists exactly once.
· Employee Data before Processing: Before the Toolbox processes employee data, it checks the processing time “Employee Data before Processing”. The system calls this processing time exactly once for every payroll period for an employee.
· Employee Data during Processing: The Toolbox calls this processing time when it processes payroll periods for an employee. The system calls this processing time exactly once for every payroll period for an employee.
– Employee Data after Processing: After the Toolbox has processed the payroll periods for an employee, the Toolbox calls the processing time “Employee Data after Processing”. The system calls this processing time exactly once for every employee in the file to be converted.
– End of File:The Toolbox processes these blocks at the end of the file to be converted. This processing time exists exactly once.
3. 3. Create a structure as shown below:
4. Create following fields in above structure:
· EMP_NUMBER (Dynamic value):
Length of a referenced field will ask in later step a field name to limit the output length to that referenced field. Because of Dynamic value we will chose a field that will populate the data in this field.
In above screenshot we have chosen the global variable &VAR_PERNR which will contain the pernr value of the currently processed PERNR. Current entry makes sure that the record is active.
· Constant value, as it says will replace the contents with a constant value, irrespective of the contents of the infotype.
· Dynamic value will get the data from the infotype or the global variables, (there are many global variables available, and that can be viewed by hitting F4).
· User exit will execute a custom routine and the returned value will be placed in the contents.
· WEEKDAY (User exit):
Consider an example for user exit at field level as shown below.
Defining the length of weekday:
Weekday field will contain the weekday of P0002-BEGDA and it will be placed in this field.
Subroutine has 16 parameters, out of which first 15 are input parameters to the form and the 16th is the return parameter which will replace the contents of the field in file layout as shown below:
The first, last and current value columns specify which record of the infotype to pick to pass value for P0002-BEGDA, the first, last or current active record.
Code for this user exit is as shown below:
· Constant field (field having constant value ):
Defining the length and value of constant field as shown below:
Value of the constant field is set to ‘X_X’ as shown below:
We have also added some additional fields as shown below:
5. 5. Enter program and include names that it will generate for the file layout. Click on suggest values button, or you can chose a name according project naming convention.
Changing ‘Z’ to ‘Y’ for main program and includes since it’s a test interface.
6. Save the File layout format and return to the main screen as shown below:
7. Generate the ABAP program for file layout:
Test Interface for (PA-PA) without change validations
Detailed steps for testing the interface:
1. 1. In the Export tab, select Interface format and execute it.
2. 2. Export Options: Provide the selection screen data as shown below:
Export for original periods only: This option determines whether the system should export all periods or only original periods. The original period corresponds with the payroll period in which the data export is started.
· If you flag the checkbox, a comparison is made with the last original period in the change validation, since it is the last period transferred to the third-party system.
· SAP recommends the export option when the third-party system does not support retroactive accounting.
· If you do not flag the checkbox, then the last period can also be a retroactive accounting period
Example: Payroll is run for an employee for period 03 with retroactive accounting to period 01.
· If the parameter is active, data is only exported for period 03 in 03. (Wage type differences must be transported to the current period using option R4).
· If the parameter is not active, data is exported for three periods (01 in 03, 02 in 03, and 03 in 03).
Repetition of Export: This option determines whether the current data export is a repetition or a new export. This information is of significance for the Toolbox in connection with the change validation.
Example: You have already exported data for your payroll period 02. Start a new export for payroll period 02. There are two options for the “repetition” export option:
· Option 1: The checkbox is not flagged.
Effect 1: The export program treats the current export as an additional export for payroll period 02. The change validation compares data from payroll period 02 with the data from the previous export for this payroll period. This makes it possible to export a payroll period several times and only transfers the differences to the third-party system.
· Option 2: The checkbox is flagged.
Effect 2: In the case of an active change validation, the export program ignores the first export from payroll period 02. The change validation compares the data from payroll period 02 with data from payroll period 01. Data from the first export is also deleted for payroll period 02.
· If you perform three or more exports for the payroll period and the Repetition checkbox is flagged, only the immediate previous export is ignored for the current payroll period. The system compares with the export before last for the current payroll period.
Not all exports are ignored for the current payroll period.
Update When Exporting: This option decides whether a data export is only simulated or is actually carried out.
The checkbox must be flagged for every productive data export.
· If you do not flag the checkbox, the export program does not create an export file.
The interface results on the cluster IF (interface format) are not updated.
· If you flag the checkbox, the export program creates the export file.
The interface results on the cluster IF (interface format) are updated.
· If you flag the checkbox, the system shows detailed information on the export data and change validation.
· You also flag the checkbox if you want to start the export program for test purposes for individual personnel numbers.
On execution the output is as shown below:
Marital status is a converted value as shown below:
3. 3. Download from TemSe, i.e. Temporary Sequential File as shown below:
In TemSe Object, hit F4.
Select below option:
Select the latest TemSe file
Provide the file path on presentation server as shown below.