Skip to Content

The following steps describe how we can create notifications. The scenario here is to create a notification through a simple workflow template that will take notification text and agent as input and simply forward the notification with the text to that agent. I will be using a method instead of a function module. If you prefer to use a function module, you can still follow up (I’ll note what you need to  change).


  • Create a workflow utility class, or use one if already exists – Transaction SE24 (If using function modules, then, create or use a workflow utility function group – Transaction SE37). 
  • Implement the IF_WORKFLOW interfacewhich will implicitly implement BI_OBJECT and BI_PERSISTENT (this step is not applicable to function modules)
  • Under the “Properties” tab, enterSWFCO in the “Type group/Object type” table and hit Enter (for function module, type “TYPE-POOLS swfco” in the TOP include).
  • Create a new static public method (create_notification) or a function module Z_CREATE_NOTIF 
  • Click the “Parameters” button todefine needed parameters that will be provided by the workflow template. Notethat the IM_WI_ID is mandatory. The text field IM_TEXT is not “technically”mandatory but it is definitely needed or otherwise this whole exercise ispointless. You will need 5 importing parameters: IM_WI_ID (the calling workitem), IM_TEXT (notification text), IM_AGENT_TYPE (receiver type: US for user,S for position, P for person, O for organization unit, etc.), IM_AGENT_ID(receiver ID depending on the agent type), IM_COMMIT (flag whether to commit).2 parameters can be defined as export parameters: EX_WI_ID (work item ID forthe notification task that was just created), and EX_WI_HEADER (Header fromtable SWWWIHEAD). 
  • Click the “Exceptions” button (similarly, the “Exceptions” tab exists for function modules) 


  • Click the “Code” button () next to “Exceptions” (or the function module’s “Source code” tab)


Note that swfco_wi_rc_latest_end is a constantdefined in type pool SWFCO that is used in methodCL_SWF_RUN_WIM_DEADLINE=>GET_DEADLINE_TYPE. If you don’t set fieldLS_PROP-WI_DH_STAT with an expected value, function module SWW_WI_CREATE willcreate a short dump. Also, feel free to modify the code to add more agents.


The code in the screenshot (you will need some adjustment for the function module):

METHOD create_notification.
    ls_prop   TYPE sww_wihext,
    ls_agent  TYPE swhactor,
    lt_agent  LIKE TABLE OF ls_agent.

  ls_prop-top_wi_id  = im_wi_id.
  ls_prop-wi_dh_stat = swfco_wi_rc_latest_end.
  ls_agent-otype     = im_agent_type.
  ls_agent-objid     = im_agent_id.
  APPEND ls_agent TO lt_agent.
      checked_wi     = im_wi_id
      do_commit      = im_commit
      text           = im_text
      properties     = ls_prop
      workitem_type  = swfco_wi_deadline
      wi_id          = ex_wi_id
      wi_header      = ex_wi_header
      id_not_created = 1
      read_failed    = 2
      OTHERS         = 3.
  IF sy-subrc <> 0.
    RAISE ex_notification_failed.
        wi_id            = ex_wi_id
        do_commit        = im_commit
        agents           = lt_agent
        no_authorization = 1
        update_failed    = 2
        invalid_type     = 3
        OTHERS           = 4.
    IF sy-subrc <> 0.
      RAISE ex_agent_failed.




  • Save and activate the class andthe method 



Integratingthis method into a Workflow template  


