Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

This article demonstrates how to create an Enhanced Workflow in the FAB Workbench.

Procedure

Creating an Application with a Simple Workflow

Step 1

Create a FAB application in transaction /n/IQX/FAB. Define the Properties, set the Workflow Mode to Process, and click Save.

Step 2

Click the Workflow button to open the FAB Process Designer.

In the FAB Process Designer, click the Template button and select Draft, Submit, Approve.

Click Yes in the Apply Template? dialog.

The following Process Flow will be generated. Click Save & Close.

Save the application and notice that the Draft and Submit actions were added in the Footer bar.

Step 3

Add a FAB Process Flow control to the Page to display the Process Flow Diagram in the application.

Using a Requirement in a Workflow

Requirements can be added to the Process Flow to specify whether a Task will be required or not depending on the conditions set. For example, you can set a requirement in the Workflow where an Approval Task is not required if the requested amount is less than $1000. To demonstrate this scenario, follow the steps below.

Step 1

Create a Data Model field by right-clicking on the Root NodeAdd Field of TypeFloat. Set the Field Name and Description to RequestAmount.

Step 2

Add an Input control in the Form Container and bind it to field RequestAmount in the Data Model.

You can drag and drop the Data Model Field onto the Form Element to easily create the Input Control and the binding.

Set the Label of the Input control to Request Amount.

Remove the Label of the Form Container.

Set the Label of the Form to Request Details.

Click Save.

Step 3

Click the Workflow button to open the FAB Process Designer.

Go to the Requirements tab. Click the Add button and enter the requirement details. In this example, we will use the following values:

Id: AMOUNT_GT_1000

Description: Amount > $1000

Go to the Tasks tab. Click the Requirements button of the Approve task and select the requirement. Click OK.

Go to the Process Flow tab and the requirement is now reflected in the Approve task.

Click Save & close.

Step 4

Implement the Requirement in ABAP by clicking the Code button.

In the Form Life-Cycle dialog, click Auto-Generate Class Name button then click Generate Class.

In the Workflow section, click the ABAP Routine button next to Evaluate Task/Outcome Requirements to create the implementation of the REQUIREMENT_EVALUATE method. Click the button again to open the class editor.

Implement the following logic for the Requirement and Activate.

method REQUIREMENT_EVALUATE.
    e_required = abap_false.
    MOVE-CORRESPONDING cr_data TO gs_data.

    CASE i_requirement_id.
      WHEN 'AMOUNT_GT_1000'.
        IF gs_data-requestamount > 1000.
          e_required = abap_true.
        ELSE.
          e_required = abap_false.
        ENDIF.
    ENDCASE.

endmethod.

In the Form Life-Cycle dialog, click Save.

Step 5

Add an Action to Update the Process Flow Diagram when the Request Amount is Changed (optional).

Configure a Default Path. Go to Workflow → Tasks → Actions (Approve Task).

In the APPROVE action, click the Behaviour button and tick Default Path. Click OK.

In the FAB Process Designer, click Save & Close.

Test the application.

Using Roles in a Workflow

Roles control who are the recipients of Workflow Tasks. Roles are assigned to Tasks and an ABAP code is used to define the actual users for each Role. A user-exit is provided for this purpose DETERMINE_APPROVERS_FOR_ROLE.

Step 1

Implement the Role Determination in ABAP by clicking the Code button.

In the Workflow section, click the ABAP Routine button next to Determine Approvers for Roles to create the implementation of the DETERMINE_APPROVERS_FOR_ROLE method. Click the button again to open the class editor.

Implement the following logic for the user assignment and Activate.

  METHOD determine_approvers_for_role.

*   NOTE - for this to work as intended, do not implement DETERMINE_APPROVERS_ON_SAVE, or call SUPER->DETERMINE_APPROVERS_ON_SAVE method if you do implement it

*   example 1 (manually define approvers)
    FIELD-SYMBOLS: <fs_approvers> LIKE LINE OF ct_approvers.

    CASE i_role.

      WHEN 'Approver1'.

        APPEND INITIAL LINE TO ct_approvers ASSIGNING <fs_approvers>.
        <fs_approvers>-approval_level = i_level.
        <fs_approvers>-node_id = i_node.
        <fs_approvers>-role_id = i_role.
        <fs_approvers>-zinstance = i_instance.
        <fs_approvers>-objty = 'US'.
        <fs_approvers>-objid = 'FABAPPR1'.


     WHEN 'Approver2'.

        APPEND INITIAL LINE TO ct_approvers ASSIGNING <fs_approvers>.
        <fs_approvers>-approval_level = i_level.
        <fs_approvers>-node_id = i_node.
        <fs_approvers>-role_id = i_role.
        <fs_approvers>-zinstance = i_instance.
        <fs_approvers>-objty = 'US'.
        <fs_approvers>-objid = 'FABAPPR2'.


    ENDCASE.

ENDMETHOD.

Note here that we have assigned two user IDs FABAPPR1 and FABAPPR2 to Role Approver1.

In the Form Life-Cycle dialog, click Save.

Once DETERMINE_APPROVERS_FOR_ROLE has been implemented, it is possible to check the agents for each Task by clicking on the Task in the Process Flow Diagram of the application.

Using View Control in a Workflow

It is often desired that certain sections of the App are only visible to certain users at different stages of the Workflow. For this capability, we can use the concept of View Control to restrict the visibility or editability of sections depending on the user's Role.

To demonstrate, let us two sections:

  1. Submission Details

  2. Approver Comments

Using Parallel Tasks in a Workflow

Using Locking in a Workflow

  • No labels