Dear friends in the very heart of the runtime system
the WAPI's ABAP-OO representation with the interface IF_WAPI_WORKITEM_CONTEXT is quite useful and you can get information about a workitem rather quickly and also do some actions with it very simply, such as changing the state (to completed or whatsoever).
An instance of that context is provided by the runtime system during the following activities:
- ABAP OO workitem exit on workflow and workitem processing
- Rule resolution by function module
- ... anything else, that you now of, where that context is provided??
Now, if you have an existing workitem (which is saved on the database), you can create a context by going through the WIM factory. This gives you at first an internal WIM handle back, which you can convert down to a WAPI object. That does like this (short version, omitting exception handling)
DATA: lo_workitem_handle TYPE REF TO IF_SWF_RUN_WIM_INTERNAL.
lo_workitem_handle = cl_swf_run_wim_factory=>find_by_wiid( lv_current_wi_id ).
DATA: lo_workitem_context TYPE REF TO IF_WAPI_WORKITEM_CONTEXT.
lo_workitem_context = lo_workitem_handle->get_workitem_context( ).
It also works the other way around, so that you had a given workitem_context instance will let you retrieve a runtime handle for that (just use the workitem-ID from the context and have the first part executed).
Now let's say, that you have created several methods to do some extraordinary stuff with such a context-object, and for some reasons, you were also in the need to use some extras from the workitem handle.
There's one exception, where you can go back from the context to the handle: When the workitem is not yet saved on the database, which means, all states up to the end of the rule resolution.
And this is, where my questions is pointing to: How can one get hold of the local workitem manager to retrieve the (singleton of the) handle. Because if you used the statement
lo_workitem_handle = cl_swf_run_wim_factory=>find_by_wiid( lv_current_wi_id ).
before the rule resolution, you get a very hard exception, that the WIM cannot find the workitem.
You could check this out, when executing this while the event_before_creation within a workitem exit, for example.
I wonders, if there's a way to get hold of the running instance of the workitem manager (class CL_SWF_RUN_WIM_LOCAL) to retrieve the runtime handle, which is currently in process.
I'm also curious, if there's a different approach to retrieve a workitem-context, not using the internal workitem manager.
Any experiences here are highly appreciated.
Working code examples are very very welcome and will give you a "solved" flag, with as many points as I can distributed
Florin
Please do not respond something like "Hey Florin, have you looked at the SAP_WAPI-methods and how they retrieve a context".....that's not helpful: yes, I have done so ... I've also debugged through the WIM, the workitem exit and through the rule resolution procedure,... through the tRFC handler and through other secions. I did not debug through the WIM transaction manager yet. If you find anything useful there, please share your experience.