Using the SAP-provided user exit EXIT_SAPLPTWS_001, you can modify generated work schedules to configure the second Saturday of the month as a day off, which otherwise is not possible through configuration.
Key Concept
SAP-provided user exit EXIT_SAPLPTWS_001 provides a window in which the outcomes of configuration in the generated work schedules are made available for any modifications before they are finally saved. When you have a requirement to use a combination of work times and holidays or days off that you cannot achieve through configuration, you can use user exits as a flexible option to modify generated work schedules. Daily work schedule variants are very useful when there is a deviation in the normal working times, but only when these variations are based on the holiday class or the day of the week. If you need to change work hours for any other reason, then you cannot use these work schedule variations.
A good example of this scenario is a business that is open six days a week, but every second Saturday of the month is a day off. You have two options available to configure this using period work schedules. Your third option is to use an SAP-provided enhancement, which I discuss in this article.
One option is to create a period work schedule for 52 weeks. In this schedule you can mark all the second Saturdays of the months as a day off. However, this would be very difficult to maintain and is not a practical solution.
The other option is to define a period work schedule for four weeks. In this schedule, you define the Saturday of the second week as a day off. However, this is not a good solution because, for the first few cycles, the second Saturday would be a day off, but, for the subsequent cycles, there could be differences, as the second cycle begins where the first cycle ends (Figure 1).

Figure 1
The period work schedule with various cycles and the position of Saturdays
The period work schedule in Figure 1 is created from January 3rd for four weeks, with the second Saturday circled in green. The second cycle of the period work schedule starts on January 31st and ends on February 27th. Here also the second Saturday is tracked properly. Even in the third and fourth cycles, the second Saturday is tracked properly. However, in the fifth cycle, the second Saturday falls on May 6th. In this case, May 6th is the first Saturday of the month, not the second Saturday, so this is incorrect. This happens because period work schedules are not based on months but on weeks, and there can be instances when a week can be broken between two months.
A better solution in this scenario would be to use the SAP-provided user exit EXIT_SAPLPTWS_001. Following are some examples of other situations for which you could use this user exit.
- Unexpected or unscheduled holidays. In this case, there is an unexpected holiday because of political unrest or a natural disaster. Because of this missed day, employees must work another day to make up for this unexpected day off. For this scenario you can create a custom application table. You can use it to maintain the unscheduled holiday date and the date when the employee makes up the missed day. The code in the user exit refers to this table, and the new work date and the unexpected holiday date are switched.
- A change in work hours or start or end times with a defined frequency. In my example, every second Saturday or every third Friday is a day off. However, the period work schedule pattern is not consistent because, after four months, a week is added, and the first week of the next month is included in the previous month’s period work schedule. Once this pattern is broken, for all subsequent months the data does not match up with the actual dates. This is seen in Figure 1, where from May 5th on the pattern is broken and the system records the first Saturday of the month as a day off instead of the second Saturday.
Before going into greater detail about this user exit, let’s look at the structure of work schedules and how they are generated.
Structure of a Work Schedule
Figure 2 shows an example of a generated work schedule. The details of any day in a work schedule look like the illustration in Figure 3.

Figure 2
Work schedule for a period

Figure 3
Representation of a day in a work schedule
These are the various attributes or parameters for each day in a work schedule. They are:
- Day type: This defines how the day is paid
- Holiday class: This defines the type of holiday class
- Name of the daily work schedule: This defines the work hours and break times
- Daily work schedule variant: This is any variant to the daily work schedule (for example, different starting or ending hours, or a reduced work schedule).
Note
When using the user exit, values for any of these parameters (Figure 3) can be replaced when the work schedules are generated.
How to Generate a Work Schedule
Depending on configuration, there are SAP-standard programs that generate work schedules. The most important of these is the function module HR_GENERATE_WORK_SCHEDULE. Based on the configuration, this function module generates employee work schedules, which are stored in structure INT552A. After storing the generated work schedule details in the structure, the system displays the work schedule as shown in Figure 4.

Figure 4
The generated work schedule
Click the save icon (circled in Figure 4), and the work schedule data from structure INT552A is saved into table T552A. As a result, table T552A is where all the work schedule data is stored.
Implement the User Exit
The user exit EXIT_SAPLPTWS_001 is available in enhancement PTIM2007 (generate monthly work schedule). Before using the user exit, the enhancement has to be implemented. To do this, first you need to create a project. Use transaction code CMOD to create a project. Assign a project name to your project and click the Create button (Figure 5).

Figure 5
Create a project
Once you click the Create button in Figure 5, the system prompts you to enter the Short text — the long name of the project (Figure 6).

Figure 6
Enter the long name for the project
Once you enter the long name, click the Enhancement assignments button at the top, which results in the screen shown in Figure 7.

Figure 7
Enhancements for a project
Here you enter the enhancements where a user exit is available. In my example, the enhancement is PTIM2007. Enter PTIM2007 in the Enhancement field and press Enter. The screen shown in Figure 8 is displayed.

Figure 8
Enhancement added to a project
Click the Components button (Figure 8) and the various components available in the enhancement are displayed. For this enhancement there is one component, which is shown in Figure 9.

Figure 9
Components in an enhancement
This component, EXIT_SAPLPTWS_001, is the user exit. Now double-click the user exit — EXIT_SAPLPTWS_001, in my example — highlighted in Figure 9. This opens the user exit and shows the include code, which is zxp01u03 for this user exit (highlighted in Figure 10).

