Versions Compared

Key

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

...

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 Element 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.

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.

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).

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 RemovedImage Added

Test the application.

Image RemovedImage Added

Using Roles in a Workflow

...

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.

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 and Role Approver2, respectively.

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 and View Variables 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

...

View Control lets you add a layer of security that regulates which users or roles can view and edit certain sections of the application. 

View Variables lets you add a catalog of Data Model fields (Booleans) that can be used by the View Control.

To demonstrate this functionality, let us two create two sections in the application:

  1. Request Amount

  2. Approver Comments

In this application, only users with Role Approver1 should be able to edit the Approver Comments, and the Approver Comments should not be visible until the application has reached Level Approval or Complete.

Step 1

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

Step 2

Add a new Form with Label Approver Details.

Add a Text Area in the Form Element and bind it to field ApproverComments in the Data Model.

Image Added

Step 3

To control the visibility of the Approver Details Form, create a new Data Model field ApproverDetailsVisible type Boolean.

The recommended practice is to place the view control variables in a dedicated Structure Type Node in the Data Model. In this example, we use ViewControl.

Image Added

Step 4

Set the Visible Property of the Approver Details Form to ViewControl/ApproverDetailsVisible. Click Save.

After saving, the Approver Details Form is no longer visible because the default value of a Boolean Field is false.

Image Added

Step 5

The objective of this step is to restrict the editing of the Approver Comments to users with Role Approver1 and the Approver Comments should not be visible until the application has reached Level Approval.

Click the Workflow button to open the FAB Process Designer.

In the FAB Process Designer, go to View Variables tab.

Click the Add button and enter the following information:

Variable name: ViewControl/ApproverDetailsVisible

Auto. Set to false at each new Level: Ticked

Click Save.

Image Added
Info

The setting Auto. Set to false at each new Level can be used to reset the related variable to false each time the workflow progresses to a new Level. If unticked, the variable will carry the latest value set from the previous level.

Go to View Control tab.

Click the Add button and enter the following information:

Level: Approve

Role: Approver1

Variable name: ViewControl/ApproverDetailsVisible

Click Save.

Image Added

Using this setting, the View Variable ViewControl/ApproverDetailsVisible is set to true when the workflow is at Level Approve and the current user has Role Approver1.

Hence, when the user FABAPPR1 (Approver1) opens the request, the Approver Details Form will be visible because the Variable ViewControl/ApproverDetailsVisible is set to true. On the other hand, the Approver Details Form will not be visible for the Initiator because it does not have the Role Approver1.

Step 6

The objective of this step is to allow the Initiator to view the Approver Details, but not edit them. To control the editability of the Approver Details Form, create a new Data Model field ApproverDetailsEditable type Boolean.

Image Added

Step 7

Set the Editable Property of the Approver Comments Text Area to ViewControl/ApproverDetailsEditable. Click Save.

Image Added

Step 8

Adjust the Workflow View Control

Click the Workflow button to open the FAB Process Designer.

In the FAB Process Designer, go to View Variables tab.

Click the Add button and enter the following information:

Variable name: ViewControl/ApproverDetailsEditable

Auto. Set to false at each new Level: Ticked

Click Save.

Image Added

Go to View Control tab.

Click the Add button and enter the following information:

Level: Approve

Role: Approver1

Variable name: ViewControl/ApproverDetailsEditable

Click Save.

Image Added

Using this setting, the View Variable ViewControl/ApproverDetailsEditable is set to true when the workflow is at Level Approve and the current user has Role Approver1.

Hence, the Text Area will be editable for Approver1 at the Approve level.

Click the Add button and enter the following information:

Level: Approve

Role: Initiator

Variable name: ViewControl/ApproverDetailsVisible

Click Save.

Image Added

Using this setting, the View Variable ViewControl/ApproverDetailsVisible is set to true when the workflow is at Level Approve and the current user has Role Initiator.

Hence, the Approver Details will be visible but not editable for the Initiator at the Approve level.

Step 9

Optional

Check the application’s View Control settings using different Users.

Initiator: Approver Details visible but not editable

Image Added

Approver: Approver Details visible and editable

Image Added

New Request: Approver Details not visible

Image Added

The Approver Details are not visible when the request is started because there is no View Control setting for Level Start.

Step 10

The objective of this step is to prevent the Request Amount from being changed by any of the Approvers. To control the editability of the Request Amount, create a new Data Model field RequestAmountEditable type Boolean.

Image Added

Step 11

Set the properties of the Request Amount Input.

Type to Float

Editable Property to ViewControl/RequestAmountEditable

Format Options to decimals 2

Click Save.

Image Added