Hide decision work item button(s) during display in SAP Workflow

Author : Biswanath Guha

 
Introduction : SAP Workflow contains several tasks to accomplish the business needs. It may contain several background tasks as well as foreground tasks . In work flow provides a decision work item to user intervention to notify the end user or to complete the task manually after error correction. User usually get two or more options to proceed the workflow.

Problem Description :  In this, user decision work item, sometimes user do not want to see all the buttons at a time. Buttons should be visible for specific scenario. So we need to invisible the button to display.

Example : Workflow WFDynBtn contains a user decision task with multiple buttons.

Work item consists below task : 

  1. ‘Button 1’ used to solve the purpose of Logic 1
  2. ‘Button 2’ used for Logic 2
  3. ‘Button 3’ is for Logic 3
  4. ‘Cancel and keep work item in inbox’

Logic are as follows : 

  1. Logic 1 sends a mail to the user inbox with the message ‘Button 1 pressed’.
  2. Similarly for Logic 2 and 3 mail will be send to the user inbox with the message ‘Button 2 / 3 pressed’.

Please refer attached Figure – 1.

Solution : 

Step 1 : Create a new custom BOR Object. Say, ZZDECISION BOR object with super type DECISION. 

Step 2 : Create a new method ZPROCESS with importing internal table of buttons number . In this internal table list : 1 denotes ‘Button 1’, 2 denotes ‘Button 2’ and 3 denotes ‘Button 3’. Internal table No_Display_Opt holds the data i.e. 1or 2 or 3 numbers of the work item options to make that particular button invisible.

Here the workflow deletes those restricted buttons from the option internal table. This option internal table is exported to a memory id. 

Code : 

CALL FUNCTION ‘SWU_GET_DECISION_TEXT_TITLE’
EXPORTING
wiid = wi_id
  at_creation =
‘ ‘
IMPORTING
decision_title = title_text
  
TABLES
decision_text = lt_text
decision_option = lt_option
  
EXCEPTIONS
node_not_found =
1
text_not_found =
2
workflow_not_found =
3
OTHERS = 4.
IF sy-subrc = 0.

LOOP AT lt_nodisplayopt.
  
DELETE lt_text INDEX lt_nodisplayopt.
  
ENDLOOP.

LOOP AT lt_nodisplayopt.
  
DELETE lt_option WHERE altkey = lt_nodisplayopt.
  
ENDLOOP.

IF lt_text[] IS INITIAL AND lt_option[] IS INITIAL.
lv_deleteall =
‘X’.
ENDIF.

EXPORT lt_text lt_option lv_deleteall TO MEMORY ID wi_id.

   ENDIF.

Step 3 : Implicitly enhance the function module SWU_INTERN_GET_DECISION_OPT

Read the memory id and get the Option internal table and assign it to final internal table decision option .

ENHANCEMENT 1 ZDECISION_OPT.  “active version

DATA : lt_option  TYPE swu_deciopts OCCURS 5 WITH HEADER LINE,
lv_deleteall(
1).

import lt_option lv_deleteall from MEMORY id wiid.

IF lv_deleteall = ‘X’ AND lt_option[] IS INITIAL.
refresh DECISION_OPTION.
FREE MEMORY ID wiid.
ELSEIF NOT lt_option[] IS INITIAL.
refresh DECISION_OPTION.

DECISION_OPTION[] = lt_option[].
FREE MEMORY ID wiid.
ENDIF.

ENDENHANCEMENT.

 
 
‘Button 1’ will be suppressed in the work item. Only button 2 & 3 are visible.

Please refer attached Figure – 2.

Log display : In the log, though there is 3 path will show , only restricted button will not visible in the work item.

Please refer attached Figure – 3.

Conclusion : In this above process the button of the work flow of work item gets hide to the end user. The process helps us to put multiple logic at a single work item.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply