Skip to Content

In this tutorial, we will see how to use BADI to default values in PA Infotypes. This tutorial will show how we will default values using a BADI and we will be using the same business scenario as used earlier in the User Exit to Default values in PA Infotypes tutorial, where we have used customer exit to default values in PA infotype.

In SAP HR, we have a BADI HRPAD00INFTY, which can be used to default the values in PA Infotype as well as perform additional check if required (in PAI event while performing any action).

This BADI implementation contains the following method which can be implemented as per our requirement.

Method Description (Usage)
BEFORE_OUTPUT This method is called at the PBO event, i.e when the infotype screen is rendered for display.
AFTER_INPUT This method is called at the PAI event, i.e. when user performs some action in the rendered infoype screen.
IN_UPDATE This method is call during update when there is update task is being carried in PA infotpe.

We can use first two methods of the above BADI 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. Go to transaction SE19, create implementation of classic BADI HRPAD00INFTY and give implementation name (name should be in SAP customer name space, i.e should start from ‘Y’ or ‘Z’).

1.PNG

Pressing ‘Create Impl.’ button, pop-up window triggers, enter the name of implementation (in customer name space) and enter.

2.JPG

2.Click on activate button to save and activate the BADI implementation.

3.JPG

Once successfully activated, Runtime Behavior text changes to ‘Implementation will be called’.

4.JPG

3. Goto ‘Interface’ tab of our implementation, following methods of the BADI implementation is available for coding.

5.JPG

4. Double click on the method name to write our custom logic in the implementation. Add below code in the BEFORE_OUTPUT and AFTER_INPUT method of our implementation.

Class ZCL_IM_DEF_0015 is created by SAP and is based on the name of our implementation in step 1 (ZDEF_0015).

6.JPG

In the code it is important to understand that we are directly fetching the runtime value of IT0015 record throgh the standard program associated (MP001500) and storing it in field symbol and changing field symbol later so that changes reflect to infotype record as well.

This is required as unlike user exit all the parameters available for this method are importing parameter and there are no changing parameter available as below.

7.JPG

5. When we try creating new entry in infotype 15 using PA30, output is as per our requirement.

8.JPG

Pressing create button, date of origin (begda) value is defaulted with correct value. [Based on current date- 13-apr-2015, pay period begin date 01-apr-2015 is defaulted].

9.JPG

6. This BADI triggers for PA20/PA30/PA40 transactions. But for an existing PA20 record, there seems to be an issue encountered here.

Output before activating BADI (PA20):

10.JPG

Output after activating BADI (PA20):

11.JPG

This is incorrect and our system should display the same value as stored in the back-end table (which is in first screen shot – 10-jan-2015). To resolve this issue we will need to add some logic which will only change the infotype field data when there is any change operation being carried out.

To determine which operation is currently happening in the Infotype, importing parameter IPSYST is of much importance. This structure parameter have a field called IOPER which determines the Infotype operation. following vales are expected in this field.

IOPER Values Meaning and Significance
DIS DISPLAY
DIS2 DISPLAY_NO_LIST
MOD MODIFY
INS INSERT
COP COPY
DEL DELETE
LIS0 LIST_DISPLAY
LIS1 LIST_MODIFY
LIS9 LIST_DELIMIT
ENQ ENQUEUE_RECORD

7. Final code logic will be as below.

12.JPG

Now, displaying same pernr with BADI activated gives correct results.

10.JPG

To report this post you need to login first.

1 Comment

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

Leave a Reply