Exporting time and master data with Interface Toolbox (PU12)
As mentioned in standard PU12 documentation : PU12 is 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. Alternatively, the Toolbox can be used to import results based on personnel numbers from the third-Party system and use them for payroll in the SAP System.
Interface can be used to:
- Evaluate data from Human Resources in a third-party system
- Run payroll partially or completely in a third-party system
The data is retrieved from the Personnel Administration (PA-PA), Payroll (PY), and Time
Management components, or from all three.
For anyone starting to work on it for the first time this blog can be of great help. However, this doc. adds exporting of time results as well.
The example demonstrated in the document below highlights customizing PU12 to select only particular wage types for which records exist in a Z* table for the employees, transfer the records to application server and update the payroll period to next payroll period.
This document covers an example of transferring time results and master data with PU12. While transferring time data we deal with wagetypes.
PU12 consists of defining the Interface format and the corresponding file format. This is specific to a particular country group. Interface format is to define all the infotypes/cluster to be read for payroll processing. File format is to define the output format and also add customizations if required.
Defining Interface Format
Starting steps are here. When time data have to be exported along with Master data both the checkboxes have to be selected while defining Interface format.
[Initial steps are intentionally skipped as already given in the blog]
After selecting Infotype/ infotypes in the below screen proceed towards Payroll records selection
Enter the table name, cluster name and press enter e.g. PCL2, B2.
Enter the name of a new Include or alternatively an already existing include (in case PU12 was implemented previously for time data) can be used. This include contains the below three includes. So, in case they are already present in some include, the same can be used.
For Time Wage Types data select ZL and press Enter to see the below screen:
For Time Wage Types data select ZL and press Enter to see the below screen:
Enter the name of Main program following coding standards and then click Suggest Values to generate the includes. Point to be noted is all the code generated by our previous selections are in these includes. It can be seen similar to transaction to LSMW where code is generated.
The below screen is the next step:
Select only the relevant fields required and delete the rest of the fields as given in blog including exploring different options on the screen.
One of the important features is ‘Attributes’ button.
F1 is the greatest help for PU12 .
Select the options with proper discussion with functional consultant.
If the requirement is to transfer time data only, then the first checkbox should be checked. The time period in which the data needs to be fetched, restrictions (e.g. reading only subtype 0001 of Infotype 0105), conversions etc. can be defined in the interface format at this stage as blogged here.
Another important point while exporting time data is selection of appropriate radio button for wage-types as shown below:
Apply filter on Wage Types. Click on filter button. The below screen appears:
Appropriate radio button R1, R2, R3 or R4 needs to be selected with due discussion with the functional consultant.
R2 has to be checked when delta difference of hoursof wage-types between retro-active and current period need to be calculated.
Defining File Format
Basic steps for creating a file format are given in the same blog link. File format is defined in the hierarchy of
Detailed information can be found on the hierarchy starting page 138 in this document .
There are different kinds of blocks depending on the stage at which they get triggered as shown below
Begin of file: Triggered once. Generally it can be used to define file headers which are one per file layout.
During Processing of employee data: Triggered for an employee for all payroll periods i.e. retro periods and current payroll period.
After processing employee data: Triggered once for each employee.
End of file: Triggered once. It can be used to define file footers defined one per file layout.
User –exits are provided at the level of blocks, structures, fields. Depending on the requirement and the recommended way of populating values, level of implementation of user-exit can be decided.
If coding needs to be done at block level, Page 146-147 gives a fair understanding of it in this document .
Any user-exit at PU12 level appears like this:
Program – It can be one main report with all the subroutines used to implement various exits in the entire development of PU12. Subroutine has to be defined like this:
FORM process_data USING fp_p01 fp_p02 fp_p03 fp_p04 fp_p05 fp_p06 fp_p07 fp_p08 fp_p09 fp_p10 fp_p11 fp_p12 fp_p13 fp_p14 fp_p15 return_value. ENDFORM.
Parameters fp_p01 to fp_p15 are used as importing variables. The importing variables are available as F4 help. F1 can be pressed to understand the required radio-button to be selected.
If coding is done at structure level, whatever master data has been read at interface format level is available. Let’s say we did read Infotype 0001. Then P0001 is available in the Subroutine created in the custom program.
READ TABLE P0001 INDEX 1.
More details can be found at page 149 – 150 of document .
During Processing of Employee can be used for processing data for an employee for all the payroll periods. PU12 evokes this block for an employee for all the payroll periods. (Current + retro) This is an important point to be noticed.
Current payroll period can be found with transaction PA03 (Payroll Control Record). Related tables are T549Q, T549A, and T569V. Retro date for an employee is determined by the record in IT 0415 in the most usual case.
Processing steps of PU12:
- One employee is processed at a time.
- ‘During Processing of employee’ block would be triggered for each payroll period starting the with the retro periods and in intervals of payroll period (weekly, biweekly or likewise). The custom subroutine can determine if a payroll period is retro based on the parameter &VAR-RCALC. It’s 0 for the active payroll period and ‘1’ for retro-periods.Any period specific logic can be handled here.
- A very important point can be accessing contents of tables/structures that get populated via standard code of PU12 that gets generated. PERIODS  is the internal table that contains all the payroll periods that will get processed for an employee.To access this table in subroutine at ‘During Processing of Employee’ then the table can be accessed via Field symbol by assigning (ZFIR_PYFILE)periods where ZFIR_PYFILE is the name of the main program in file layout source code.
- ZL  table will contain all the wage types to be processed for the employee for that processing pay period in the block ‘During Processing of Employee’. So any custom code can be written in subroutine at ‘During Processing of employee’.
- Any activity to be performed after processing of an employee can be coded in the exit at either structure/block level in block ‘After Processing Employee Data’. This block gets triggered once for each employee getting processed in PU12.
- ‘End of File’ Block gets processed at the end of the entire processing. This can be used to perform activities like updating payroll dates to next payroll period processing dates on successful execution.
- If any changes are done in Interface format or file format they need to be re-generated.
- If any custom coding is added in the includes generated while creating interface format, the custom coding is lost whenever the interface format is re-generated again after a change.
Tips and Tricks:
- For debugging any issue faced e.g. let’s say when PU12 is run in update mode, PCL2(IF) cluster does not get updated and it was supposed to get updated. Debugging can be started by putting breakpoints in the main Include RPCIFM47 which then calls all the customized and standard PU12 generated coding. One of the issues faced was PCL2(IF) cluster was not updated when PU12 was run in update mode, reason being the buffer was getting refreshed as an FM was called in between which used COMMIT work.
- Break-points can be put in the generated includes while creation of interface and file-formats to understand the functioning and population of values in PU12.
Viewing Cluster Data:
More about Clusters can found here: http://wiki.sdn.sap.com/wiki/display/Community/Cluster+tables+in+HR
Standard SAP report to display Time Evaluation results (Cluster B2): RPCLSTB2
Transaction: PT_CLSTB2 or do a where used list of above report.
On entering relevant data like Pernr, Year etc. below is the output:
Double click on a record to see the detailed information as below:
To see the data of a particular table double click on one table and the data appears:
Standard transaction to view Time evaluation results: PT_BAL00
Either Payroll period can be selected or a time period can be entered. To view wage types related data, 3rd radio button needs to be selected under ‘Selection Conditions’.
The result displays the wage types and the corresponding hours for them.