PU12, Payroll Export Interface, is a useful tool for creating payroll export files. This transaction can be used to export both master data and payroll results to a third party system when a company does not wish to run the payroll in house. The below gives an insight into creating a simple export file, however does not cover more complex functions such as user exits.
N.B. To create a payroll export you must be registered as a developer on your SAP system
Configuring a Payroll Export Interface consists of 2 main steps, the interface format and the File Layout.
Configuring the Interface Format:
The interface format is where the data that is going to be exported is defined; this can be payroll results, master data or a mixture of the 2.
Choose a name for your format and select 'create'

Select the relevant country and type a description:

Now choose what data is required in the export:

Here, a master data export is being created.
Now choose which tables hold the data that needs to be exported, these relate to the infotypes in PA:

Here, a simple export which shows the employee's personal data, their address, basic pay and bank details is being created.
You will then be asked to name the program and includes that you are creating by configuring PU12, simply select 'suggest values' and enter.

Now, a list of the tables that have been chosen will appear; each entry can be expanded to show every field that is held in that table.

Each entry that appears in this screen will be analysed by the export program, so every field that is not relevant to the export should be highlighted and deleted.
To highlight an entry and delete it, open the relevant table and place the cursor on the field

Here the 'Lock Indicator for HR Master Data Record' is being deleted.
Choose the select button,  and now choose delete
 and now choose delete  .
 .

All the fields that are not relevant to the export have been deleted.
As the address field has been selected, the export is currently looking at every address type that is held on the system, however it may be the case that only the employee's home address should be exported; to do this select the subtype field of IT0006 and select the filter button:

You will then be asked to enter the values of the subtypes that you want to report on.
Another useful tool at this stage is the conversion button:

Using this tool, it is possible to convert the values that the program exports to a constant value or another related field.
To convert the output of a field, select the field with the select button and choose the conversion button and select the type of conversion that is required.

Here the value is of the gender key is converted from '0' or '1' to 'M' or 'F':

Change Validation
Most export files to a third party system work on a change validation basis, i.e. the information only needs to appear in the export if the data has changed from the previous time the export was run.
To achieve this, select the 'change validation' button at the top of the screen.
Hit create and select all the tables that contain data that is to only be exported when it has changed.

Here, every table has been chosen. Any field that appears here will be exported. In the example, the subtype of the address does not need to be exported as it will always be the home address, therefore this field can be deleted.
To ensure that only fields that have been changed are exported, the 'single field validation' must be assigned at the table level. To do this, select the table (blue line) and select the single field validation button:

This means that all the fields within the infotype will only be exported if they have changed.
Some fields need to be linked, so that if one changes then they are both exported, for example if the first line of an address was to change, then the whole address should be exported, not just the first line.
To do this, select the relevant field, in this example STRAS, and choose the 'relations' button, now select the fields that you want to link to the original field, in this example ORT01, ORT02, PSTLZ and LAND1.
N.B. the relations function only works one way, so by carrying out the above actions, the ORT01 field is linked to the STRAS field but not vice-versa.
After the above actions have been carried out the change validation screen now shows:

If a field is only to be exported once, such as the start and end dates, then this field is made a 'key field'. To accomplish this, select the field and choose the key field button:

If an infotype may have a delimit date, for example IT0014, then the export file will pick up on this change if the 'delimit flag' has been set for this field. To do this, select the relevant field and select the delimit button.

N.B. The start and end date of the infotype must be key fields for this functionality to work.
Configuring the File Layout
Once the interface format has been defined, a corresponding 'file layout' must be configured, this is where the layout of the export file is configured, e.g. which fields should appear where.
Choose a name for the file layout and select create.
You will be asked which 'interface format' the file layout corresponds to, enter the name of the recently created file format and give the file layout a description.

File layouts are split into blocks, structures and fields; simply, a block is made up of a number of structures and a structure is made up of a group of fields.
Select create and enter a name for the first block.
Here, you can specify when the export should be run, how many times the export should be run and whether it should be part of the main export file or an additional export file.

Now select create structure:

Finally select create field:

When creating the field you can define the length of the field and whether the value should be a fixed value, for example if you want to create a header line for your file, a dynamic value, i.e. a value that has been brought through by the export, or if a user exit should be used to populate it.
Here, the employee's first name is to be brought into the field, so 'length of a reference field' is selected and 'dynamic value'.
When enter is selected, the 'reference field' for 'length of the reference field' is asked for, as the employee's first name is the value that will be used field, this field should also be used for the length.

The value which the field should take then needs to be specified, as this is the same as the reference field used to determine the length, the value is already populated.

The entry in the table that should be exported is defined here.

The file layout will then be displayed on the screen, from here more blocks, structures and fields can be added. There is no limit to how many structures can be assigned to a block or how many fields can be assigned to a structure.
The amount of times a structure should be repeated can be defined by selecting the repeat icon next to 'Export':

From here, you can select whether the structure should be repeated always, depending on table values in the export file (this can be useful if you want to repeat the structure for every entry in IT0014 for example) or whether it should be determined due to a user exit.
 


No comments:
Post a Comment