Skip to Content

This document contains step by step procedure to create custom payroll function.

What is a Custom function?

Payroll function and Schema plays very important roles in SAP HCM payroll run. Functions are used to calculate different amounts on the basis of master data and time data, wage type values etc. SAP provides many standard functions to calculate the amount for payroll run. We can also create custom functions with custom calculations as per business requirements and tweak into payroll schema.

How to create one?

Before we create a function, we must create, check, and save the source text for the new function in an include. For Payroll Accounting functions and operations, you use the include RPCBURZ0; for Time Management functions and operations, you use the include RPTMOZ00.

Go to se38 and enter RPCBURZ0 and click on change, for the first time in every project it would ask for Access Key, once we generate one key for change access we don’t need to do it every time we create a function/operation. It is a one time activity

Create a custom include which will have source text for all your custom functions/operations created in your project.

Snap1.jpg

In custom include ZHPY_RPCBURZ0 create your own custom include for your custom function for example ZTEST

Snap2.jpg

In custom include created above subroutine of your custom function ZTEST which has the source text is placed with form name as FUZTEST.

Snap3.jpg

Now go to PE04 transaction code to create/display custom functions and operations

Type ZTEST in name field and select payroll and function as object class and type and click on Create

Snap4.jpg

Enter the description text  relevant to the functionality, form routine is defined by standard as FUZTEST (which we have created above in the include) we can also self define our own form name.

Check the checkbox of the countries depending on this the form or the source text will be called in respective country’s payroll schema

Define the parameters in the parameters section by which data will flow into the subroutine

Snap5.jpg

In order to go to the source code we have to click on the below highlighted button which will take you to the subroutine of the custom function which we have created in RPCBURZ0

Snap6.jpg

Select the payroll program of the country which we have chosen in the country assignment section

Snap7.jpg

Snap8.jpg

We can write our ABAP code as per our business requirement as per the below Screen shot.

Snap9.jpg

Once the code is written, we have to activate the source code and also save and activate the function in PE04

Finally we can call the above custom Function in our custom schema where ever necessary as below

Snap10.jpg

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Sven Ringling

    Hi Tatavarthi,

    you do nicely cover the basic steps for creating a custom payroll function.

    However, I think we should mention that this process is only recommended, if you have only one payroll country in your system or you are 100% sure the function is to be used by several countries AND doesn’t create any problems for others.

    The reason is:

    RPCBURZ0 would be an include to all active payroll drivers. If you use a table or other object only visible from one of them, all others would thrwo a syntax error, because they don’t know the object. Even declaring that object in your form routine wouldn’t work, as it would then throw a sysntax error in the country you are aiming at due to double declaration.

    The include to use would therefore be PCBURZxx0. “xx” being the country acronym (ISO code such as GB for Great Britain or DE for Germany) or, if you work with RPCALCX0 as payroll driver, 99.

    Example:

    You want to develop a function, which needs to read UK rax rates in table T5G01.

    If you use this table in your coding in RPCBURZ0 without declaring it, it works fine, when running RPCALCG0 (UK), but others, e.g. RPCALCD0 (Germany) throw a syntax error.

    If you do declare it as “tables: T5G01.”, The German payroll will be fine, but you’ have a syntax error for UK due to double declaration.

    Therefore, the form routines need to go into PCBURZGB0, which is used in RPCALCG0 only.

    This has another advantage:

    implementation / support teams from different yountries don’t get into each others’ ways, if two of them work on custom functions or operations at the same time. This extra structure is, why I’d always use the country-specific includes whenever possible. It’s just cleaner.

    hope I could makle this point clear and it helps readers to get the most out of your post.

    happy hacking 🙂

    Sven

    RPCBURZ0 would

    (0) 
    1. Rohit S

      Hi Sven,

      To continue your concern , if we are going to add up any infotypes for INPUT Parameter section(ie Infotype Tab of Characteristics screen) , Will it cause a error for other countries as the INCLUDE is same for all PY Drivers.

      Hi Divya,

      Appreciate you effort for your SAP evangelism.

      Can you highlight how to add Input , Output , Processing parameters

      Regards,

      Rohit.S

      (0) 
  2. Gyöngyi Meszlenyi

    Hi Divya,

    I find this article really helpful, thanks for it!

    I would however also like to know a bit more about how to parametrize the function, and what else I need to do to make it work within the payroll schema.

    We have created a new custom function based on the standard DPKW, I copied all the parameter settings, copied the code and modified it to read our data from infotypes 0008 and 0032.

    The problem is, that the consultant cannot see any data in the payroll schema when run.

    I guess, we should add some lines, or just modify the existing ones for our schema in T52C5 table.

    Any comments on this?

    Regards

    Gyöngyi

    (0) 

Leave a Reply