Hello everyone! Welcome once again to the EBAL IT blog. Today, we bring you a topic that we know will interest many of you working in the SAP MM (Material Management) area. We’re going to talk about how to implement a workflow to send automatic emails when a purchase order is modified. Yes, you read that right: automatic!
Why You Need a Workflow in SAP MM?
Before we dive into the technical details, let me tell you why a workflow is so essential in the management of purchase orders. Imagine you’re in a business environment where numerous transactions are managed every day. Manual updating and communication with different departments can be a mess and, let’s be honest, quite tedious. This is where the workflow comes into play: to make our lives much easier.
Let’s get to work 😉
Searching for the Business Object
The first thing we will do is search among all that SAP has for a Business Object that suits the task we need, in this case, one that triggers an event when a purchase order already created is modified.
1. Go to the transaction ME23N
And here we see the Business Object for use
And we verify if it has an event that suits our needs
Let’s go to transaction SWO1
We enter the Business Object obtained in the previous step and click on display
And we see that there is an event when the PO changes
Note: We can use the same process described in this article for any other event shown, such as when creating a PO or when it is completed.
Creation of WF
Now let’s get down to business, we proceed to create the WF flow.
We execute the transaction PFTC
We create a new Workflow Model
And we set the restrictions
We assign the event from the previously found Object
En este punto nos pedirá orden.
Now that we have assigned the Business Object to the task, we are going to activate the trigger when modifications are made to a PO.
if we click on the matchcode of the event field, we see all the options that we observed when analyzing the object through SWO1, as shown below
Now we assign the data flow, so we can use the values in the WF
And we activate the event, so that it takes effect
At this point, it will ask for a custom order, we choose the one that interests us, and we see that it has been activated
Now we have completed all the preparations, so that when we modify a PO and save it, an event is triggered. Now we need to specify which operation we will perform, in our case, sending an email
By clicking on the Workflow Builder button, the WF editor appears
In the task, we right-click and select create, and all the possible options appear (we will make future videos with other functionalities)
We choose to send an email
We indicate that the recipient is an email, the email to send, and the subject and body.
In our case, we want to indicate the PO number in the subject, for this, we click on the icon and choose the PO number
And the field appears between &&, we do the same process in the body to get the user who initiates the process and the supplier code
And we save, upon activation it asks for the name of the task and the order where to save it
And now we have the WF created
Now let’s test it.
Modifying a PO
We go to transaction ME22N and change the brief text and save
Now we see the WF
We see that we have a WF entry assigned to this order
Now let’s go to SOST to view the email directly
And we see that there is an email, and if we enter, it matches the email seen in the WF previously
And Done!