Еще вариант.
1. Создаем ФМ
Code:
FUNCTION zcfa_inplace_decision_process.
*"----------------------------------------------------------------------
*"*"Ëîêàëüíûé èíòåðôåéñ:
*" IMPORTING
*" REFERENCE(I_INFO) TYPE SWR_WIPR_I
*" EXPORTING
*" REFERENCE(E_INFO) TYPE SWR_WIPR_E
*"----------------------------------------------------------------------
TYPE-POOLS: swlc.
CONSTANTS $swp_decision_parameter1 TYPE swc_elem
VALUE '_DECISION_PARAMETER1'.
CONSTANTS $swp_decision_parameter2 TYPE swc_elem
VALUE '_DECISION_PARAMETER2'.
CONSTANTS $swp_decision_parameter3 TYPE swc_elem
VALUE '_DECISION_PARAMETER3'.
CONSTANTS $swp_decision_parameter4 TYPE swc_elem
VALUE '_DECISION_PARAMETER4'.
CONSTANTS $swp_decision_text TYPE swc_elem
VALUE '_DECISION_TEXT'.
CONSTANTS $swp_decision_title TYPE swc_elem
VALUE '_DECISION_TITLE'.
DATA: BEGIN OF t_listtab OCCURS 0.
DATA: decision LIKE swd_decsn-decision.
DATA: END OF t_listtab.
DATA:
lt_container TYPE swr_cont OCCURS 0 WITH HEADER LINE,
ls_wi_header TYPE swwwihead,
ls_ib_workitem TYPE swlwp1,
lt_merge_table TYPE swww_t_merge_table WITH HEADER LINE,
lt_mime_objects TYPE sinmimeobj OCCURS 2 WITH HEADER LINE,
ls_mergeline TYPE swrsmerge,
l_font_tag_sml(30) TYPE c,
l_font_tag_big(30) TYPE c,
l_col_bc(30) TYPE c.
DATA:
l_action_name,
l_action_index(4) TYPE n,
ls_por TYPE sibflporb,
ls_object TYPE swlobjects,
l_return_code TYPE sy-subrc,
l_result TYPE swcont-value,
l_title TYPE swcont-value,
ls_swlc_workitem TYPE swlc_workitem.
DATA: BEGIN OF gt_alternatives OCCURS 0,
number(4) TYPE c,
text(251) TYPE c,
END OF gt_alternatives.
DATA: g_refresh_html TYPE sy-input,
g_we_run_in_html_mode
TYPE sy-input,
my_container TYPE REF TO cl_gui_custom_container,
my_html TYPE REF TO cl_gui_html_viewer,
gt_workitem_preview_objects
TYPE swlobjects_t.
IF i_info-command IS INITIAL.
e_info-enableexec = 'X'.
ELSEIF i_info-command EQ '$EXECUTE'.
CALL FUNCTION 'SWL_WI_SELECT'
EXPORTING
wi_id = i_info-wi_id
CHANGING
workitem = ls_swlc_workitem
EXCEPTIONS
wi_reservation_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
e_info-enableexec = space.
MESSAGE s145(5w) .
ELSE.
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
workitem_id = i_info-wi_id
TABLES
simple_container = lt_container
EXCEPTIONS
OTHERS = 1.
CLEAR gt_alternatives. REFRESH gt_alternatives.
LOOP AT lt_container WHERE element = $swp_decision_text.
gt_alternatives = lt_container-value.
APPEND gt_alternatives.
ENDLOOP.
CALL FUNCTION 'SWW_WI_HEADER_READ'
EXPORTING
wi_id = i_info-wi_id
IMPORTING
wi_header = ls_wi_header
EXCEPTIONS
OTHERS = 1.
*- get text if language not equal creation language
* IF ls_wi_header-wi_lang NE sy-langu.
CALL FUNCTION 'SWU_GET_DECISION_TEXT_TITLE'
EXPORTING
wiid = ls_wi_header-wi_id
IMPORTING
decision_title = l_title
TABLES
decision_text = gt_alternatives
EXCEPTIONS
node_not_found = 1
text_not_found = 2
workflow_not_found = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ENDIF.
MOVE-CORRESPONDING ls_wi_header TO ls_ib_workitem.
ls_ib_workitem-wi_text = l_title.
REFRESH gt_workitem_preview_objects.
CALL FUNCTION 'SIN_WI_PREVIEW_HTML_BUILD'
EXPORTING
workitem = ls_ib_workitem
inbox_mode = space
deliver_data_but_no_html = 'X'
IMPORTING
e_font_tag_sml = l_font_tag_sml
e_font_tag_big = l_font_tag_big
e_col_bc = l_col_bc
TABLES
preview_objects = gt_workitem_preview_objects[].
*- add the stuff necessary for executing a decision...
REFRESH t_listtab.
SORT gt_alternatives ASCENDING BY number.
LOOP AT gt_alternatives.
CLEAR t_listtab.
" OVER HERE!Я ИДИЁТ, УБЕЙТЕ МИНЯ КТО-НИБУДЬ!!
" Lets kill some button. Second button for example
IF sy-tabix = 2.
CONTINUE.
ENDIF.
" End of buttonkiller proccess
t_listtab-decision = gt_alternatives-text.
APPEND t_listtab.
ENDLOOP.
PERFORM add_decision_html
TABLES lt_merge_table t_listtab
USING l_font_tag_sml l_font_tag_big l_col_bc.
LOOP AT lt_merge_table.
CLEAR ls_mergeline.
ls_mergeline-name = lt_merge_table-name.
ls_mergeline-command = lt_merge_table-command.
APPEND LINES OF lt_merge_table-html TO ls_mergeline-html.
APPEND ls_mergeline TO e_info-mergelines.
ENDLOOP.
ENDIF.
ELSEIF i_info-command EQ '$HTMLEVT'. "SAPEVENT event has been raised
IF i_info-evt_par-action CS 'NOTE:'.
SPLIT i_info-evt_par-action AT ':'
INTO l_action_name l_action_index.
READ TABLE gt_workitem_preview_objects INTO ls_object
INDEX l_action_index.
IF sy-subrc EQ 0.
MOVE ls_object-objid TO ls_por.
CLASS cl_swf_utl_run_services DEFINITION LOAD.
CALL METHOD cl_swf_utl_run_services=>execute_default_method_object
EXPORTING
im_lpor = ls_por.
ENDIF.
ELSEIF i_info-evt_par-action CS 'DECI:'.
CALL FUNCTION 'SWL_WI_SELECT'
EXPORTING
wi_id = i_info-wi_id
CHANGING
workitem = ls_swlc_workitem
EXCEPTIONS
wi_reservation_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
e_info-enableexec = space.
e_info-execresult = 'C'.
MESSAGE s145(5w) .
ELSE.
SPLIT i_info-evt_par-action AT ':'
INTO l_action_name l_action_index.
IF l_action_index EQ 0. "user selected 'cancel'
e_info-execresult = 'C'.
ELSE. "user selected a terminating alternative
READ TABLE gt_alternatives INDEX l_action_index.
IF sy-subrc EQ 0.
DATA wim TYPE REF TO if_swf_run_wim_internal.
DATA txmgr TYPE REF TO cl_swf_run_transaction_manager.
DATA cnt TYPE REF TO if_swf_cnt_container.
DATA element_name TYPE swfdname.
TRY.
txmgr = cl_swf_run_transaction_manager=>get_instance( ).
wim = cl_swf_run_wim_factory=>find_by_wiid(
im_read_for_update = 'X'
im_wiid = i_info-wi_id
im_tx = txmgr ).
cnt = wim->get_wi_container( ).
element_name = cl_swf_run_decision_services=>c_inplace_decision_result.
cnt->element_set( name = element_name
value = gt_alternatives-number ).
txmgr->add_object( wim ).
txmgr->save( ).
txmgr->commit( ).
e_info-execresult = 'E'.
CATCH cx_swf_ifs_exception.
e_info-execresult = 'C'.
ENDTRY.
ELSE.
e_info-execresult = 'C'.
ENDIF. "problems while reading alternative table
ENDIF. "decision was not "cancel"
ENDIF. "item could bb selected
ENDIF. "decision has been selected
ENDIF. "an event has been fired during execution
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form add_decision_html
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT_MERGE_TABLE text
* -->L_FONT_TAG_SML text
* -->L_FONT_TAG_BIG text
* -->L_COL_BC text
*----------------------------------------------------------------------*
FORM add_decision_html
TABLES lt_merge_table t_listtab
USING l_font_tag_sml l_font_tag_big l_col_bc.
DATA: BEGIN OF tmp_listtab OCCURS 0.
DATA: decision LIKE swd_decsn-decision.
DATA: END OF tmp_listtab.
DATA: l_count(4) TYPE n,
l_buf(255) TYPE c,
merge_item TYPE swww_t_merge_item.
tmp_listtab[] = t_listtab[].
CLEAR merge_item.
merge_item-name = '<!DECISION_ALTERNATIVES!>'.
CLEAR l_buf.
CONCATENATE '<hr><table width="100%" border="0"><tr><td><b>'
l_font_tag_sml INTO l_buf.
APPEND l_buf TO merge_item-html.
APPEND 'Select one of the alternatives below'(300)
TO merge_item-html.
APPEND '</td></tr>'
TO merge_item-html.
LOOP AT tmp_listtab.
l_count = sy-tabix.
CLEAR l_buf.
l_buf = '<tr>'.
APPEND l_buf TO merge_item-html.
CLEAR l_buf.
CONCATENATE '<td onmouseover="this.className=''altfoc''"' "#EC NOTEXT
'onmouseout="this.className=''alt''" class=alt' "#EC NOTEXT
'style="background-color:'
INTO l_buf SEPARATED BY space.
CONCATENATE l_buf
l_col_bc '"><a style="color:black;text-decoration:none;display:block;width:100%" href="SAPEVENT:DECI:' l_count '">' l_font_tag_sml
INTO l_buf.
APPEND l_buf TO merge_item-html.
APPEND tmp_listtab-decision TO merge_item-html.
APPEND '</a></td></tr>' TO merge_item-html.
ENDLOOP.
*- unfortunately we gotta append a button for cancel...
APPEND '<tr>' TO merge_item-html.
CLEAR l_buf.
CONCATENATE '<td onmouseover="this.className=''altfoc''"' "#EC NOTEXT
'onmouseout="this.className=''alt''" class=alt' "#EC NOTEXT
'style="background-color:'
l_col_bc '"><a style="color:black;text-decoration:none;display:block;width:100%" href="SAPEVENT:DECI:0000">' l_font_tag_sml
INTO l_buf SEPARATED BY space.
APPEND l_buf TO merge_item-html.
APPEND 'Abort'(301) TO merge_item-html.
APPEND '</a></td></tr>' TO merge_item-html.
APPEND '</table><hr><br><br>' TO merge_item-html.
APPEND merge_item TO lt_merge_table.
ENDFORM. " add_decision_html
2. В шаге на закладке "Просмотр ЭПО" прописываем его в настройке предварит.просмотра в интегр.Раб.месте.
После этих манипуляций данный шаг будет выполняться
только в рамках предпросмотра (нижний контейнер). Зато кнопки сможете регулировать сами.