Steps:
SE38: Copy program RSWIWILS to ZRSWIWILS.
Copy all components, except Includes.
In the attributes, change the title to 'Agents of Workitems'.
SE93: Create transaction ZWF_AGENTS as a 'Report Transaction' (program and selection screen).
Transaction text = 'Agents of Workitems'
Program = ZRSWIWILS
Selection Screen = 1000
Click 'SAPGUI for WIndows'.
SE38: Make the following simple code changes to ZRSWIWILS
(1) At the beginning of the program
REPORT zrswiwils MESSAGE-ID swf_rep_base.
*------------------------------------------------------------------
* This is a copy of program RSWIWILS, which underlies SWIA,
* SWI1_USER etc.
*
* We have adapted it to provide an Agents report: list all current
* agents for a workitem. This reported is executed via transaction
* ZWF_AGENTS.
*
* Changes are marked with the text 'Agents'
*------------------------------------------------------------------
(2) about line 25
* DATA: g_report_name TYPE sy-repid VALUE 'RSWIWILS'.
DATA: g_report_name TYPE sy-repid VALUE 'ZRSWIWILS'. "Agents
(3) about line 56 - set the default values to only pick up 'READY' dialog workitems
SELECT-OPTIONS:
type FOR swfawrkitm-wi_type default 'W', "Agents - Dialog workitem
state FOR swfawrkitm-wi_stat default 'READY', "Agents - Ready
(4) about line 109 - set the title of the program
ELSEIF tcode = 'SWIA_BATCH'. "Context
SET TITLEBAR '1006'. "Context
ELSEIF tcode = 'ZWF_AGENTS'. "Agents
SET TITLEBAR '1099'. "Agents of Workitems
ENDIF.
You also need to create the text element 1099 (double-click on it) and give it the value 'Agents of Workitems'.
If you are asked to change the original language of the program, do so.
(5) about line 259 (after the call to 'get_workitem_header')
*-- begin Agents
* If the (dialog) workitem does not have an agent, then we want to
* list all current users who have this workitem in their inbox.
if sy-tcode = 'ZWF_AGENTS'.
PERFORM get_workitem_agents CHANGING g_wiheader.
endif.
*-- end Agents
(6) At the very end of the program, add this subroutine
*-- begin Agents
*---------------------------------------------------------------*
* FORM get_workitem_agents *
*---------------------------------------------------------------*
* Augment the workitem list with agent information:
* if a DIALOG workitem is in status READY and has
* NO CURRENT AGENT, find all (responsible) agents
* who have this item in their inbox.
* Add one line to the list for each agent found.
*---------------------------------------------------------------*
* <-> PT_WIHEADER *
*---------------------------------------------------------------*
form get_workitem_agents changing pt_wiheader type swfatalvitm.
types: begin of ty_user_name,
user type SYUNAME,
name type AD_NAMTEXT,
end of ty_user_name.
data: lt_user_names type sorted table of ty_user_name
with UNIQUE key user,
ls_user_name type ty_user_name.
data: lt_wi_agents type SWRTWIAGENT,
ls_wi_agents type SWR_WIAGENT,
lt_wiheader type swfatalvitm,
ls_wiheader type SWFAALVITM,
lt_wi_ids type SWRTWIID,
lv_user_id type XUBNAME,
ls_user_address type ADDR3_VAL.
check pt_wiheader is not initial.
loop at pt_wiheader into ls_wiheader.
clear: lt_wi_ids, lt_wi_agents.
* Dialog workitem in status READY with no agents?
if ls_wiheader-wi_type EQ 'W' and "dialog workitem
ls_wiheader-WI_AAGENT is initial and "no agents
ls_wiheader-WI_STAT EQ 'READY'. "ready
append ls_wiheader-wi_id to lt_wi_ids.
* Get the current (responsible) agents, who would
* have the workitem in their inbox
CALL FUNCTION 'SAP_WAPI_GET_WI_AGENTS'
EXPORTING
* LANGUAGE = SY-LANGU
WORKITEMS = lt_wi_ids
* USER = SY-UNAME
WITH_SUBSTITUTES = 'X'
IMPORTING
* RETURN_CODE =
* TIMESTAMP =
WI_AGENTS = lt_wi_agents
* TABLES
* MESSAGE_LINES =
* MESSAGE_STRUCT =
.
* For every agent found, add a new line to the WI list
if lt_wi_agents[] is initial.
"just add a line with no agent
append ls_wiheader to lt_wiheader.
else.
loop at lt_wi_agents into ls_wi_agents.
"add a new line for each agent
ls_wiheader-wi_aagent = ls_wi_agents-user.
* get the user name
clear ls_user_address.
lv_user_id = ls_wi_agents-user.
* try a local buffer first
read table lt_user_names into ls_user_name
with key user = lv_user_id.
if sy-subrc = 0.
ls_wiheader-WI_AA_NAME = ls_user_name-name.
else.
* get the user name from the user address
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = lv_user_id
IMPORTING
user_address = ls_user_address
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
if sy-subrc = 0.
ls_wiheader-WI_AA_NAME = ls_user_address-name_text.
* store in a buffer table
clear ls_user_name.
ls_user_name-user = lv_user_id.
ls_user_name-name = ls_user_address-name_text.
insert ls_user_name into table lt_user_names.
endif.
endif.
append ls_wiheader to lt_wiheader.
clear ls_wiheader-wi_aagent.
endloop.
endif.
else. "if its not a dialog workitem, or already has an agent,
"just append it
append ls_wiheader to lt_wiheader.
endif.
endloop.
*Replace the original table with the extended table
if lt_wiheader[] is not initial.
pt_wiheader[] = lt_wiheader[].
endif.
endform. "get_workitem_agents
*-- end Agents
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
2 |