SAP MDG · UTILITIES
How do I reassign an SAP workflow work item from an ALV hotspot click in ABAP?
Use a CL_GUI_ALV_GRID hotspot_click handler to read the selected row, prompt for a target user with POPUP_TO_GET_VALUE, then forward the work item with SAP_WAPI_FORWARD_WORKITEM and show any error message returned by the API.
Use a CL_GUI_ALV_GRID hotspot_click handler to read the selected row, prompt for a target user with POPUP_TO_GET_VALUE, then forward the work item with SAP_WAPI_FORWARD_WORKITEM and show any error message returned by the API.
Handle the ALV hotspot_click event, map the clicked row to your workitem table, prompt the user for the new assignee, and then forward the work item with SAP_WAPI_FORWARD_WORKITEM. The reusable pattern is built around a simple event receiver class and returns the API message lines so you can show success or error feedback immediately.
Process flow
- Register a hotspot click handler for the ALV grid.
- Read the clicked row from your workitem internal table.
- Prompt the user for the target user name.
- Call SAP_WAPI_FORWARD_WORKITEM with the workitem ID and user ID.
- Check the returned message lines and display success or error feedback.
Referenced tables
| Object | Purpose |
|---|---|
USR21 | Used by POPUP_TO_GET_VALUE to prompt for the target user name field BNAME. |
SWR_MESSAG | Message table type used to collect return messages from SAP_WAPI_FORWARD_WORKITEM. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1*&---------------------------------------------------------------------*
2*& 01_Workitem_Reassignment_From_ALV_Hotspot
3*&---------------------------------------------------------------------*
4*& Reusable functionality:
5*& Reassign a workflow workitem from an ALV hotspot click.
6*&---------------------------------------------------------------------*
7CLASS lcl_event_receiver DEFINITION.
8 PUBLIC SECTION.
9 METHODS on_hotspot_click
10 FOR EVENT hotspot_click OF cl_gui_alv_grid
11 IMPORTING
12 !e_row_id
13 !es_row_no.
14ENDCLASS.
15
16CLASS lcl_event_receiver IMPLEMENTATION.
17 METHOD on_hotspot_click.
18 DATA: lv_to_user TYPE sy-uname,
19 lv_new_status TYPE swr_wistat,
20 lt_message TYPE TABLE OF swr_messag.
21
22 " 1) Resolve selected row into your workitem table.
23 READ TABLE gt_wi_tab INTO gs_wi_tab INDEX es_row_no-row_id.
24 IF sy-subrc <> 0.
25 RETURN.
26 ENDIF.
27
28 " 2) Ask user for target assignee.
29 CALL FUNCTION 'POPUP_TO_GET_VALUE'
30 EXPORTING
31 fieldname = 'BNAME'
32 tabname = 'USR21'
33 titel = 'Assign to user'
34 IMPORTING
35 valueout = lv_to_user.
36 IF sy-subrc <> 0 OR lv_to_user IS INITIAL.
37 RETURN.
38 ENDIF.
39
40 " 3) Forward the workitem to the selected user.
41 CALL FUNCTION 'SAP_WAPI_FORWARD_WORKITEM'
42 EXPORTING
43 workitem_id = gs_wi_tab-workitem_id
44 user_id = lv_to_user
45 IMPORTING
46 new_status = lv_new_status
47 TABLES
48 message_lines = lt_message.
49
50 " 4) Show outcome.
51 READ TABLE lt_message INTO DATA(ls_message) WITH KEY msg_type = 'E'.
52 IF sy-subrc = 0.
53 MESSAGE ls_message-line TYPE 'E'.
54 ELSE.
55 MESSAGE 'User updated' TYPE 'S'.
56 ENDIF.
57 ENDMETHOD.
58ENDCLASS.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I forward a workflow work item when a user clicks a hotspot in an ALV grid?
- What is the ABAP pattern to reassign a workflow work item from an ALV click?
- How do I call SAP_WAPI_FORWARD_WORKITEM from an ALV event handler?
Possible questions
- How do I reassign an SAP workflow work item from an ALV hotspot click in ABAP?
- How can I forward a workflow work item when a user clicks a hotspot in an ALV grid?
- What is the ABAP pattern to reassign a workflow work item from an ALV click?
- How do I call SAP_WAPI_FORWARD_WORKITEM from an ALV event handler?
- Which workitem reassignment API should I use in ABAP?