14
Trigger workflow when a record is created in a database table Step 1: Create a Database Table in SE11 This document shows step by step process for the creation of a business object, table maintenance events and linking them to workflows in the SAP system. Also this document shows how to integrate the business object created with SAP workflow. Business objects are of two types With Super Type Without Super type Business Object with Super type In this case the BO refers to a standard BO already existing in the SAP system. We create our own BO with by coping the existing standard BO . Let’s suppose we have a BO BUS2014 which is Purchase contract. Now if I want to add my own attributes /methods in addition to the standard, I will create ZBUS2014 which has all the items in BUS2014 plus my own attributes and methods. In this case BUS2014 is called Supertype of my BO ZBUS2014. Business Object without Super type Here my BO is completely customized. It does not refer to any standard BO available in the SAP system. Now in the slides down we will see step by step approach to create a BO without a supertype. Scenario We have a Z table by the name ZEMPDETAIL. This table has three fields, Employee Number (PERNR), start date(BEGDA) and end date(ENDDA).Whenever a record is entered in this table ,the start date (BEGDA) should be saved as the sy-datum (current date) automatically and mail should be triggered stating that a new entry has been created into the table to a particular user . We will first see the creation of the table and its table maintenance step by step

Trigger Workflow When a Record is Created in a Database Table

Embed Size (px)

Citation preview

Page 1: Trigger Workflow When a Record is Created in a Database Table

Trigger workflow when a record is created in a database table

Step 1: Create a Database Table in SE11

This document shows step by step process for the creation of a business object, table maintenance events and linking them to workflows in the SAP system.

Also this document shows how to integrate the business object created with SAP workflow.

Business objects are of two types

With Super Type

Without Super type

Business Object with Super type

In this case the BO refers to a standard BO already existing in the SAP system. We create our own BO with by coping the existing standard BO . Let’s suppose we have a BO BUS2014 which is Purchase contract. Now if I want to add my own

attributes /methods in addition to the standard, I will create ZBUS2014 which has all the items in BUS2014 plus my own attributes and methods. In this case BUS2014 is called Supertype of my BO ZBUS2014.

Business Object without Super type

Here my BO is completely customized. It does not refer to any standard BO available in the SAP system.

Now in the slides down we will see step by step approach to create a BO without a supertype.

Scenario

We have a Z table by the name ZEMPDETAIL. This table has three fields, Employee Number (PERNR), start date(BEGDA) and end date(ENDDA).Whenever a record is entered in this table ,the start date (BEGDA) should be saved as the sy-datum (current date) automatically and mail should be triggered stating that a new entry has been created into the table to a particular user .

We will first see the creation of the table and its table maintenance step by step

Page 2: Trigger Workflow When a Record is Created in a Database Table

1.) The table is created as per the below screenshot via SE11

2.) Table Maintenance is also created for the table in the same transaction.

Page 3: Trigger Workflow When a Record is Created in a Database Table

3.) Once the table maintenance is created, an event is linked to it.

4.) There are many events available for table maintenance and we will choose the event “create new entry” to suit a purpose and write a code for the same

Page 4: Trigger Workflow When a Record is Created in a Database Table

5.) Now we write a routine / code for that event.

6.) The code is to change the start date to sy-datum and create an event using the function module SAP_WAPI_CREATE_EVENT. Once the event is created it is linked to workflow.

Now the table part is over. We will see the step by step approach to create a business object and the linkage to a workflow.

Page 5: Trigger Workflow When a Record is Created in a Database Table

Step 1 – Creating a business object

• Go to the Transaction SWO1.

Step 2 – Create the object type by giving the details

Page 6: Trigger Workflow When a Record is Created in a Database Table

Step 3 – Business object without a super type is now created. Existence check and Display methods are

the default methods available in all sorts of Business objects. IFSAP is the standard interface used across

all the business objects. These get automatically appended to our business object as soon as we create

them.

Step 4 – Creating an event in the Business object so that it can be linked to the table maintenance event and called as workflow start event.

Page 7: Trigger Workflow When a Record is Created in a Database Table

STEP 5 – The business object has to be implemented. First the object components are implemented and then the business object is implemented.

Page 8: Trigger Workflow When a Record is Created in a Database Table

STEP 6 - The business object has to be released. First the object is released and then the business object components are released.

STEP 9 – Business Object Generation

Page 9: Trigger Workflow When a Record is Created in a Database Table

The business object ZTAB_CHG is ready for and can be used in the workflow.

Step 1 -> Workflow builder – SWDD

Step 2 - >Creating a start event for workflow to trigger

Step 3 -> Activate the start events

Page 10: Trigger Workflow When a Record is Created in a Database Table

Step 4 -> Set the default binding

Step 5 -> Agent Assignment

Page 11: Trigger Workflow When a Record is Created in a Database Table

Step6 -> Event linkage is now available from our workflow definition side

Step 7 -> Inserting a step in our workflow for sending a mail

Page 12: Trigger Workflow When a Record is Created in a Database Table

Step 8 -> Email step in a workflow

Here we enter the user id, the subject of the mail and the mail content as per the screenshot below.

Step 9 -> The workflow is now completed

Page 13: Trigger Workflow When a Record is Created in a Database Table

Step 10 -> Now we have to notify the system whenever the event ZCHANGE_DATA occurs this workflow should be called.

The Transaction code is SWETYPV

Step 11 -> Check for a duplicate entry for the same object BO type.

Step 12 -> Linking the workflow with event

Page 14: Trigger Workflow When a Record is Created in a Database Table

OUTPUT

Output at the business workplace (Transaction SBWP) of user specified in the workflow:

And the mail content in the inbox of the user is shown in the screenshot below.