Skip to Content
0

forwarding a workitem from one user to another programatically

May 16, 2017 at 10:52 AM

423

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Pavan Bhamidipati May 22, 2017 at 06:48 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Pavan,

Thanks for your reply.

I am using MIR4 transaction , so the business object would be BUS2081.

rg

0
REM REM May 16, 2017 at 10:58 AM
0

Hi ,

Write a program and loop uploaded excel data.

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

Thanks and Regards,

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello,

Thanks for your reply.

I want to forward only the active workitems . How can I check if the work item is active .

Thanks,

rg

0

Hi,

In case WI is not active, FM will threw an exception. If you wanted to handle exceptions in your programs , then use FM : SAP_WAPI_FORWARD_WORKITEM instead of SWW_WI_FORWARD

Regards,

0

Hi ,

thanks once again . I want to get the work items assigned to an user by programatically . how can I acheive this.

thanks,

rg

0

Hi ,

You can use : SAP_WAPI_CREATE_WORKLIST by setting appropriate filters

Thanks and Regards,

0
Pavan Bhamidipati May 17, 2017 at 07:13 AM
0

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello Pavan,

thanks for your reply, we need to find the workitem ids for that correspodning user enetered, please suggest.

rg

0

Hi,

Use SAP_WAPI_CREATE_WORKLIST to get eh list of workitems present in a specific user.

Thanks, Pavan

0

Hello Pavan,

Could you please let me know how to get the assigned agents for an invoice. In my requirement user will be entering the invoice number and user id of the user . so want to know how to get the assigned active workitems for that particular user .

rg

0

Hi Pavan,

I want to get all the workitems for a particular invoice associated to an user . How can I achieve that.

rg

0
Rani Kittaneh May 17, 2017 at 08:03 AM
0

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

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Erm, the clue is in the title: "programatically"

0

Hello Rani,

thanks for your reply, we need to find the workitem ids for that correspodning user enetered, please suggest.

rg

0
Ramya g 3 minutes ago

Hello,

Could you please let me know how to get the assigned agents for an invoice. In my requirement user will be entering the invoice number and user id of the user . so want to know how to get the assigned active workitems for that particular user .

rg

0

Hi, you can get the currently assigned items to a certain user "manually" using SWIA, just execute the report and use the name of the user as a filter criteria in the "Agent" column, this will give you all workitems for that user, you can also user the column "Status" to filter out completed work items and keep those pending.

0

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

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

Great, it helped you,finally.

Thanks, Pavan

Share
10 |10000 characters needed characters left characters exceeded