Defining Rules Using Function to Be Executed
Use
You use function modules for defining agent determination rules when very complex selection criteria, which cannot be depicted by other rule categories, are required for agent determination.
Prerequisites
You have decided what you want the workflow to do. Depending on that, you decide whether you want to use a function module delivered by SAP or a function module of your own that suits your requirements exactly. To avoid having to display the source text of the function module during the procedure, you should be absolutely sure about which container elements are required by the function module beforehand. If you do need to check the source text of a function module, on the Rule: Display screen, choose Goto ®
Function module.
The function module must enable the following process:
- The rule container transferred as the table parameter
AC_CONTAINER is read using the macro commands SWC_GET_ELEMENT and SWC_GET_TABLE.
If you want to have the macro commands available, you must integrate the Include
<CNTN01> as a sub-report for shared use. <CNTN01> mainly contains the macro command definitions for creating and processing a container instance.
For further information, see
Macro Commands for Processing a Container Instance in a Program and Macro Commands for Accessing Objects, Attributes, and Methods.
The rule parameters are used to determine the responsible agent(s). At its simplest, this sub-program consists of a loop on a (Customizing) table, from which the agent is selected.
The table ACTOR_TAB is filled.
For an example of such a function module, see
Function Module for Rule Resolution.
You are on the Rule: Change or Rule: Create screen.
Procedure
Enter a short description and a name for the rule.
As the rule category, choose Agent Determination: Function to be Executed.
Enter the name of the function module.
If you want to evaluate the organizational structure, use the function module
RH_GET_STRUCTURE. For more information, see Defining Rules Using Evaluation Paths.
The function module delivered by SAP,
SWX_GET_MANAGER, determines the manager of an employee, based on the organizational plan.
Switch to the Container tab page.
Choose .
The Change Container Element dialog box appears.
Make entries in the Element, Name, and Short Description fields.
Create either an object reference or an ABAP dictionary reference for the container element. As a guide, use the data type reference of the container element of the workflow or task container from which the container will be filled at runtime.
On the Properties tab page, set, if required, the Obligatory and/or Multiline indicators.
Repeat steps 5 to 8 until you have defined all the necessary elements for the rule container.
Save the rule.
Result
When the rule is executed, the function module receives the container elements from the rule container, and returns agents as a result.
For an example of this kind of rule, see the
Rule for Determining the Manager of a User.