You are on page 1of 5

Unleash the Power of Dynamic Actions: Tips and Tricks to Get the Best Results

by Rehan Zaidi, SAP Technical Consultant, Siemens Pakistan

The following provides more information about how dynamic actions work.
Brief Technical Backgrounder
Dynamic actions are activities triggered automatically by R/3 during infotype
maintenance. The database table T588Z is a set of records that stores information related
to dynamic actions. The module pool MPNNNN00 of all infotypes includes the standard
program MPPERS00. That program contains routines for calling dynamic action
functionality. Each time you press the save button on the maintenance screen of an
infotype, the PAI (process after input) section of the screen calls these routines. This is to
check the table T588Z for starting any dynamic action relevant to the current infotype.

The maintenance of dynamic actions is done via the view V_T588Z, as shown in Figure
1 (IMG menu path Personnel Management>Global Settings in Personnel
Management>Basic Settings>Infotypes>Create Dynamic Actions).

Figure 1 Maintenance screen for dynamic actions

A dynamic action has the following components.

Infotype Number (INFTY): specifies the infotype for which you want the dynamic
action triggered
Subtype (SUBTY): narrows the focus to a specific subtype

Field Name (FIELDN): starts your action when a maintenance function is performed on
a particular field

Function (FC): specifies the various maintenance operations to which your dynamic
action would respond. They are 02 (change); 04 (create); 06 (create and change); 08
(delete); 10 (change and delete); 12 (create and delete). Dynamic actions are only
applicable in maintenance operations, not in display functions.

Sequence Number (NO): refers to a sequential number.

Step (A): specifies a particular type of action. No dynamic action is executed if the
function character has a value other than one of the following:
P: Plausibility checks, which allow you to check certain conditions.
I: Calls an infotype for processing
W: Called after the I statement and used to assign values to screen fields while
creating or copying another infotype record through the I statement
F: Calls a FORM routine (subroutines in ABAP) during your action. The
routine may reside in or out the module pool MPNNNN00.
V: Lets you treat collectively a number of fields for which you want to define a
common dynamic action
M: Sends SAP Office mail

Variable function part: The variable function part along with the step indicator forms
the core part of your action. It specifies the processing details when the dynamic action is
triggered. For example:

Requirement: When the postal code or the city of an employee’s permanent residence is
changed in infotype 0006, an email should be sent to the administrator.

INFTY SUBTY FIELDN FC NO. STEP VARIABLE FUNCTION


0006 1 ORT01 06 001 V PSTLZ
0006 1 PSTLZ 06 002 M M0001

The V statement on line 001 is used to link the two fields to the M statement. The
statements relevant to field PSTLZ are also applicable to the ORT01 field.
When a record is created or changed in infotype 0006 of permanent address, an email is
sent using the feature M0001. Information such as the recipient address, subject, and
content of the mail is derived from M0001.

Requirement: You want to create two allowances (2001 and 2002) in infotype 0014 with
the creation of Basic Pay - 0008 for employees belonging to Personnel Sub-area SUB1
and having either Grade 1 or Grade 2. The Allowance 2001 must be created in online
mode, whereas the 2002 is in the background.
INFTY SUBTY FIELDN FC NO. STEP VARIABLE FUNCTION

0008 06 001 P P0001-BTRTL<>'SUB1'


0008 06 002 P P0008-TRFGR='GRADE 1' /X
0008 06 003 P P0008-TRFGR='GRADE 2' /X
0008 06 004 I INS,0014,2001,,(P0008-BEGDA),(P0008-ENDDA)
0008 06 005 I INS,0014,2001,,20020101,99991231/D
0008 06 006 W P0014-BETRG='1800'
The lines 001-003 formulate the condition for the action (note the OR logic achieved
by /X). The insertion lines 004, 005, and 006 are executed only when the conditions
mentioned are true.

Requirement : On successful deletion of an infotype 0015 record having subtype ‘1234’,


all records with subtype ‘1235’ and ‘1236’ should be deleted automatically.
INFTY SUBTY FIELDN FC NO. STEP VARIABLE FUNCTION

