Skip to Content
Technical Articles
Author's profile photo Naveen Veshala

SAP Flexible Workflow Custom Scenario development with My Inbox Integration

1.   Background:

Flexible Workflow is a new concept introduced in SAP S/4HANA with the objective to simplify  workflow configuration. It is recommended that we use the new Flexible Workflow functionality in S/4HANA.

The flexible workflow is based on a set of predefined workflow scenarios and tasks. This provides the functionality to define condition-based workflow for different processes in the system.

It is possible to define single or multi step approval processes, and the relevant workflow items are made available in the My Inbox Fiori App for the approvers. Manage Workflows Fiori App is available to configure flexible workflow scenario, and these apps allow the Business process specialist to set up workflows based on the business requirement.

SAP pre-delivered many such flexible scenario in procurement, finance etc. and SAP help is available to set up/activate those templates. However, I found some difficulty to create custom template by using this new technology and integrate them in my inbox. To address that, I have prepared this blog post to fulfil one simple multi step scenario which we come across in every implementation.

2.   Multi step Approval/Reject Scenario


Multi Step Approval Flow

3.   Objects Involved in this development

  • Flexible workflow scenario Development
  • Responsibility rule to get L1 approver
  • Workflow Class to manage workflow
  • My inbox task configuration
  • Manage Workflow setup for custom workflow
  • Email Templates

4.   Flexible Scenario development:


New tcode being used to create flexible scenarios in S4 system. Flexible block is the main component which will play important role in scenario. We have to first decide all possible decision tasks and activities (background method executions) as per business requirement. As per our sample workflow, we have 3 decision tasks and 1 activity.

Create new flexible workflow scenario with class based.


New Scenario details

Create one container element employee of class type to hold all employee object details.


Workflow Element


Go to Header and update start event details. I have created one START event in custom class which will be used to trigger this WF.

Create all required activities as per business requirement. As per our sample requirements, we have user decision steps like Level1 Approval, Level 2 Approval, To Requestor and activity like Post Employee data by final approver.




Create all required Agent rules as per business conditions. For the sake of POC, I have used one responsibility rule with one agent maintained manually to get L1 Approver. But in real time scnario, these agents will be determined in FM based on some roles or any other conditions. That FM being used in PFAC rule.


The moment we create activities in Flexible block, it will ask us to provide all task details for that activity. We need to provide required task details whether user decision or activity. I’m not going too much here as this is normal workflow functionality. The moment we create activity, then flow will be created for this activity. Since we have 4 activities in sample workflow, so we can see 4 flows visible in this workflow.

5.   Workflow Triggering logic (Workflow class logic )

Flexible workflow triggering is just same as classic workflow mechanism. We can trigger this either by using BO or Class events. I have created one simple method in class to trigger this wf with some event parameters. I’m passing employee details to workflow through start event for the sake of POC.

Redefine standard WF interface methods at least with empty implementation and activate class.

I have declared one public key attribute in this class and instantiated this value in constructor of the class.

START Event to trigger workflow


Event Parameters

STARTWF method code to trigger this workflow: Below is the sample code to trigger workflow. In real time situations, you can use your own event parameters and populatate those. Based on your requirement, we will call this event in some exits, BADIs, Odata function imports or create/update methods or custom programs etc.

DATA lv_objkey        TYPE sibfinstid.
DATA ls_empdetails TYPE zhcm_st_telecommuting.
DATA lv_param_name       TYPE swfdname.
DATA lr_event_parameters TYPE REF TO if_swf_ifs_parameter_container.

DATA g_evt_param_container   TYPE REF TO if_swf_cnt_container.
DATA l_event_ref             TYPE REF TO if_swf_evt_event.
DATA vl_returncode           TYPE sysubrc.
DATA l_objtype               TYPE sibftypeid VALUE ‘ZCL_WF_EMPLOYEE_FLEX’.   DATA l_event                 TYPE swo_event VALUE ‘START’.
DATA l_event_container       TYPE REF TO if_swf_ifs_parameter_container.

lv_objkey = iv_employee.

CALL METHOD cl_swf_evt_event=>get_event_container
im_objcateg  = cl_swf_evt_event=>mc_objcateg_cl
im_objtype   = l_objtype
im_event     = l_event
re_reference = lr_event_parameters.
ls_empdetails-ei_employeeno = iv_employee.
ls_empdetails-ei_lastname = ‘Veshala’.
ls_empdetails-ei_firstname = ‘Naveen’.
ls_empdetails-ei_postitle = ‘Consultant’.
ls_empdetails-hr_telestartdate = sy-datum.
lv_param_name = ‘EMPDETAILS’.
CALL METHOD lr_event_parameters->set
name  = lv_param_name “#EC NOTEXT
value = ls_empdetails.
CALL METHOD cl_swf_evt_event=>raise
im_objcateg        = cl_swf_evt_event=>mc_objcateg_cl
im_objtype         = l_objtype
im_event           = l_event
im_objkey          = lv_objkey
im_event_container = lr_event_parameters.

