cancel
Showing results for 
Search instead for 
Did you mean: 

Remove optinos in user decision task dinamically

RicardoRomero_1
Active Contributor
0 Kudos

Hi all,

I have an user decision task wich have several options. I want to remove (or deactivate) some of these options dinamically or under some conditions...

Do you know how can i do it?

May be it's possible to do with a program exit but i don't find any method in the class for do that.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member188827
Active Contributor
0 Kudos

Instead of using one decision task, you can use "Multiple Conditions" step and assign a different decision task to each condition branch. In this way, a different decision task will be sent based on condition at runtime,

RicardoRomero_1
Active Contributor
0 Kudos

Yes, I can do it in that way, but if I do it I need to repeat the logic of the same options in each branch... And this a static way to do it, if I want to have more freedom in chose what options will be displayed I can't...

But, thanks for the suggestion...

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

Finally, I had to do it. I put the steps in case anyone is interested:

- Create a Decision Task in workflow builder. Replace the Task used in Control tab by a custom one. You need to create a copy of the standard task 00008267. In my case I've created the task 99000001.

- The FM to get the options and texts is SWU_GET_DECISION_TEXT_TITLE. We need to create an enhancement point at the end of this FM. I've created a method in a custom class to embed all my code:

TRY.
  CALL METHOD zcl_im_wf_dec_task=>zz_mod_decision_task
    EXPORTING
      wiid             = wiid
    changing
      ct_decision_text = decision_text[].
 CATCH cx_root.

 ENDTRY.

- This method has the following parameters:


WIID	                TYPE SWW_WIID
CT_DECISION_TEXT	TYPE ANY TABLE

With the following code you can change the description of the options you want or delete some options dinamically:

DATA: l_wi_handle  TYPE REF TO if_swf_run_wim_internal,
      lo_wi_dialog TYPE REF TO cl_swf_run_wim_dialog,
      lo_container TYPE REF TO if_swf_cnt_container,
      ls_wi_head   TYPE sww_wihead,
      lv_key       TYPE sww_wi2obj-instid,
      lv_bstyp     TYPE ebstyp.

FIELD-SYMBOLS: <ls> TYPE ANY.

* Obtain the header:
TRY.
    CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
      EXPORTING
        im_wiid     = wiid
      RECEIVING
        re_instance = l_wi_handle.
    lo_wi_dialog ?= l_wi_handle.
    ls_wi_head = lo_wi_dialog->if_swf_run_wim_internal~m_sww_wihead.
  CATCH cx_swf_run_wim .
  CATCH cx_root.
ENDTRY.

* Read the container (if you want...):
TRY.
    CALL METHOD lo_wi_dialog->if_swf_run_wim_wfm~get_wi_container
      RECEIVING
        re_container = lo_container.
  CATCH cx_swf_run_wim .
ENDTRY.

* Read the Key:
SELECT SINGLE instid INTO lv_key
 FROM sww_wi2obj
 WHERE top_wi_id EQ ls_wi_head-top_wi_id.

* In this example is a workflow for PO;
SELECT SINGLE bstyp INTO lv_bstyp
 FROM ekko WHERE ebeln EQ lv_key.

* Depending on the Task;
CASE ls_wi_head-wi_rh_task.
*  Authorize   
  WHEN 'TS99000001'.
    LOOP AT ct_decision_text ASSIGNING <ls>.
*       The first 4 characters are the number of the option.
*       The following characters are the description.

*       Delete an option;
      IF <ls>(4) EQ '0001' AND lv_bstyp EQ 'F'.
        DELETE ct_decision_text INDEX sy-tabix.
        CONTINUE.
      ENDIF.

*       Change the description:
      IF <ls>(4) EQ '0002'.
        IF lv_bstyp EQ 'K'.
          <ls>+4 = 'Authorize'.
        ELSE.
          <ls>+4 = 'Continue with the process'.
        ENDIF.
      ENDIF.
      
    ENDLOOP.
