cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger WF Programatically

karuna_gangireddy
Contributor
0 Kudos

Hi All,

Could any one out there please tell me if there is a way to start/trigger the WF programmatically. My WF is triggering well through the triggering events but i want to trigger the WF in the user exit. I am not sure how to do this. Please advice.

Thanks,

Karuna\.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

There's a user exit which is called after the material document is posted, but just before the 'commit work' takes place. I think it's 'EXIT_SAPLMBMB_001.

Raise your workflow event programmatically there using 'SWE_EVENT_CREATE_FOR_UPD_TASK' in update task. You'll have the material document number/year in the MKPF structure by then, so you should be well equipped for any subsequent workflow.

Reward points if it helps

regards

Biju

rmazzali
Active Contributor
0 Kudos

You have to raise an event from inside the user exit.

To do this use FM SWE_EVENT_CREATE

You can also generate a change document and attach the event from there.

pls. reward if helpful

Roberto

here a code sample:

INCLUDE <CNTAIN>. " Definizione MACRO

DATA: KEY LIKE SWEINSTCOU-OBJKEY.

Key(18) = rmmg1-matnr.

key+18(4) = marc-werks.

key+22(2) = stato.

SWC_CONTAINER T_SWCONT.

SWC_SET_ELEMENT T_SWCONT 'Codice' rmmg1-matnr.

SWC_SET_ELEMENT T_SWCONT 'Plant' marc-werks.

SWC_SET_ELEMENT T_SWCONT 'Stato' stato.

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

OBJTYPE = 'businessobject'

OBJKEY = KEY

EVENT = 'eventname'

TABLES

EVENT_CONTAINER = T_SWCONT

EXCEPTIONS

OBJTYPE_NOT_FOUND = 1

OTHERS = 2.

endif.

commit work.

karuna_gangireddy
Contributor
0 Kudos

Hi Roberto,

Thank you very much for the quick response. I will try the code and get back.

Thanks again,

Karuna.