CATCH cx_swf_evt_invalid_objtype.
CATCH cx_swf_evt_invalid_event.


6.   Manage Workflow App – Workflow development and activation

Open Manage Workflow app in Fiori launch pad and configure new workflow based on our custom template. As per our flow, we have 3 steps in workflow, L1 approval, L2 approval and finally posting data into SAP. When L1 or L2 clicks on Return button , then workitem routed back to Requestor and then restart workflow when Requestor clicks on Resubmit button. Let us configure workflow to fulfil this business scenario.

Open our custom scenario in Manage Workflow fiori app and click on + add button to create new workflow

Valid from and Valid to need to updated if we want to configure workflow for certain period of time else, leave it blank.

Configure steps. Click on Add in step sequence section and create new step.


Step1 – Level1 Approval

Choose Level1Approver Agent role in receipents. Pls note that these roles are coming from Agent Rules in Flexi block. So based on our business requirement, we have to create different rules to determine agents and use those rules in workflow step configuration.

Add Exception Handling actions as per our flow.

If approver Rejects – then workfow would get cancelled.

Returns  – Then workflow routed back to Requestor.

Note : I have used our other decision step To Requstor as required action for Return action and selected Restart workflow as action result. Due to this, When requstor clicks on Resubmit button, it will again routed back to L1 Approval for review and approval.

Similarly, add other 2 steps as well.

Save and Activate workflow.

7.   My Inbox Task Configuration

Generally, we will activate task filter in real time scenario to display ONLY required workflow tasks work items in My Inbox App. So, unless we add these in Task settings, new decision tasks won’t be displayed in My Inbox app.

SPRO->SAP Netweaver -> SAP Gateway Service Enablement -> Content -> Workflow Settings -> Maintain Task Names and Decision Options


Sample Decision Keys for Return to Tequestor task, These desions will be displayed as buttons in My Inbox App.

Note: These are minimum steps needed to create one custom scenario and expose it to My inbox app. Let us start testing now.

8.   Testing

Login with requestor role and execute test method STARTWF in our workflow class.

Login fiori launchpad with Level 1 Approver  and check the work item in My Inbox app.

Click on Return button . As per our flow, it will be routed back to requestor.

Click on Resubmit, Workflow will restart again and work item goes to L1 Approver for approval.

Resubmitted by requestor and approved by L1. Workitem is awaiting final approval now.

Final L2 approver approved. As per flow, it called background activity and posted data and log updated and workflow got completed.

9.   Dead line Monitoring :

From S4 1909 onwards, SAP  has provided to enable dead line feature for decision taks steps in Manage workflow configuration.

As shown below , overdue item was triggered after 10 min and reflected that in SBWP and My Inbox app of L2 approver.

10.   Email Templates

SAP provided Email template options to generate emails through flexible workflow scenario. Email template name plays main role while sending mail. We have to follow same naming convention as per our scenario to send email.

Copy Pre-delivered email template SWF_CRT_NOTIFY_RECIPIENTS and make changes as per your business requirement in custom template. When copying, you can name custom template as per your scenario correctly.

Naming Standards:

To send email before particular task id : YY1_(Scenario_ID)_CRT_(StepID)

For Ex : YY1-ZZ1_YY1_90000005_CRT_87 to send mail for L2 Approver

To send mail to requestor after completion of workflow with Approved or Rejection

Approve – YY1_(Scenario_ID)_COMPLETE_POSITIVE

Rejected – YY1_(Scenario_ID)_COMPLETE_NEGETIVE

Create one email template for L2 Approver as shown in below screenshot


L2 Email Template

With this i conclude this blog post. My intenstion is to keep all required steps in this blog post, so it is useful to others as well.


I have referred other blog posts and taken flexible workflow introduction from below blog post.

References :  – Introductory text – Overall documentation

Email Templates : How to set up email template in flexible workflow..


