Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 


Today in this blog post, we will have a deep dive to understand how system uses email templates and how email is triggered by flexible workflow. There are many beautiful blog post available today on email template on flexible workflow, but the information on how system uses these template to trigger email is missing. So, we will discuss the same in this blog post.


Knowledge of Flexible workflow and email template in Flexible Workflow is required. We won't be discussing how flexible workflow works and how email template can be maintained to trigger email for flexible workflow. There are already so many beautiful blog post are available. Some of the links are given below. If you have not gone through the concept of flexible workflow and email template, then it is recommended to have a look into below links first then continuing this blog post

Los Geht's:

A couple of points which are worth re-iterating:

  • The email template for Flexible Workflow is maintained using Fiori App "Maintain Email Template".

  • The name of the email template should follow the below naming convension

    • YY1_<Scenario_ID>_CRT_<StepID> / YY1_<Scenario_ID>_CRT_ALL: Email template to be used when workitem is created

    • YY1_<Scenario_ID>_COMPLETE_POSITIVE: Email template to be used when workflow is approved (Point to note: It will be triggered when the workflow is approved, and not the workitem)

    • YY1_<Scenario_ID>_COMPLETE_NEGATIVE: Email template to be used when workflow is rejected(Point to note: It will be triggered when the workflow is rejected)

So, whenever the email templates are maintained, it is stored in below tables

SMTG_TMPL_HDR Email Template Header
SMTG_TMPL_HDR_T Email Template Name and Description

(Email template defined in Maintain Email Template Fiori App)

(Email template stored in Table)

Point to note: We can see the table is a cross client table, so no need to transport the email template across client.

Now that email template has been maintained using the Fiori apps, various event like work item creation, workflow approval and rejection, system check for the respective template associated with the workflow and creates an entry in the table "SWW_WIREGISTER" on the respective event(WI Creation, Approval and rejection) if email template is maintain for those events.

Let's have a look into table entry to have an idea how it's looks.

(Registration of a Work Item)

We can notice below points in the table entries

  • Application type is OPM(Output Management)

  • Subcategory

    • 001 - Email on workitem creation

    • 003 - Email on workflow approved/rejected

  • Value: We can in value field the respective "Email template" and "use case" has been stored

  • Use cases: Use case is the events on which email needs to be sent.

    • useCase-mailToWorkitemRecipients

    • useCase-postiveWorkflowCompletion

    • useCase-negativeWorkflowCompletion

The class "CL_SWF_RUN_OM_SERVICE"(Workflow: Mail service via output management) is responsible for workitem registration.


We can see various important method available in the class, for example "REGISTER"  method, which saves the entry to "SWW_WIREGISTER" table and "GET_TEMPLATE_ID" gets the workflow email template. All the method name are self explanatory, so I am skipping the explanation of the functionality of these methods.

(Constants in class CL_SWF_RUN_OM_SERVICE)

Let's have a look, where and how the class "CL_SWF_RUN_OM_SERVICE" is used to registered the workitem to trigger the email.

Let's have a look into the the class "CL_SWF_RUN_WIM_DIALOG", which will be called when a dialog workitem is created. The class has a method "CREATE_VIA_WFM" which calls the register method of class "CL_SWF_RUN_OM_SERVICE" to save the entry in "SWW_WIREGISTER".

(Method CL_SWF_RUN_WIM_DIALOG =>CREATE_VIA_WFM registering the workitem for email)

So, this how the entry will be created in the table "SWW_WIREGISTER" for workitem creation use cases. Similarly system has to register the workitem on Workflow completion. That will be called from "IF_SWF_FLEX_IFS_RUN_APPL_STEP~AFTER_COMPLETION_CALLBACK" of callback class of the respective Flexible workflow.

Below is the screenshot of call back classes of flexible workflow for PO.(T-code: SWDD_SCENARIO_DISP, WF Template: WS00800238)

So, we understood how system is storing the entry in "SWW_WIREGISTER". Now, that the entry are available in the table, but email has not yet triggered. So, how the email is triggered?

There is a report program "RSWF_OUTPUT_MANAGEMENT" which runs as a batch job every 1 min, which reads the table "SWW_WIREGISTER" and triggers the email.

Below are the screenshot of the program RSWF_OUTPUT_MANAGEMENT. We can see on the line number 28, the method "EXECUTE_ACTION" is called on object "LO_INSTANCE" and LO_INSTANCE is a object of class "CL_SWF_RUN_JOB_OUTPUT_MGMNT".


We can see the "EXECUTE_ACTION" method calls "SEND_MAIL_TO_RECIPIENTS" method.


"Vallah!!!" We can see the "EXECUTE_ACTIONS" uses the method "SEND_COMPLETION_MAILS" of class "CL_SWF_RUN_OM_SERVICE". The method SEND_MAIL_TO_RECIPIENTS reads the table "SWW_WIREGISTER" and sends the email to the recipient using email template.

(Overview of process)


So, in this blog post we saw how work item is registered in table "SWW_WIREGISTER" using the class "CL_SWF_RUN_OM_SERVICE" during the Workitem creation, workflow approval or rejection, based on the availability of the email template. We also saw how the report program "RSWF_OUTPUT_MANAGEMENT" uses the same class "CL_SWF_RUN_OM_SERVICE" to send email. So, we had a complete picture how system handles email template on various events like workitem creation, workflow approval and rejection.

Hope this helps!
Labels in this area