Skip to Content

forwarding a workitem from one user to another programatically

Hi Experts,

I will be uploading workitems in an excel sheet which corresponds to a single user . i want to forward that corresponding work items to other user. Please suggest how can I do that programatically.

thanks,

rg

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    May 22, 2017 at 06:48 AM

    Hi Ramya,

    There can be many ways to do it at this moment below are the possible approaches is what I can think of:

    I am not sure what is the business object related to invoice number you are using . However, you can find the below code might be helpful to get the list of work items related to a instance of the business object.

    DATA: ls_por TYPE sibflporb,
     lv_otype TYPE swotobjid-objtype,
     lv_key TYPE swotobjid-objkey,
     lt_witabs TYPE swrtwihdr,
     ls_wi TYPE swr_wihdr,
     lt_dep_witabs TYPE swrtwihdr.
    lv_otype = 'BUS2081'.
    CONCATENATE '<Invoice Document Number>' '<Fiscal Year>' INTO lv_key.
    CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
     EXPORTING
     objtype = lv_otype
     objkey = lv_key
     top_level_items = 'X'
    * SELECTION_STATUS_VARIANT = 0001
    * TIME =
    * TEXT = 'X'
    * OUTPUT_ONLY_TOP_LEVEL = ' '
    * LANGUAGE = SY-LANGU
    * DETERMINE_TASK_FILTER = 'X'
    * REMOVED_OBJECTS = ' '
    * IMPORTING
    * RETURN_CODE =
     TABLES
    * TASK_FILTER =
     worklist = lt_witabs
    * MESSAGE_LINES =
    * MESSAGE_STRUCT =
     .
    LOOP AT lt_witabs INTO ls_wi.
     CALL FUNCTION 'SAP_WAPI_GET_DEPENDENT_WIS'
     EXPORTING
     workitem_id = ls_wi-wi_id
     direct_dependants_only = abap_true
    * USER = SY-UNAME
    * LANGUAGE = SY-LANGU
    * TRANSLATE_WI_TEXT = ' '
    * IMPORTING
    * RETURN_CODE =
     TABLES
     items = lt_dep_witabs
    * MESSAGE_LINES =
    * MESSAGE_STRUCT =
     .ENDLOOP. 
    

    From the dependent work items you need to fetch the work items of type F which are basically foreground workitems and make sure they are not with the status COMPLETED.

    and then for this workitem ID find the agent by using the below code.

    CALL FUNCTION 'RH_WI_ORGTASK_READ'
     EXPORTING
     wi_id = ls_cr_wis-wi_id
     TABLES
     wi_orgtask = lt_wiorgtab
     wi_agents = lt_agents
     EXCEPTIONS
     read_failed = 1
     OTHERS = 2.
     IF sy-subrc <> 0.
    * Implement suitable error handling here
     ELSE.
     READ TABLE lt_agents INTO ls_agent INDEX 1.
     
     ENDIF.

    Can you please let me know the business object that you are using.

    The other approach would be

    I guess you might have some standard tables where you can find the list of invoices associated with a user. use this table get the user name based on invoice number and then pass the same user name to SAP_WAPI_CREATE_WORLIST user and filter the result based on the task id used for the approval work item. you have the exact task.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 16, 2017 at 10:58 AM

    Hi ,

    Write a program and loop uploaded excel data.

    In that loop call FM - SWW_WI_FORWARD to forward work items.

    Thanks and Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • May 17, 2017 at 07:13 AM

    Hi,

    1. Create a function or method to upload the excel sheet with workite Ids.
    2. Loop the internal table where you might have converted the excel sheet data into an internaö table.
    3. Within the loop call the function module SAP_WAPI_FORWARD_WORKITEM.
    4. Finally, log the result by creating some log object which you can refer in SLG1 transaction.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 17, 2017 at 08:03 AM

    Why not use SWIA, highlight all the work items and use the forward function?

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rani,

      I understood that we can get the workitems assigned to a user , but my question is where is the link between invoice no and the associated work item for that invoice.

      I want to forward the work item associated with a invoice from one user to another user.

      Thanks,

      rg

  • May 22, 2017 at 10:58 AM
    Thanks for your reply.I am using MIR4 transaction , so the business object would be BUS2081.

    Great, it helped you,finally.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded