Skip to Content

Issue with SAP_WAPI_FORWARD_WORKITEM in sap workflow

Hi Exprets,
I am using function module SAP_WAPI_FORWARD_WORKITEM to forward a work item from one user to another. I am getting return code as 2 . please let me know if I am missing any thing

SELECT wi_id wi_type wi_stat
FROM swwwihead
INTO TABLE i_wi_head
WHERE wi_id IN s_wi_id.

IF sy-subrc IS INITIAL.

v_oldus = p_oldus.
v_newus = p_newus.

* Forward the work item to the requred user
LOOP AT i_wi_head INTO w_wi_head.
workitem_id = w_wi_head-wi_id
user_id = v_newus
language = sy-langu
do_commit = 'X'
current_user = v_oldus
return_code = v_return
new_status = v_status.
v_oldus is the user id pf work item sender and v_newus is the id of the workitem receiver.
Add comment
10|10000 characters needed characters exceeded

  • Please use appropriate formatting when posting plain text.

    As you previously posted this question all in plain text, and now again all in code format, it seems to me you are not familiar with formatting. Here's how it works:

    Select a piece of text by clicking and dragging the mouse over it. Then click one of the format buttons above.

    e.g. I selected this line and clicked "B" for bold.

    And if you have a piece of code, select the code and click the "code" button to format only the code. Remember to select only the code, not the text above or below. I have done this with the below piece of code.

    data(today) = sy-datum.
    data(next_week) = today + 7. while today < next_week. wait up to 1 day. today = day + 1. endwhile.

    It makes it much easier to read what is code and what is information. It is also considered polite to make your question easy to read and understand, and provides more incentive for people to read your post.

3 Answers

  • Best Answer
    Posted on Jun 12, 2017 at 01:24 PM

    Here is a snap shot of how to do..

    first of all make sure your work item is correct.. to be sure about work item, go in to swi1 and pick the ID whose work item type is dialog step. (SWI1 screen shote )

    go to Se37


    in User ID table fill it as below

    and execute.

    Results in Message lines:


    I think now you know very well how to write the same in the code


    capture.jpg (22.2 kB)
    capture.jpg (52.4 kB)
    capture.jpg (29.3 kB)
    capture.jpg (69.2 kB)
    capture.jpg (41.1 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 12, 2017 at 11:00 AM

    Hi Ramya,

    PFB the description for the return codes. You can read the table message_lines to get info about the workitem.

    2 Work item cannot be forwarded.

    3 No agents for forwarding specified during call

    900 System error: method must not be used in the current context

    999 An unknown error occurred.

    Alternatively you can use the FM "SAP_WAPI_AGENTS_CHANGE".It also forwards the work item .

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 12, 2017 at 12:40 PM


    Please check the workitem status , is it in Ready status or not.

    Return code 2 means, its can not be forwarded

    Add comment
    10|10000 characters needed characters exceeded