cancel
Showing results for 
Search instead for 
Did you mean: 

Work Item ID

0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

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.

Former Member
0 Kudos

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.

StephaneBailleu
Active Contributor
0 Kudos

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

0 Kudos

Hi Rakesh,

Thanks for the class but I need to pass work item id to get the class instantiate. I need work item after the event raised the workflow.

Thanks,

Ranjith

Former Member
0 Kudos

Hi Ranjith/Stephane,

You are right. Sorry for that.

@Ranjith : How you are triggering the event ? by FM , class method ?

Thanks

Rakesh

0 Kudos

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.

  • If the same documents are sent for approvals, i need to save the history of those(Obviously I have keys to store).
  • I need to display the history as well in the report and need to display the Approvers of those workflows(Approvers can be different )

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

Former Member
0 Kudos

HI Ranjith,

Then just after this call , you can create a instance of the class CL_SWF_EVT_EVENT by passing the same parameter and then call method GET_EVENT_ID.

Hope this will help.

Thanks

Rakesh

0 Kudos

Hi Rakesh,

Event ID, Event parameters are set in the same method, which means we have all in the same method only and why should we get the instance again?.

The class CL_SWF_EVT_EVENT returning the instance of interface IF_SWF_EVT_EVENT.

Regards,

Ranjith

anjan_paul
Active Contributor
0 Kudos

HI,

  You can sort lt_swr_wihdr  based on date and time and pick the latest one.

Former Member
0 Kudos

Then you ahve the event id. Which you required , isn't it ?

StephaneBailleu
Active Contributor
0 Kudos

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

0 Kudos

Hi,

Yes Stephane. You are right. I need to get work item id not event id.

Yes i am passing all the keys to the method.

Regards,

Ranjith

StephaneBailleu
Active Contributor
0 Kudos

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

StephaneBailleu
Active Contributor
0 Kudos

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

0 Kudos

Hi Stephane,

I am raising bulk records for approvals and need work item id to store with all the records. I have no unique key to store the data.

I need a work item id immediately when the workflow triggered.

Regards,

Ranjith

StephaneBailleu
Active Contributor
0 Kudos

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

former_member185167
Active Contributor
0 Kudos

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

StephaneBailleu
Active Contributor
0 Kudos

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

former_member185167
Active Contributor
0 Kudos

" I am using class based workflow and triggered the workflow through the event."

Hi Stephane, I interpret the above as meaning it was started with an event.

StephaneBailleu
Active Contributor
0 Kudos

Hi Rick

OK I missed this part

But then there is a key ....If you instantiate a class there is a key...or did I miss something else ...

Cheers

Stephane