Author: Jayanthi Jayaraman
Submitted: 02.01.2009
Related Links:
IMG Activity Documentation
http://it.toolbox.com/wiki/index.php/Dynamic_Action#Dynamic_Actions
Applies to:
SAP ECC 6.0 - ABAP
Summary
This tutorial will explain how to Configure Dynamic Action. This is being explained by illustrating the below two scenarios.
1) Default the Pay scale Type, Area and Group based on the Employee group and subgroup.
2) Default the Valid Until field in Contract Elements Infotype based on the hiring date.
Prerequisite
The action needs to be identified for which dynamic action is to be configured. Here for the action 'Test Hiring', we are going to configure the dynamic action. Make sure that the Hiring Action is properly configured in infogroup. Ensure that Personnel Action types are configured for the action (It should mention infogroup name).
Infogroup: Go to SPRO->Personnel Management->Personnel Administration->Customizing Procedures->Actions->Define Infogroups for infogroup configuration.
Personnel Action Types: Go to SPRO->Personnel Management->Personnel Administration->Customizing Procedures->Actions->Set up Personnel Actions (choose Personnel Action Types)
About Dynamic Action
Go to SPRO->Personnel Management->Personnel Administration->Customizing Procedures->Dynamic Actions.Dynamic Action is used to control the action in infotypes dynamically based on some condition.The dynamic action can be performed when creating/changing/deleting records in infotypes.T588Z is the table which holds all the information about dynamic actions.

The table structure itself explains about the field in dynamic action.
INFTY - First field which specifies the infotype should be responsible to trigger the action.
SUBTY - Respective subtype of the infotype. This is optional.
FNAME- Name of the field in the infotype. This is again not mandatory.
OPERA- Name of the operation performed in the infotype. That is entry in this field will execute the Dynamic action when that operation is performed to the infotype in action.Ex: when a record is created in IT0001, do this action.
The possible values are:
- 00 for Independent of the current function carried out
- 02 for Change
- 04 for Create
- 06 for Change and create
- 08 for Delete
- 10 for Change and delete
- 12 for Create and delete
SEQNO: This field specifies the sequence number.
KENNZ: This field specifies about the nature of the action to be performed.
The value can be:
- P - Plausibility Check - This is used for checking a condition. Operators <, >, <=, >=, = and <> can be used. Consecutive checks must be linked by a logical AND. Logical OR links must also be indicated by a /X. Note that all checks with OR links must have a /X.
- I - 'I' is used to maintain Infotype. Maintenance includes actions INS, COP, MOD and DEL.
- W- Using 'W', default values can be set for the infotype field. 'Q' values cannot be defaulted because values for these fields are derived from the corresponding P fields.
- V- Cross-reference to another step. Using 'V", we can combine fields to groups. The variable function part contains the value in the field which follows the "field" column.
- F- TO call external or internal subroutine.
- M- Sending mail
- Any other entries refer to "comment line".
- VINFO - This field is used to brief the exact action.
Configuring Dynamic Action
Scenario 1:
To default the Pay scale Type, Area and Group based on the Employee group and subgroup. We need this to be done after Organizational Assignment changes. We are going to default the Pay Scale Type and Area as 'TF' and Group as 'COMTECHF' in infotype 0008. We are doing to this only if the employee group is '0' and employee subgroup is either 'AW' or '11'.

Infotype is 0001.Here specifying the subtype and field name is not required.This will happen when the record is created in 0001.So we have used '04' for operation.We need to mention the sequential numbers without contrary to the existing numbers.We have used the nature of action as 'P' for the first three lines to specify conditions.We have used /X to specify the OR condition.First line specifies the employee group should be equal to '0'. Second line and Third line specifies the employee subgroup should be either equal to 'AW' or '11'. We have used 'I' in fourth line to maintain infotype operation. Insertion will be done for infotype 8.In the rest of the lines, we are specifying the default values to be set for the fields in the infotype.
Scenario 2:
To default the Valid Until field in Contract Elements Infotype based on the begin date of Organizational assignment by using a subroutine from a program.

Create a program zzz_jay(as specified in dynamic action) with subroutine GETDATE.
Write the following code in the program.

RP50D is the structure which is meant for HR: Return Fields for Dynamic Actions.
In the program, we are going to add 365 days to the hiring date and populating it as default for Valid Until field in infotype 0016.
First line in Dynamic Action specifies that Subroutine getdate is called in program zzz_jay.
Second line is used to maintain(Insert a record) in infotype 0016.
Third line is defaulting the value for the field Valid Until from the program calculation.
Output
Execute the Test Hiring Action from PA40.

Pay Scale Type, Area and Group is defaulted. 
Valid Until is defaulted in Contract Elements. 