Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Step 1

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

Image RemovedImage Added

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.

Image RemovedImage Added

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.

...

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.

Info

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.

Image RemovedImage Added

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.

Image RemovedImage Added

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

Image RemovedImage Added

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 it again to open the class editor.

Implement the following logic for the Requirement and Activate.

Code Block
languageabap
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).

Image Added

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.

Image Added

Test the application.

Image Added

Adding Roles to 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 it again to open the class editor.

Implement the following logic for the user assignment and Activate.

Code Block
languageabap
  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.