Few Updates:

  1. When configuring ATO ( S_ATO_SETUP ) for in app enhancements, use prefix YY1_ , then we can able to create all email templates like for final approal (YY1_(Scenario_ID)_COMPLETE_POSITIVE)  or rejection (YY1_(Scenario_ID)_COMPLETE_NEGETIVE) as per SAP naming standards, Otherwise,it will not take that much name like ZZ1_YY1_*.
  2. If you want to enable dead line monitoring email notification in custom scenarios , then create that template in backend ( SWDD_SCENARIO) and then we will get email options in Manage workflow app.
  3. In above example, i have used seperate background task to update the data in to SAP . How ever, we can still wrtie this code in flexible workflow run time adopter class which is inherited from standard class -CL_SWF_FLEX_IFS_RUN_APPL_BASE. You can check this class in SWDD_SCENARIO – control tab of scnario definition.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Suman Pandit
      Suman Pandit

      This is a Nice blog. Hopefully we will get more topic on flexible WF from you.

      Author's profile photo Surendra Ganipineni
      Surendra Ganipineni

      Hi Naveen,

      We are doing same requirement , but we are not getting  information TAB details in MY INBOX.

      Could you please guide us, what needs to do in Decision step.



      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author

      Hi Surendra,

      Maintain variable from task container in respected task like below.

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Naveen,

      How to move the Email Template and Workflow Scenario to QA and PRD since while creating in FIORI app it's not asking any TR to capture the same. Could you please share the step by step procedure.



      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author


      You can use below fiori apps to register email templates to transport request and then transport that TR .

      • Configure Software packages
      • Register Extensions for Transport

      We have to use Manage workflow scenarios app to export and import custom flexible workflow templates across the landscape. You can first export the template in dev system to your local folder by using this app and then import the same template file in QA and PROD environments as cutover activity.

      Author's profile photo Anand Babu V
      Anand Babu V

      Hi Naveen,

      Thank you for your input. I am working on it will update you later on the same.



      Author's profile photo Frank Li
      Frank Li

      Hi Naveen,

      Thanks for sharing. The email received in system SOST transaction, how about send email to outlook? If want to send email to outlook, what need to be done?



      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author

      Pls check with your basis team. They will check SCOT config and push emails from SOST to oulook if needed in your non-prod systems for testing purpose.

      Author's profile photo Yan Qun
      Yan Qun

      Hi Naveen,

      Thanks for sharing. We have a question about custom flexible workflow, we want to assign user as receive directly as standard Purchase order flexible workflow, not by custom rule. How do we configure this ? Thanks!

      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author

      I found one interesting blog on agent determination  -  . pls check that once whether it might be helpful to you.

      Author's profile photo Raja Reddy
      Raja Reddy

      Hi Naveen,

      Very Nice blog. Thank you for sharing.

      Author's profile photo Subhashini Kuntala
      Subhashini Kuntala

      Hi Naveen ,


      This is a very nice blog. Thank you for sharing.


      I have a requirement to create a Custom header level Purchase requisition.

      The custom requirement is to send the PR to the requestor for rework. I have copied the started Workflow and added another activity for the requestor.


      But, under exception handling, I'm not getting the "To Requestor" option under Add actions dropdown. I only see the "Do nothing" action.


      Can you please suggest if I'm missing anything?



      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author

      Can you check whether your new To requestor activity is dialog activity or background activity.  It should be dailog activity.

      Author's profile photo Subhashini Kuntala
      Subhashini Kuntala

      Hi Naveen,

      "To Requestor," activity is the same as the user decision step to the approval. ( as in your example)

      How and where can we define actions for Exception handling?





      Author's profile photo Balaji R
      Balaji R

      Hi Naveen,

      This is a Nice blog. Thanks for sharing the valuable information.


      As per the blog I have configured the Email template with naming convention. But still I did not receive any email in SOST. Could you please let me know if any pre-requisites are required set up to receive an email in SOST.


      Email Template



      Author's profile photo Naveen Veshala
      Naveen Veshala
      Blog Post Author

      Hi Balaji, Can you check once whether email id maintained or not in user master ( SU01 ). If maintained, then mail will get triggered and u can check that in SOST. You can check workflow logs as well to see whether email has triggered or not.

      Author's profile photo Suman Pradhan
      Suman Pradhan

      HI Naveen ,

      Thank for sharing the blog . It is a good informative article with steps very detailed out .

      We are working on a similar scenario  and would like your opinion . When using a custom class we are facing a message as "SAP node type for leading object could not found" . Although it is not stopping the working , however is there any way to avoid it .

      Also is there any way to accept input from approver through work item ?


      Suman Kalyan

      Author's profile photo Arun Prema Venkatesh
      Arun Prema Venkatesh

      Hi Naveen,


      Nice blog. Thanks for sharing.

      After creating email in Maintain templates App.

      Did you write any code in callback class IF_SWF_FLEX_IFS_RUN_APPL_STEP~AFTER_COMPLETION_CALLBACK to call Class  CL_SWF_RUN_OM_SERVICE for registering/storing  the entry in table “SWW_WIREGISTER”.

      Or just maintaining the templates in the App is enough to send out mails.


      Arun P V

      Author's profile photo Chiragben Shah
      Chiragben Shah

      Informative blog. Thank you.