on 07-15-2016 10:40 AM
Hello All,
I am trying to get the work item id after the workflow triggered. I am using class based workflow and triggered the workflow through the event.
Please help me to get the work item id.
Thanks in Advance.
Hi Ranjith,
You can try following Standard Table.
SELECT SINGLE wi_id
FROM sww_wi2obj
INTO lv_wiid
WHERE wi_rh_task EQ "Your Workflow Template ID (WS*)"
AND instid EQ lv_event_id(Which will be return from SWE_EVENT_CREATE).
Let me know if you need more info on this.
Regards,
Siva K.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can fetch the workitem id in the context immediately.
Please refer class CL_SWF_RUN_WORKITEM_CONTEXT and interface IF_WAPI_WORKITEM_CONTEXT
* Get the Work Item ID
CALL METHOD wi_context->get_workitem_id
RECEIVING
re_workitem = lcl_v_wi_id.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rakesh,
This class is very useful but not in this particular case.
The method you are referring to as all the other IF_WAPI_WORKITEM_CONTEXT method are instance method and to instanciate the class you need ... well the work item id ...
So not really useful if you are looking for the work item id ...
Cheers
Stephane
Dear All,
I require work item at the time of workflow get initiate( Triggering the workflow through class event).
I have requirement to send the multiple documents for approvals, the same documents might be resend for approvals many times also.
I have coded the below piece in my class method to trigger the workflow,
CALL METHOD cl_swf_evt_event=>raise(
EXPORTING
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
im_objtype = lv_objtype
im_event = lv_event
im_objkey = lv_objkey
im_event_container = lr_event_parameters ).
CATCH cx_swf_evt_invalid_objtype .
CATCH cx_swf_evt_invalid_event .
ENDTRY.
COMMIT WORK.
DATA: lt_swr_wihdr TYPE STANDARD TABLE OF swr_wihdr,
lv_key TYPE swotobjid-objkey.
lv_key = lv_objkey.
DATA lv_sibflporb TYPE sibflporb.
lv_sibflporb = m_lpor.
break-point.
CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
EXPORTING
object_por = lv_sibflporb
objkey = lv_key
TABLES
* TASK_FILTER =
worklist = lt_swr_wihdr
Hi
I don't think the event id is what Ranjith is looking for but the work item id.
Looking at your code extract I think there is something in the call of the function
Ranjith, your current issue is that the function module is not returning anything ?
FUNCTION sap_wapi_workitems_to_object .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(OBJECT_POR) TYPE SIBFLPORB OPTIONAL
*" VALUE(OBJTYPE) LIKE SWOTOBJID-OBJTYPE OPTIONAL
*" VALUE(OBJKEY) LIKE SWOTOBJID-OBJKEY OPTIONAL
*" VALUE(TOP_LEVEL_ITEMS) LIKE SWR_STRUCT-TOP_LEVEL DEFAULT 'X'
I think either you fill the OBJECT_POR or OBJTYPE and OBJKEY
Tell me if I am wrong (or right )
Cheers
Stephane
Hi
From the piece of code you sent earlier :
DATA: lt_swr_wihdr TYPE STANDARD TABLE OF swr_wihdr,
lv_key TYPE swotobjid-objkey.
lv_key = lv_objkey.
DATA lv_sibflporb TYPE sibflporb.
lv_sibflporb = m_lpor.
break-point.
CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
EXPORTING
object_por = lv_sibflporb
objkey = lv_key
TABLES
* TASK_FILTER =
worklist = lt_swr_wihdr
You are not filling OBJTYPE
if you provide OBJKEY you need OBJTYPE and you don't need object_por
if you provide object_por (totally filled) you don't need OBJKEY and OBJTYPE
BR
Stephane
Hi
Can you explain a little more why do you want the work item ID ?
Is this because you don't find your wokflow ?
First if you know the object (class) you can use tansaction SWI6 with the instance number
Then if it does not work you can use transaction SWI1 with you workflow definition number in the selection screen.
Cheers
Stephane
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
No key .. ok why not using a Guid ?
Otherwise how do you start your workflow SAP_WAPI_START_WORKFLOW returns the work item ID
I prefer using event but in your case you won't get the WIID by using event
If you don't want to use a GUID as a key then I think that is the best option
Cheers
Stephane
Hello,
You are starting the workflow with an event, that is good.
But surely you provide the event with a key, of the object or class?
If so, then you can search for the workflow with a SAP_WAPI* function module.
If not, then please explain what the workflow is for. They have to be based on something.
Where are you storing this workitem id? What for?
regards
Rick
Hi Rick,
I agree that the requirement is stange, but so far nothing says that the workflow is started with an event, which is always the best.
In fact I suspect that this is not the case otherwise there would be a Key.
A little more on the requirement would certainly be a big plus to provide a good answer.
Cheers
Stephane
User | Count |
---|---|
82 | |
11 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.