Skip to Content

There are different ways to default values in the infotype. Some of them are listed below:

1. Using dynamic actions.

2. Using user exit/BADI.

3. Using SAP provided features(PE03).

In this tutorial, we will see as how to default values in infotype using user exit.

In SAP HR, we have a very interesting user exit PBAS0001, which have following two components:

Function Exit  Description                                                                                       
EXIT_SAPFP50M_001 Called once in PBO.Customer Default Values for Personnel Administration and Recruitment.
EXIT_SAPFP50M_002 Called for all PAI events.Additional Customer Checks for Personnel Administration and Recruitment and for defaulting values.

Both of the above exit FMs can be used to default the values to the personnel administration and recruitment infotypes(TCLAS ‘A’ and ‘B’).

We can use both the user exit to default the value by calling a custom function module or global class method. This will ensure that when the infotype screen is first rendered(PBO) as well when user perform some actions also the values remain consistent(PAI).

We will now see one real time example wherein we need to default the infotype 0015 begin date to payroll period begin date based on the current system date.

Here are the steps that need to be followed to write a user exit coding to default infotype 0015 values:

1. Goto transaction CMOD, and create a Z project, say ZHR_PA01 as bellow.

1.PNG

2. In the next screen, click on the ‘Enhancement assignments’ button after giving suitable description as below.

2.PNG

3. In the next screen, enter enhancement as PBAS0001 and press components button.

3.PNG

    a. In the next screen activate the exit as below.

3a.PNG

     b. Green LEDs suggest everything is good and we are set to go.

3b.PNG

4. Now double click on EXIT_SAPFP50M_002 and then double click on the include inside the function module ZXPADU02.

Ignore the warning message that pop-ups when double clicking on the include ‘ZXPADU02’ “Program names ZX… are reserved for includes of exit function groups” and press enter to create the include and start up with our coding.

5. Following are the export parameters(variables, structures) whose values are available in our include and can be used further.

4.PNG

Import parameter ‘INNNN’ is of real important to us as this will contain the current infotype record and any changes (default etc), needs to be done inside this structure.

4a.PNG

6. Create and call a function module ‘Z_DEFAULT_IT0015’ so that it can be reused with exporting parameter IPSYST [from above exit exporting parameter] and changing parameter as ‘INNNN’.

Capture.JPG

7. Code inside the function module is as below:

    Here, we are getting the payroll period start date from T549Q table based on the current system date (SY-DATUM) and payroll area (ABKRS) and setting as  begin date of IT0015.

Capture.JPG

Running the action to create a record, we found that the code is being executed while the save action is being performed and creates the begin date based on the above logic as below.

Capture.JPG

After saving the entries, we got infotype record as below.

Capture.JPG

Based on the current system date (30-sep-2014), for our monthly payroll period, begin date of payroll period is saved as 01-sep-2014.

8. But as we saw, initially begin date (Date of origin came) as 31.03.2013, what if we want to default the date when the screen is rendered first time itself (while creating a record through PA30), we can use other user exit EXIT_SAPFP50M_001 (as per step 4 and implementing include ZXPADU01) for this functionality as it is trigerred at PBO. Just cal the same function module that we created for the exit EXIT_SAPFP50M_002.

Capture2.JPG

9. Now try creating a new entry for IT0015 from PA30.

Capture1.JPG

And the outcome is as desired.

Capture1.JPG

Complete code is attached for your reference.

PS: This IT0015 scenario to default begin date is just for the sake of learning, you may use this example to default differnent infotypes and different fields based on user requirement.

To report this post you need to login first.

2 Comments

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

  1. Keabetswe Moerane

    As part of series it really helps to broaden a Functional/Technical users understanding of the various options available to meet customer’s requirements.

    Very well done.

    Thank you for sharing!

    (0) 

Leave a Reply