cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP OO - Get workitem ID

projecto_sap
Explorer
0 Kudos

Hello,

I'm migrating BOR tasks to ABAP OO (some compatibility issue arose) using a task with a class/method. The method is static like the BOR method was instance independent.

Inside my method I need to retrieve the workitem ID. In BOR method I used the macro swc_get_element to retrieve the workitem object and then the workitem ID. How do I do the same thing in a class method?

I tried using the IF_SWF_IFS_PARAMETER_CONTAINER but it is only usable in instance methods. Does the method need to be instance based?

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

pokrakam
Active Contributor
0 Kudos

Hello,

Simple trick using automatic method binding: create an import parameter _WORKITEM (the name is important) type SIBFLPORB, and it will automagically populate it at runtime with the workitem object. Since the ID is the key, you can just read _WORKITEM-INSTID and save yourself the trouble of instantiating the BOR object.

Cheers,

Mike

olivier_segol
Active Participant
0 Kudos

Hello,

You can add the parameter as input parameter of the method. And then bind the id from the Wf : &_WORKITEM.WORKITEMID& to your parameter.

Hope it will help you.

Olivier

projecto_sap
Explorer
0 Kudos

If I bind the parameter from the WF to the task I will get the WF ID, not the workitem ID.

I tried to use the method binding to send the task ID to the method, but tha doesn't seem to work. The PFTC transaction is always asking I want to copy parameters to container, and the binding disappear a lot. The functionality seems to be bugged.

Anyway I can get the workitem ID from the workflow ID, I'll do that.

olivier_segol
Active Participant
0 Kudos

Hello,

Curious, I'm able to bind the task id (&_WORKITEM.WORKITEMID) to a method in the task builder.

Perhaps try to acces to the task via SWDD instead of directly going to PFTC.

Or try to put the value manually. If you have a look at SWI2_FREQ, at an item level, the field &_WORKITEM.WORKITEMID has the workitem id and not the workflow id.

Olivier