cancel
Showing results for 
Search instead for 
Did you mean: 

Passing an object through SAP_WAPI_START_WORKFLOW

Former Member
0 Kudos

Hi All,

I am trying to start my workflow from a report program using SAP_WAPI_START_WORKFLOW. Now i have a container element ZEHSBO in my workflow which refers to a custom object type.

I have the object key in the program which calls SAP_WAPI_START_WORKFLOW. Now i need to populate the container element ZEHSBO while starting the workflow. For container elements which refers to an ABAP Dictionary reference i am able to populate it using INPUT_CONTAINER by passing the details in ELEMENT and VALUE fields. But how do i populate the same when it refers to a BO type?

I tried putting SWC_CREATE_OBJECT in my report program and i get an object reference. But i am not sure how to pass this object reference and get the whole object in the element - ZEHSBO in workflow.

Other alternative is to create a triggering event in my custom BO and pass the object from event to workflow through bindings. But i dont want to use events. I need to use SAP_WAPI_START_WORKFLOW and get the container element ZEHSBO populated.

How do i achieve this?

Thanks,

Prasath N

Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor
0 Kudos

Unless you have a specific reason to use SAP_WAPI_START_WF, this is usually not the most effective approach. Why not define an event on ZEHSBO and raise that using SAP_WAPI_CREATE_EVENT? Much easier, more stable, no need for error handling in your code, restartable if it fails....

Former Member
0 Kudos

Hi Mike,

Thanks for a quick reply. I really dont have any major reason for not using start events. Only reason is I was not sure if using events to start a workflow will be the best approach compared to SAP_WAPI_START_WORKFLOW.

Though i am not sure about the backend code i was under an impression that even when we use a start events the workflow is internally started by SAP_WAPI_START_WORKFLOW or some other similar function module (after receiving the event).

So i just thot of bypassing the usage of events. So can i conclude from your answer that usage of start events is the only way to pass object to workflow?

Also it looks like i cant pass multiline elements using SAP_WAPI_START_WORKFLOW!!!!

Thanks,

Prasath N

pokrakam
Active Contributor
0 Kudos

Hi Prasath,

Events are definitely the way to go unless you have a reason not to. They are more visible, handled by the event manager, restartable. You have logging, load balancing, event trace, the ability to use start conditions. Your WF admin doesn't need to understand a bit of code stuck deep in some custom report if the workflow doesn't start correctly. Events are good. Direct start should be a second choice.

To answer your question, you can pass objects. Not sure if you can just pass the key in the VALUE field, else you will need to use swc_object_to_persistent to convert your object to a persistent reference.

data: lv_obj type ref to swc_object, 
      lv_pref type swotobjid. 
  swc_create_object lv_obj 'ZEHSBO' <object key>.
  swc_object_to_persistent lv_obj lv_pref.
  ...
  lv_cont-value = lv_pref.

Try both, one should work.

Cheers,

Mike

Former Member
0 Kudos

Thanks a lot mike.

I have decided to use the events itself.

Thanks,

Prasath N

Answers (0)