Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to trigger workflow from abap program

Former Member
0 Kudos

Hi Experts,

i have a user developed screen in which there is an option to approve (not a std tcode)

for which there is no event created.

i am very new to workflow ,

now how to create an event and also how to trigger the workflow

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can run a ABAP report or call a transaction from the BOR's Method directly.

Check this link for more info.

http://help.sap.com/saphelp_nw2004s/helpdata/en/80/9a3cb3971c11d194c60000e82dec10/frameset.htm.

In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.

BUS1001006 ( Standard Material )

here is the sample code.

DATA: key LIKE sweinstcou-objkey.

key = '68." Material Number (hard-coded)

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

objtype = 'BUS1001006'

objkey = key

event = 'CREATED'

  • CREATOR = ' '

  • TAKE_WORKITEM_REQUESTER = ' '

  • START_WITH_DELAY = ' '

  • START_RECFB_SYNCHRON = ' '

  • NO_COMMIT_FOR_QUEUE = ' '

  • DEBUG_FLAG = ' '

  • NO_LOGGING = ' '

  • IDENT =

  • IMPORTING

  • EVENT_ID =

  • TABLES

  • EVENT_CONTAINER =

  • EXCEPTIONS

  • OBJTYPE_NOT_FOUND = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE 'Event Triggered'.

ENDIF.

COMMIT WORK.

************************************************************************

In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.

Press ‘Switch On”.

Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.

Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:

Regards

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can run a ABAP report or call a transaction from the BOR's Method directly.

Check this link for more info.

http://help.sap.com/saphelp_nw2004s/helpdata/en/80/9a3cb3971c11d194c60000e82dec10/frameset.htm.

In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.

BUS1001006 ( Standard Material )

here is the sample code.

DATA: key LIKE sweinstcou-objkey.

key = '68." Material Number (hard-coded)

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

objtype = 'BUS1001006'

objkey = key

event = 'CREATED'

  • CREATOR = ' '

  • TAKE_WORKITEM_REQUESTER = ' '

  • START_WITH_DELAY = ' '

  • START_RECFB_SYNCHRON = ' '

  • NO_COMMIT_FOR_QUEUE = ' '

  • DEBUG_FLAG = ' '

  • NO_LOGGING = ' '

  • IDENT =

  • IMPORTING

  • EVENT_ID =

  • TABLES

  • EVENT_CONTAINER =

  • EXCEPTIONS

  • OBJTYPE_NOT_FOUND = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE 'Event Triggered'.

ENDIF.

COMMIT WORK.

************************************************************************

In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.

Press ‘Switch On”.

Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.

Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:

Regards

0 Kudos

Hi ,

i have tried both 'SWE_EVENT_CREATE' and also SAP_WAPI_EVENT_CREATE,

let me explain the scenario,

once the enquiry is created assuming having multiple line items

i am able to trigger the wf

but

in my case i have to approve each line item ,so there is a user developed module pool pgm screen to do the same, now when this line item is approved i have to trigger the wf and then on SO is created with reference ,

i hope my question is clear this time.

Many thanks,

subramanya

Former Member

Hi there --- actually this is really easy.

In your ABAP create the event with FM SAP_WAPI_CREATE_EVENT.

Use transaction SWE2 to define the workflow / task to start when the event is created.

Ensure in the definition of your BOR (or CLASS if using OO workflow) you've defined an EVENT. In BOR use transaction SWO1. For classes transaction SE24.

If you are using a Standard (SAP) supplied BOR but you need to add methods / events then just define a Z version and DELEGATE it to the standard SAP one. Also done in transaction SWO1.

Cheers

Jimbo

0 Kudos

Thank you ,

it was help full....

regards,

subramanya