0015 08 001 P T500P-MOLGA='99'


0015 08 002 P P0015-LGART='1234'
0015 08 003 I DEL,15,1235 /D
0015 08 004 P T500P-MOLGA='99'
0015 08 005 P P0015-LGART='1234'
0015 08 006 I DEL,15,1236 /D

The first two lines check that the record being deleted belongs to country grouping
international (code 99) and that the wage type is ‘1234’. If this is found true, the two
delete statements are fired, each deleting all the records having wage type ‘1235’ and
‘1236’.

If you are puzzled about how many dynamic actions exist for a particular set of lines in
table T588Z, follow a simple rule: Each I, F, and M statement is a separate dynamic
action. In the following example, two dynamic actions are executed for the same
combination of SUBTYP,FIELD/FUNCTION. One action creates infotype 0041 if the
reason is 01 and another action creates infotype 8 if the reason is 02.

0000 06 001 P PSPAR-MASSG=’01’


0000 06 002 I INS,0041,,,(P0000-BEGDA),(P0000-ENDDA)/D
0000 06 003 P PSPAR-MASSG=’02’
0000 06 004 I INS,0008,,,(P0000-BEGDA),(P0000-ENDDA)/D

EXAMPLE
Let's look at an example of an action. These statements check the country grouping and
the action type. If these match the desired criteria, a record is inserted in infotype 41
having date types U1 and U2. When you create a new record (04) in infotype 0000, this
dynamic action checks the following conditions:
Is T001P-MOLGA equal to ‘99’?
Is PSPAR-MASSN equals ‘01’?
If both conditions specified by the P statements are found to be true, then a new record is
created in infotype 41 in background mode. The values specified by the W statements are
also assigned to the corresponding screen fields of infotype 0041. If the condition defined
by the P statement is not fulfilled, the system skips the subsequent commands until it
reaches a new plausibility check or F statement.

INFTY SUBTY FIELDN FC NO. STEP VARIABLE FUNCTION


0000 04 001 P T001P-MOLGA='99'
0000 04 002 P PSPAR-MASSN='01'

0000 04 003 I INS,0041,,,(P0000-BEGDA),(P0000-ENDDA)/D


0000 04 004 W P0041-DAR01='U1'
0000 04 005 W P0041-DAT01=P0000-BEGDA
0000 04 006 W P0041-DAR02='U2'
0000 04 007 W P0041-DAT02=P0000-BEGDA

The following is a supplement to the section on "Rules for Working with Dynamic
Actions."

External Factors That May Cause Dynamic Actions to Fail.


Even if you have strictly followed the guidelines, you may still have problems with the
execution of your action. This is because your dynamic action is dependent on numerous
external factors. Let's consider a few:

• You may encounter problems assigning values to fields having the form
QNNNN-FIELDNAME. These are fields that are visible on the infotype screen
Examples are Q0082-datwc and Q0112-PZIN3. There lies a chance that these
fields are overwritten by values computed during the PBO and PAI modules of
the infotype screen. For this reason, assigning values to these fields in W
statements may or may not have any practical effect. However, you can use them
in your P statements.

• You may experience problems when your dynamic action calls an infotype that
has its own dynamic action written. When the second infotype is called and the
user presses the save button, the dynamic action of the second infotype runs. It
may be a problem if the second dynamic action calls a FORM routine that takes
you to an undesirable screen for the first one.

• Dynamic actions are turned off during the execution of batch input sessions. This
is a standard behavior. Any updates that happen via dynamic actions in online
mode must be explicitly included in the BDC session.
Rehan Zaidi is working in Siemens Pakistan as an SAP technical consultant. The major
part of his experience includes development of country- and customer-specific programs
for the SAP HR module. Having ample technical knowledge (including RFC, ALE,
BAPI, and Workflow), Rehan is also conversant with many of the module’s functional
features. He has also contributed articles to the SAP Professional Journal. He can be
reached at rehan.zaidi@consultant.com or rehan.zaidi@siemens.com.