Defining Roles Using Function to Be Executed  

Use

You use function modules for role definition when very complex selection criteria are required for agent determination, in other words, when it is not possible to use responsibilities to model agent selection. Function modules provide you with a very powerful tool for determining the agent of a task in Workflow.

Prerequisites

  1. You must specify what job you expect the workflow to perform. Depending on this, you decide whether you want to use a standard function module delivered by SAP or your own function module that suits your requirements exactly. To avoid having to display the coding of the function module during the procedure, you should be absolutely sure about what container elements are required by the function module beforehand. If you do need to check the coding of a function module, on the Standard Role: Display screen, choose Goto ® Function module.
  1. You created your own function module, where relevant. The function module must enable the following process:
    1. The role container transferred as the table parameter AC_CONTAINER is read using the macro commands SWC_GET_ELEMENT and SWC_GET_TABLE .
    2. 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 a complete list of all macro commands, refer to:

      Macro Instructions for Processing a Container Instance in a Program

      Macro Instructions for Accessing Objects, Attributes and Methods

    3. The role parameters are used to determine the relevant agent. At its simplest, this sub-program consists of a loop on a (Customizing) table, from which the agent is selected.
    4. The table ACTOR_TAB is filled.

(See also Example)

  1. You have created a role. To call the transaction for processing roles, access the SAP menu and choose Tools ® Business Workflow ® Development ® Definition tools ® Standard roles ® Create.

Procedure

On the Standard Role: Create screen:

  1. Select Function to be executed.
  2. Enter the name of the function module. For example, if you want to use a function module for reporting on the organizational structure, you can enter RH_GET_STRUCTURE.
  3. Save the role.
  4. Depending on what function module you used, the field Evaluation path appears.

  5. Enter the relevant evaluation path and choose Save.
  6. Choose Container Definition.
  7. The Standard Role: Process Container screen appears.

  8. Choose Create. The Create Element dialog box appears.
  9. If you want to use Data Dictionary fields, choose Yes.
  10. The Create with Data Dictionary Field Defaults dialog box appears.

  11. Specify the table from which you want to select fields and Choose Continue.
  12. The table appears.

  13. Select the fields that you want to appear in the container definition. Bear in mind that these are the elements required by the function module.
  14. The system prompts you to confirm the texts for the container elements.

  15. Choose Back.

The Standard Role:Create screen appears.

Result

Workflow executes the function module and, depending on the container data, returns a list of possible agents.