How To Create A Custom Time (PT) Function

Summary:

Custom time functions are required when the standard functions and PCRs (Personal Calculation Rule) are not able to fulfill the complex business requirements. This tutorial explains the step-by-step process to create a custom time function to fulfill those complex business requirements. But, before we start the step-by step process we will see what are Schema and Time Functions?

Schema and Time Functions: When Time evaluation report is executed, employee’s working and absence times are evaluated, the individual processing steps in this valuation are executed in a specific order. This specific sequence is known as Schema, and the individual processing steps are known as Functions.

Schema in time management determines the sequence in which the functions (individual processing step) are executed in time evaluation. With the help of functions data is either provided back to the internal tables in time evaluation or sets a switch which is then used to determine whether or not to process any activity.

Step-by-step process to create custom Time (PT) function

Step 1. Go to transaction code PE04. In the ‘Name’ field, give a name to your custom time function, then select ‘Time management’ radio button from the Object class tab, and then select ‘Function radio button from the Object Type tab. Finally, click on the create button.

Go To Transaction Code PE04

You will see a pop-up message, stating that the function can only be created in SAP package. Accept by clicking on “Continue”    button.

Pop-up Message Will Appear, then Click Continue Button

 

Step 2. Now, enter a description for your function and select the radio button ‘Standard name’ from the ‘Name of form routine’ tab. You can also define a custom name by selecting the ‘Self-defined’ radio button.

Select ‘Other Counties’ checkbox from the Country assignment tab.

Enter A Description

Step 3. Defining Input and Output parameters: When these functions are called in schema, they provide data to the internal time evaluation tables such as TIP, TES, and TZP etc, using input and output parameters.

For providing Input parameters, click on the Input parameters button.

Defining Input And Output Parameters

Below is the screen which you will see after clicking on the Input parameters button.

Input Parameters Button

Now click on the ‘Change’ icon .

Click On The "Change" Icon

Click on the new entries button to create new input parameters.

Click On "New Entries" Button

Here, you can insert all the parameters which you are going to take from the internal tables of Time Evaluation.

Inset All The Parameters

After providing all the parameters click on save iconSave .

Repeat the same procedure to provide the Output parameters. But, remember here you will insert all those parameters which will give data to the internal tables of Time Evaluation.

Step 4. Creating the Transport Request: Now return back to the initial screen of transaction PE01 and click on save icon. After pressing the save button, system will ask you to assign the function to a Standard SAP package.

Creating The Transport Request

After assigning the function to a standard SAP package, you will get the pop up to assign the transport request.

Pop Up To Assign The Transport Request

Step 5. Creating the form routine: Now we will create a form routine as specified in step two. We have selected standard name, so we will create the form routine with the name as ‘FUY0001’.

We will have to create this form routine in the standard include ‘RPTMOZ00’. For creating the form routine in standard include we will require the SAP access key.
This will not be overwritten by SAP in the next upgrade.

Creating The Form Routine

After inserting the form routine write your business logic.

Step 6. Using the custom function in Time Schema: In this step we will use our custom time function that we have created.

Go to transaction code PE01. Enter the name of your schema in which you wish to use your custom function.

Using The Custom Function In Time Schema

Select the radio button ‘Source text’ in the ‘Subobjects’ tab and then click on ‘Change’Change Button button.

Here, you can insert new lines to use your custom function.

You Can Insert New Lines To Use Your Custom Function

Summary:

In this tutorial we have learned how to create a custom function in Time Management, so that it can be used in schema. Following the same process you can create custom functions in Payroll also. The only difference is that when you create a custom function in payroll, you will have to insert your form routine in the include PCBURZ990.

Categories

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon

One Comment
  1. Srikanth

    Hi Pete,

    We have an issue in one of the quota accrual using time evaluation.
    I have a situation where client is asking 5 digit decimal values in the quota accrual.

    I created a time type and set as 3.3333 hours. The calculation are perfectly fine and my only issue is the decimal values.

    When Time evaluation runs, it picks 3.33 hours and multiplies with % from IT0007 / 100. For, full time employees I used the rounding rule. ( If 3.33 hrs -> 3.33333 hrs) So, there is no issue and the issue is only for part time employees who may change from full time -> part time or part time -> full time or part time -> part time (Change in percentage) between the payroll period (which is 15th and last day of the month). So, for part timers I cannot use the rounding rule.

    E.G – 3.33 hours * 80 / 100 = 2.664 hours.

    Whereas client wanted to be like this 3.33333 hours * 80 / 100 = 2.66666 hours.

    When I looked at the time eval. log, I could see the value 3.3333 hrs in time type ZSMX. But, when it goes to ZES table it truncates to 2 decimal values.

    Or is there any possibility for user exits to by pass the value of 3.33 hrs from ZES table to 3.3333 hours while calculating the quota.

    Or how to create a function for the above to by pass the value from ZES table and calculate based on 3.3333 hrs.

    Need your help on this.

    Srikanth