As more companies using SAP Payroll move to PDF files for payslip forms, they usually use a single payslip for employees having multiple contracts. I show the main steps to switch to HR Forms payslips for users who struggle with handling those PDFs. The solution I describe here is fully standard.
(SAP offers an HR Forms framework to create a PDF or Smart Forms payslip and to implement specific business requirements without any additional support. HR Forms is central tool that eases designing forms such as payslips. It provides an open directory with data to capture in the form with drag-and-drop functionality, such as adding additional wage types and sorting them according to your needs—for example, by first or last name. It sends them automatically by email via ABAP code to employees using the standard Business Add-In (BAdI) HRFORM_HRF02 delivered by SAP. The modification can be done using SAP standard functionality.)
Enhancing HR Forms
SAP offers tools to optimize HR daily processes such as mailing payslips to employees when needed, saving time and effort and staying within SAP instances (such as SAP ERP Central Component [ECC]).
While with the old forms you needed to convert the payslip from SAPscript or Smart Forms to PDF format, with HR Forms you can use SAP standard functionalities to save development time by avoiding the conversion into PDF format.
Use transaction code SE19 (Figure 1) to go to the initial screen for creating your enhancement.
The initial screen for creating a new implematation
Click the Create Impl. button to open the screen shown in to Figure 2, which shows enhancement ZHREXPERTONLINE. It has a filter on the SAP_PAYSLIP_USCE form. In my example, use HR Form SAP_PAYSLIP_USCE.
Specify the name of the form you need to enhance
You create the enhancement to filter on the payslip you want to display. To do so, click the insert row icon . Use the matchcode to search for and then select the form. In this case you use the HR Form SAP_PAYSLIP_USCE. Based on this filter value, the system decides which active add-in implementation to execute. The system only acts on the object data you enter as a filter name of your HR Form. Enter the name of the HR form and a short name in Figure 2, and then press Enter. Then click the Interface tab in Figure 3 to see a list of a set of methods.
List of methods to enhance according to the business requirement
I highlight the most used methods:
- IF_EX_HRFORM_HRF02~CHECK_PERNR_LATE: In this method, you can reject empty payslips within object-oriented ABAP. You can raise an exception (for example: raise reject) in a final PDF so that no empty page is displayed.
- IF_EX_HRFORM_HRF02~MODIFY_PAY_RESULTS: With this Business Add-In (BAdI) you can remove the split indicator WPBP. During payroll, the system writes the Basic Pay wage type to the results table with two different indicators. These split indicators are a link to the WPBP table that contains the relevant values. The system takes into consideration both data records for the corresponding partial periods when calculating remuneration for specific wage types. You use this method to avoid having multiple lines in a payslip in one period. A split indicator, WPBP for example, causes a wage type to be split in a period with multiple lines displaying in a payslip.
- IF_EX_HRFORM_HRF02~AFTER_PDF_PRINT. You use this method to execute operations immediately after printing a form. Also, this method provides two file formats, PDF and page description language (PDL), that you can send via ABAP code by email immediately after printing based on information stored in infotype 0105. PDLs define page elements independently of printer technology so that a page’s appearance should be consistent regardless of the specific printer used.
- IF_EX_HRFORM_HRF02~BEFORE_PDF_PRINT: You can use this method to adjust print parameters. For example, you can download the form without printing it so that you can send it to employees who do not have access to a company portal.
Double-click AFTER_PDF_PRINT in Figure 3 to go to Figure 4.
Attributes to send an email to employees
Click the Sourcecode tab in Figure 4 to add the code shown in Figure 5 to enable immediate print and spool once the print is finished. Also, for instance, if you want to send emails with attachments by using ABAP code read the documentation after clicking this link.
Sample of ABAP code for immediate print
Two Methods for Displaying Many Payslips in One PDF Form
In this section, I describe two options for creating PDFs of massive numbers of payslips that show all the payslips in the same PDF file.
Option 1: Use the PDF Toolkit (PDFtk) to Merge Payslips into a Single File
You can use the software PDFTK (short for PDF Toolkit), a cross-platform tool for merging PDF files. The advantage of this tool is that you can merge PDFs by calling function module GUI_RUN (Figure 5). Note that this is for Unix-based systems, Mac OS, and Windows-based systems.
You can download a free copy of program PDFTK here. This tool can accept command-line options. The reason to select this among many others (such as ilovepdf, mergepdf, and smallpdf) is that with this software you can use the Unix/MS command line. It’s possible to run an OS command from ABAP (click here to find all the necessary steps to create external commands with the help of Unix coding in an SAP system).
Option 2: Use a Standard Report to Merge PDF Files
To have all payslips in one file, you need to implement SAP Note 0002264208 Merging PDF files (ABAP interface). After you import this note you have an additional report to merge PDF files in the package SASP via transaction code SE80. Executing transaction code SE80 takes you to Figure 6. The benefit of this option is you use a standard report and no interfaces are needed.
SAP-delivered report to merge all PDF files in a single one
Option 1: Using the PDF Toolkit (PDFtk)
To use this option, you generate all payslip PDF files as shown in Figure 7, and a spool ID is created.
Select the Execute in Background option
For the US, you run transaction code PC00_M10_HRF, and for Switzerland, for example, use PC00_M02_HRF_CE. Once you finish your payroll run, execute the payroll log in the background by clicking Program in the menu bar and selecting the Execute in Background option.
Once you run the payroll log, you create PDF payslips in the background. You download PDF documents locally, and you use the toolkit PDFTK to concatenate the files. Refer to the second part of this series to see how to generate the driver print.
Figure 6 shows report RSPO0020 for displaying all the files of an PDF spool request. The spool ID is also generated in background. To get the spool ID, run transaction code SP02. It is created for this example immediately when all payslips are created (Figure 8).
Execute the report with the spool ID
To generate the spool ID enter a number in the PDF Spool ID field in Figure 8 and then click the execute icon . You execute the report RSPO0020 via transaction code SE38 to display technical details (Figure 9) with the generated spool ID.
All PDF file names are concatenated with SPOOL and spool ID (000029441)
To summarize the process for storing PDFs to merge into a single file, you complete three steps:
- Figure 9 provides the path where PDF files are stored in this example: /usr/sap/TST /SYS/global/. As shown in Figure 9 PDF files are named in the format SPOOL000029441*.pdf’.
- Locally download all PDF files from /usr/sap/TST/SYS/global/ to local directory pdf-directory
- Call the function module GUI_RUN to merge the PDFs (Figure 10) with information you get after completing steps 1 and 2.
Use function module GUI_RUN to merge PDFs
You call the function module to execute the PDFTK toolkit to merge all PDF files. In this example, you see in the pdf-directory all payslips are merged into single file named new_single_file.pdf.
Option 2: Use Standard SAP Functionality to Merge Pay Slips into a Single File
I prefer this solution. Because it’s fully standard functionality, you don’t need to install any additional software. You just need to implement SAP Note 0002264208 Merging PDF files (ABAP interface) and process as follows:
1. Merge the PDFs into one document. First, print all the payslips in the background (Figure 7) to generate a spool. Immediately check where the PDF payslips are stored in your system by using function module ADS_GET_PATH. In this example, the PDF-formatted payslips can be found here: /usr/…/global/.
Note that the path depends on the OS hosting your SAP system instance (Figure 11). Once you mass print payslips in the background (Figure 7), you run the function module ADS_GET_PATH via transaction code SE37 to get the path where all PDF files are stored.
This function module gives information about where the PDF files are stored
2. Download the file containing all the PDFs in a local directory using transaction code SP02. From the spool menu select Export as PDF…(Figure 12).
Select the spool id to export to the local drive
Once you know all input parameters such as where you save your PDF files that you download from the SAP system, run report RSPO_TEST_MERGE_PDF_FILES via transaction code SE38. This action takes you to Figure 13. The report has a lot of features for merging files and displaying them as a PDF file.
With the parameters selected in Figure 13, click the execute icon to provide the path to where you store your PDF files to merge into single PDF file. A pop-up screen appears (Figure 14) in your window to ask you to provide the path of files you need to merge.
Provide the path for storing PDFs to merge into a single file
Click the OK button and a second pop-up screen appears asking you to save the file (Figure 15). The name merged.pdf is a default name. Click the Save button to save the file.
Save the file