cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Triggering workflow

Former Member
0 Likes
8,397

Hi Experts,

I wanted to trigger a custom workflow during sales order creation/change. As I wanted to start workflow only based on some complex conditions I have decided to trigger it from user exit MV45AFZZ/USEREXIT_SAVE_DOCUMENT. Buidling this logic as workflow starting condition  or @ event linkage is not possible.

I can think of two options here to start workflow from user exit.

Option1: Start the workflow directly with the FM SAP_WAPI_START_WORKFLOW'. I doubt workflow triggerd in this way is not linked to the transaction and thus I shouldnt be able to see this from VA02/03?

Option2: Link my custom workflow to an event and triggering the event using  FM SAP_WAPI_CREATE_EVENT. Events CREATED/CHANGED for business object BUS2032 are triggered whenever sales order is changed/created. I am confused here about what event I need to link to my workflow and trigger? Do I need to create a subtype for 2032 and link my custom workflow and trigger CREATED & CHANGED event? As I am not changing anything for the business object my question is why should I create a subtype?

Much appriciated for any calrification on this,

Thanks,

Rams V.   

View Entire Topic
Former Member
0 Likes

Thanks a lot for your valuable inputs Rob.

I am very sorry still I am not able to understand why do we need both custom event and custom attribute? As this custom event is only triggered by me in the user exit why do I need this attribute?

Former Member
0 Likes

Hello,

I agree with you. I don't see the need for a custom event if you have a custom attribute. You can always turn off the link between the (existing) event and your workflow if there's a problem.

regards

Rick

Former Member
0 Likes

Thanks Rick. Hope this is my last question here ....I have checked few threads in SCN about setting virtual attributes in BO and use it in workflow start condition? Is it possible to set virtual attribue in USER exit and check the value in work flow start condition? Or we need to have data base field? ...if this is not possible I would rather go with custom event as i don't want to extend standard table for this field?

Or with the combination of check function module at start condition and EXPORTing a value in the userexit then IMPORTing it in the function module...

I wanted to use the best available solution without disutrbing standard sap functionality

Former Member
0 Likes

Hello,

A virtual attribute should work in a start condition, as long as it's not based on something that may not yet exist.

Give it a try.

regards

Rick

Former Member
0 Likes

Hi,

You are still going to use an exit to trigger an event. what I was trying to tell you is that you don't want that. You want to use standard event (or through change docs, status management, etc.) then using an attribute and conditions you can control whether you want to start a workflow or not.

Kind regards, Rob Dielemans

Former Member
0 Likes

I am not sure how I can set the value for virtual attribute I have created in my user exit. But I will give a go with FM SWO_INVOKE. Thanks guys.

Former Member
0 Likes

I agree. Keep it simple. No need for user exits or custom events.

Former Member
0 Likes

Hi,

you keep on mentioning the user exit.

If you have an event or change doc when you save this data then you won't need to bother fiddling around with cumbersome user exits.

My advise was to extend the business object, add an attribute(or attributes) link the event to workflow, and then use conditions with your new attribute to control the workflow.

This is straightforward Workflow consultant stuff, so please try and do it this way to get accustomed to these methods so that you can keep on using these methods in the future.

Kind regards, Rob Dielemans

Former Member
0 Likes

I completely agree with you Rob and I also wanted to do it in correct way. But how can I set the value of the custom/virtual/new attribue I have created? My assumption is that I need to do this in user exit?  Thanks a lot for your time sofar.

Former Member
0 Likes

I think this is explained in the Workflow tutorial on help.sap.com.

1. Swo1, type in business object, click subtype.

2. Swo1, go to delegate and delegate the business object with your subtype

3. swo1, edit, open attributes, click create, source virtual, name description and reference

4. position cursor on your attribute and click program.

5. code your own attribute (check help or other business objects programming to get accustomed to macros used for setting the virtual attribute

6. generate (follow instructions, you might have to also change release status)

7. Swo1, test your business object and see if the attribute is created with correct values.

8. swe2, link sap standard business object event to your workflow (it is delegated)

9. swb_cond find your linked business object-->event and add a condition with your virtual attribute.

10. test.

Kind regards, Rob Dielemans