Figure 10
Include code available in the user exit
Double-click the include code highlighted in Figure 10. This opens the ABAP editor screen for editing, where you can write your ABAP code (Figure 11).

Figure 11
Include code ZXP01U03 opened for editing
Structure of the User Exit
The user exit is a function module; therefore, it has export and import parameters. In this example, EXIT_SAPLPTWS_001 imports structure STANDARD_WORK_SCHEDULE (which is a type of table T552A) and exports structure MOD_WORK_SCHEDULE (which is also table T552A). This user exit is called from function module HR_GENERATE_WORK_SCHEDULE, and the data from structure INT552A is passed to the structure STANDARD_WORK_SCHEDULE (Figure 12).

Figure 12
Screen from a debug session, showing the calling of the user exit
Now the structure STANDARD_WORK_SCHEDULE in the user exit includes the data from the work schedules generated based on configuration. Here you can write your ABAP code, which replaces the employee daily work schedule with another daily work schedule.
Once the data is modified, the new, modified data is copied to the structure MOD_WORK_SCHEDULE, which is also the export parameter for the user exit. Once you exit the user exit, the data from MOD_WORK_SCHEDULE replaces the data in structure INT552A and the rest of the process is the same.
Now let’s look at some of the important fields available in the structure STANDARD_WORK_SCHEDULE (Figure 13):
- ZEITY – ES Grouping: The employee subgrouping for the work schedule rules
- MOFID – Holiday Calendar ID: The ID of the holiday calendar for the work schedule rule that is being generated
- MOSID – PS Grouping: The personnel subarea grouping
- SCHKZ – Work Schedule Rule: The name of the work schedule rule that is being generated
- KJAHR – Calendar Year: The year for which the work schedule rule is generated
- MONAT – Posting Period: The month for which the work schedule is generated
- TPR01: Daily work schedule
- TTP01: Day type
- FTK01: Holiday class
- VAR01: Daily work schedule variant

Figure 13
Structure of STANDARD_WORK_SCHEDULE and MOD_WORK_SCHEDULE
Note that the final four fields (TPR01, TTP01, FTK01, and VAR01) represent the first day of the month. These fields are available from TRP01 to TRP31 (for each day of the month). You can modify any of these four fields for any day of the month from the user exit. For example, if you have to replace the daily work schedule on the 20th day of a month, then replace the value in the field TPR20. Similarly, if you have to replace a day type on the 15th day of a month, then replace the value in the field TTP15.
Similarly, the following fields are for each day of the month:
- TTP01 to TTP31
- FTK01 to FTK31
- VAR01 to VAR31
NOTE
Both the STANDARD_WORK_SCHEDULE and MOD_WORK_SCHEDULE structures have similar fields.
Use the User Exit
In the example scenario, the second Saturday is a day off. When the original work schedule rule is created based on the configuration, all six days (Monday through Saturday) have the same daily work schedule. Sunday has a different daily work schedule as Sunday is a day off. Table 1 shows a typical work schedule generated by the system, based on the configurations.

Table 1
An actual work schedule generated based on the configurations
If this Saturday happens to be a second Saturday, then GEN1 should be replaced by OFF1. This replacement is done through the code in the user exit. The code in the user exit is executed for each month for which the work schedules are generated.
NOTE
Work schedules are generated for entire months. For each month the work schedule is generated, if the user exit is implemented, the system loops through the code in the exit.
In the code, replace the daily work schedule of a second Saturday with OFF1. Before you take this step, however, you have to identify the day when the second Saturday in the month occurs. For this you create a custom function module that returns the date of the second Saturday in a particular month. See Figure 14 for sample code for the function module. For sample user exit code, see Figure 15.

Figure 14
Sample function module code to find the day of the second Saturday

Figure 15
Sample user exit code
Note
The codes in Figures 14 and 15 are sample codes with minimal validations. These can be used as references for writing codes that fit your specific business requirements.
Once you have the date, then you can modify the parameter TRPxx. TRPxx is the field for the daily work schedule. Here xx denotes a day; for example, day 05 of a month would be TRP05, day 10 would be TRP10, and so on. You can replace the current value in the field TRPxx with the value OFF1. This replaces the daily work schedule on a second Saturday with OFF1.
Note
It is important to keep the following points in mind when creating the user exit code. Initially, when the user exit is called, the structure MOD_WORK_SCHEDULE is set to initial (i.e., there is no data). Therefore, you need to move the data from the structure STANDARD_WORK_SCHEDULE to the structure MOD_WORK_SCHEDULE. You also need to have some checks on the personnel area and subarea, the employee subgroupings, and the work schedule rule so that you can ensure that you are modifying the right work schedule rule. The code in the user exit is executed once for each month. For example, if you are generating the work schedule for 12 months (e.g., January 2011 to December 2011), then the code in the user exit is executed 12 times — once for each month.
Vamsi Mohan
Vamsi Mohan works as an SAP ERP HCM consultant. He has been working in SAP ERP HCM for the past seven years in various assignments. Vamsi has rich experience in time management, payroll, LSO, ESS, and has been part of many implementations. Prior to joining Accenture, he was associated with TCS, IBM, and Dell. Vamsi has a master’s degree in business administration.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.