ENDCASE.

Former Member
0 Kudos

You know what? SAP has recently brought certain options to create dynamic user decisions. This blog explaining how to do it was published just few days ago:

Regards,

Karri

RicardoRomero_1
Active Contributor
0 Kudos

Ooops ! Thats sounds great !

I already have a program exit in my task for other things. But I need to apply the [Note 1648822 - Dynamic user decision|https://websmp130.sap-ag.de/sap(bD1lcyZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1648822] for use this new method.

Thanks for the info !

Former Member
0 Kudos

Hi Ricardo,

Your post i'ts very good I have implemented and It's working perfect.

But I have another problem.. in the user decisions there is one option "Cancel, and keep work Item in inbox" I need to remove that option from the decisions. but its not coming in the table in the function module, It seems like the function module is just getting the decisions we created. do you know if there is any way I can remove this cancel option from the decision. It is an urgent requirement and I haven't found anything yet. Thanks.

RicardoRomero_1
Active Contributor
0 Kudos

Hi Freddy,

I don't know if someone knows how to do it, but I think is not possible to remove the option "Cancel, and keep work Item in inbox".

Regards,

bpawanchand
Active Contributor
0 Kudos

Hi Freddy,

  You cannot remove that particular option If I am not wrong, because the screen what ever you seeing when you execute a decision workitem is a kind of HTM page which is designed in SMW0. So after lots of processing it replaces  the values what ever you defined in the workflow decision step. but the last option is by default populated before the values are replaced .

Regards

Pavan

Former Member
0 Kudos

Hi Guys,

Thanks for your answers, But I did it, I have removed the cancel and keep work item in inbox option.. I had to create an enhancement in include LSWU2F10.

from here I created my custom method to modify table: lt_merge_table

based on my requirement I remove the cancel option taking into account that I should remove this only when my workflow is triggered. after that is working perfectly now.

regards

Freddy

Former Member
0 Kudos

Hi Ricardo,

Do you know if it is feasible to add possible decision outcomes with your program above instead of deleting outcomes?

Thank you,

Javier

RicardoRomero_1
Active Contributor
0 Kudos

Hola Javier,

If I've not misunderstood your question you want to add new decisions dynamically to the task, don't you?

I think this is not possible, as you need to create the decisions in the workflow builder to create the branch of each decision.

Regards,
Ricardo.

Former Member
0 Kudos

Gracias Ricardo,

I was thinking of creating a non-decision task, just a pure on-line standard task and try to create outcomes dynamically..I'll let you know if it is possible...

Saludos,

Javi

Former Member
0 Kudos

Hi,

Unless someone has better ideas, I would give you one. Don't start to mess with the standard decision task. I don't think that it would be easy to make it "dynamic". Much more easy probably to make your own simple screen, that can have whatever functionality (dynamic buttons, etc.) that you want.

Or maybe it would be easier to have the buttons there, but give an error to the user that he cannot use it, or whatever.

If you find out that it is possible to enhance the decision step in a way that you described, I would be interested to hear about that.

Regards,

Karri

RicardoRomero_1
Active Contributor
0 Kudos

Hi Karri,

Finally it's not necessary to do it in my project. But I've just found a solution:

All the standard user decission tasks call to the method PROCESS of bussiness object DECISION.

Within this method there is a FM called SWU_PROCESS_MANUEL_DECISION.

And within this FM there is a call to another FM called SWU_GET_DECISION_TEXT_TITLE.

This FM return a table called decision_text. Here you have all the options.

I've tried by debugging to remove some entries and works fine. The options are hidden and the workflow works fine.

So, you can create an enhancement point at the end of the FM SWU_GET_DECISION_TEXT_TITLE and remove the options you want.

Regards,

Ricardo.

Edited by: Ricardo Romero Mata on Jan 19, 2012 5:24 PM