Triggering a Workflow whenever a new record is created:
Scenario: Whenever a new record is created a workflow is executed which sends a mail to desired user intimating about the new record.
2. Create the table maintenance generator for above table.
3. For triggering the work flow we need to create an event. From below screen shot create an event.
The code is to change the start date field to sy-datum and create an event using the function module SAP_WAPI_CREATE_EVENT.
Write below code:
4.Now we need to create a business object. Go to Tcode: SWO1 and give the name and press create button:
8.Activate the start events by clicking A button.
9. Do the binding now by clicking the B button.
Go back and save it.
11. Now workflow looks like:
12. Add the Mail step type
And press transfer to graphic button.
Activate the workflow.
Create a record in SE16
and save it. Now a mail will be triggered in tcode SBWP as below: