on 10-13-2011 5:57 PM
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.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.