Skip to Content
Author's profile photo Ronen Weisz

Canceling or changing decision options dynamically

This is an example of how to implement note 1648822 – Dynamic user decision which allows for the decision options to be changed. This example was used in a workflow which was basically a loop on a table of approvers, where the workflow goes up and down the list according to the user’s decision, to set the decision option text and to remove the rejection option from the first approver (he/she has no one reject to…).

In this example ‘level’ is used as the current workflow level in the workflow container, ‘LevelNeeded’ is the number of approvers needed, it and the approvers list was calculated before the workitem started.

The use of this note enabled the approvers to be set dynamically, and to simplicity the workflow actually replacing more then a dozen workflow templates with a single one.

For example, the same workflow template was used for:

  • Requester->manager.
  • Requester->manager->CFO.
  • Requester->manager->Legal department->CFO.

The manager approval option can show:

  • Approve
  • approve and send request to CFO
  • approve and send request to legal department

according to the next step description.

In the implementation of method if_swf_ifs_workitem_exit~event_raised

IF im_event_name = ‘BEF_DECI’.

Get the defined decision alternatives

CALL METHOD im_workitem_context->get_decision_alts

  IMPORTING

     et_decialts = lt_dec_alts

Get the workitem container

CALL METHOD im_workitem_context->get_wf_contianer

   RECEIVING re_container = lo_wf_container

Get data from the workitem contianer

CALL METHOD lo_wf_container->get

  EXPORTING

     name = ‘Level’

  IMPORTING

     value = lv_level

CALL METHOD lo_wf_container->get

  EXPORTING

      name = ‘LevelNeeded’

  IMPORTING

     value = lv_level_needed

Call method lo_wf_container->get

  EXPORTING

     name = ‘Approvers’

  IMPORTING

     value = lt_approvers

Delete the reject option for the first approver

IF lv_level = 1.

  DELETE lt_dec_alts WHERE altkey = ‘0002’.

ENDIF.

Change the approval text

IF lv_level < lv_level_needed.

   lv_next_level = lv_level + 1.

   READ TABLE lt_approvers INDEX  lv_next_level INTO ls_approver.

   CONCATENATE text-001 “Approve and send to

                            ls_approver-decsription

                    INTO ls_dec_alt-alttext separated by space.

   MODIFY TABLE lt_dec_alts  FROM ls_dec_alt INDEX 1 TRANSPORTING alttext .

ENDIF.

Set the changed decision options 

CALL METHOD im_workitem_context->set_decision_alts

  EXPORTING

      et_decialts = lt_dec_alts

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo nitish chawla
      nitish chawla

      I am doing the exact same but not geting any entry in  lt_dec_alts entry table. Any clue with that ?