For more information on how to build workflow templates and tasks, refer to the “Practical Workflow forSAP” book ( to SAP’s help web page (


  • For the function module, you will need to create a corresponding business object method (transaction SWO1). Go to that transaction, enter an object name (say ZWFOBJ), and then place the cursor on the methods node. Click “Create” icon then click Yes when asked whether you want to “Create with function module as template?” Enter the function module name then continue keeping all defaults as they are. You will then be asked whether you want the code auto-generated and you will need to select Yes. A new method will be created that has the same function module name without any underscores.
  • Create a standard task forcreating notifications (transaction PFTC)
  • Enter standard task details asshown (for function modules, you will need to change the Object Category to BOR “Object Type” and then provide the business object and method names defined earlier)
  • When asked whether to transfermissing parameters, click “Yes”
  • Click the binding button justbelow the “Method” label 
  • Click the “Auto-Generate” buttonto link the task parameters to the method parameters as shown in the screenshot 
  • After saving, the system willgenerate a task ID (in my case the number was 90000075). The task from now onwill be TS90000075. This number will depend on the system this exercise isbeing performed in.
  • There is no need to set up thetask agent assignment (menu option: Additional data à Agent assignment à Maintain) since thistask is a “background” task.
  • Go back to PFTC’s main screenand create a new workflow template 
  • Enter workflow properties(screenshot shows an example) 
  • Click the “Container” tab andenter all parameters you’ll need to use in the workflow. In my case, I createdthe following:
  1. IM_TEXT_PARAM (type: TEXT20)so that I can pass text when running the workflow
  2. IM_AGENT (type: SWHACTOR) sothat I can determine the notification agent dynamically when starting theworkflow 
  • Go back to the “Basic Data”tab and click the “Workflow Builder” button 
  • Double-click the “Undefined”white step, then select “Activity” 
  • Enter the task ID in the Taskfield (in my case it is TS90000075) 
  • Adopt the binding defaults 
  • Click the “Binding” button again,and bind the container’s &_WORKITEM.TOPFLOW& to the task’s&IM_WI_ID& parameter. Also, map the agent into the&IM_AGENT_TYPE& and &IM_AGENT_ID&. Optional: Map some text tothe task’s &IM_TEXT& parameter. In my case, I created an inputparameter called im_test_param for the workflow that I pass on to the task.This way, every time I create a workflow instance I can change the text thatwill show up in the user’s inbox and in the workflow log. 
  • Click the green check mark toreturn the step definition, then again, click the green check mark to return tothe main Workflow builder screen
  • Save and Activate the workflowtemplate
  • Since this is a customdevelopment that “defies” SAP standard for creating notifications other than“missed-deadline” there is another trick you might want to consider. In theworkflow log (transaction SWI1), any task of type D will show as “MissedDeadline” as in the below screenshot. Technically, it will not make adifference, but if you are very picky as a workflow administrator, you canoverwrite this description. The following steps describe how you can changethat description. 
  • Go to transaction SM30 andenter table name SWWVTYPTXT 
  • Click the “Maintain” button andyou will get the following warnings: 

If you are OK with overwriting SAP data, thenproceed.

  • Find all entries of type D(Deadline Work Item). In front of the corresponding entry, edit the text asrequired for all available languages. For the purpose of this exercise, I’llchange only the English text to “Custom Notification.” Note that you will needto attach this change to a development request which makes sense since this isa client-independent table. 
  • Now, let’s test our workflow;go to transaction SWUS and enter the workflow template ID generated earlier(WS90000039 in my case) 
  • Fill input parameters asrequired and click the run button (
  • Go to the workflow log(transaction SWI1) and display the last triggered workflow tasks and items 
  • Once you see the notification work item created, go to your Universal WorkList in EP and display your inbox 
  • The notification should bethere as displayed above.


To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Christophe BRETON

    Great article that I will use this afternoon !!!

    One question : can we use the “Agents” options instead the parameters of the CREATE_NOTIFICATION method ? This need some change on the method, but simplify the use, I think.

    This will be more efficient, isn’t it ??


    1. Anonymous
      Hello and thanks 🙂

      If you mean the “Agent” option when defining the step in the workflow template then it will not work. Step agents are meant for interactive tasks that need to action the step (like approvals, data entry, etc.). Creation of the notification itself is a “background” task. So, basically, notification is just like sending an e-mail. In the e-mail task you assign the e-mail address in the step definition. Here, you assign the agent in the binding.

      Please let me know if this answered your question or if I misunderstood.



  2. Vinoth Kumar
    Hi Abdullah

    Nice blog and is it a alternative of SONIC connector?, as normally we will receive notification to UWL via SONIC.


    1. Anonymous
      Thank Vinoth,

      It is NOT an alternative to SONiC. It is just a work-around in case you had difficulty getting SONiC set up in the system.


Leave a Reply