Skip to Content
Technical Articles

Fiori Launchpad: Display Background Send Mail Workflow Task with Decision Step in My Inbox and Notification Center

This blog post is to share solution of the recent problem I faced in SAP Fiori My Inbox App and Notification Center with all of you

Presumptions

  • My Inbox Fiori App has been configured
  • Notification Center (if required) has been configured

Problem

I faced this problem when I used the Send Mail step to send Notification in a Workflow.

 

In SAP GUI it was working perfectly. These get displayed in Unread Documents/Documents Category of SAP Business Workplace (SBWP)

 

But these were missing in the My Inbox app and also the Notification Center. While trying to find a solution for this, I saw the SAP Note shown below and came to this conclusion –

My Inbox app and Notification Center in Fiori Launchpad do not support the Background Tasks of the Workflow. Only the workitems of User Decision dialog steps/tasks are shown there. 

 

Solution

Go to the Control Tab of the Workflow Step and open the Task –

 

To make it a User Decision Task, Uncheck the Background Processing Checkbox and Check the Confirm end of Processing as shown below –

 

Confirm end of Processing will provide the decision step button called “Complete Workitem” in SAP Business Workplace (SBWP). The name itself clarifies that this button is used to complete the Workitem. Hence, after user action, workitem will be moved out of the Open Workitems Category in SBWP (Though it will be still in Documents category).

After making this change, the workitem will start appearing in My Inbox and Notification Center. And we have achieved our 1st milestone. 🙂

As you can see in the screenshot below, the User Decision button “Complete” is missing in Fiori My Inbox app –

 

Because of this Send Mail Workitems will never move out of My Inbox, as a result it will get too much of load. So, let’s start the next step.

What we need to do is a small configuration to get the Decision Step Button in My Inbox app. Go to –

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

 

Enter the Workflow ID and Step ID of the Send Mail Task in Workflow. Then, mark the entry and select “Decision Keys” –

 

Enter these values now –

  • Decision Key – Numeric value. This we will get back in return after user action
  • Decision Text – Use any Description for the button which is suitable as per Users
  • Nature of the DecisionPositive/Negative/Neutral, this will manage the color of the button

I have configured it as “Complete” –

 

Now the “Complete” Button will start showing in My Inbox

 

But pressing this button will not give any result as of now. For that, we need to implement a BADI/IWWRK/BADI_WF_BEFORE_UPD_IB. In this, we get the “Decision Step” taken by the user and it can be processed as per requirement.

BADI Implementation – Z_MYINBOX_NOTIF_WF

 

Filter values in the BADI Implementation should be filled with the Workflow ID and Step ID of the Send Mail Task in Workflow, so that it gets executed only for these –

 

There is only one method, /IWWRK/IF_WF_WI_BEFORE_UPD_IB~BEFORE_UPDATE, available which is sufficient for our requirement –

 

Code Snippet –

  METHOD /iwwrk/if_wf_wi_before_upd_ib~before_update.
*&--------------------------------------------------------------------&*
*&  Revision Log                                                      &*
*&  Date           : 05-Jun-2020                                      &*
*&  Author         : Harsh Bansal (BANSAL)                            &*
*&  Revision Tag   : Initial Version                                  &*
*&  Description    : Complete Workitem in MyInbox after User Decision &*
*&--------------------------------------------------------------------&*

* Local Data Declaration
    DATA: lv_subrc  TYPE sy-subrc,
          lv_status TYPE sww_wistat.

    CLEAR: lv_subrc,
           lv_status.
    IF iv_decision_key EQ '0001'.
* Status: Ready to Committed Status
      CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
        EXPORTING
          workitem_id = is_wi_details-wi_id
        IMPORTING
          return_code = lv_subrc
          new_status  = lv_status.
      IF lv_subrc EQ 0
        AND lv_status NE 'COMPLETED'.
        CLEAR: lv_status.
* Status: Committed to Completed Status
        CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
          EXPORTING
            workitem_id = is_wi_details-wi_id
          IMPORTING
            return_code = lv_subrc
            new_status  = lv_status.
      ENDIF.
    ENDIF.

  ENDMETHOD.

 

To complete the workitem and move it out of the My Inbox app when user presses the “Complete” button, we have to call the FM – SAP_WAPI_WORKITEM_COMPLETE

As you can see it has been called twice, that’s because after running one time, it just changes the status of workitem from “READY” to “COMMITTED” only. That’s why it has to be called again and now after execution, status of the workitem gets updated to “COMPLETED” and workitem will be moved out of My Inbox app

Note – Check on Decision Key value is based on the configuration we did earlier

 

Conclusion

Changes to be done –

  • Uncheck Background Processing and Check Confirm end of Processing in Send Mail Task
  • Configuration to get the Decision Step Button in My Inbox
  • BADI Implementation to complete the workitem after user action

 

That’s it, now every time this workflow will be triggered, it will be available in SAP Business Workplace (SBWP), Fiori Launchpad My Inbox app and Notification Center. After user action SAP_WAPI_WORKITEM_COMPLETE in BADI will change the status of Workitem to “COMMITTEDand then “COMPLETED. Finally, it will be cleared out from all the platforms.

 

Voila! We have reached our goal 🙂

 

Thank You !!

10 Comments
You must be Logged on to comment or reply to a post.
  • what if we make a a fork in the WF.

    one arm is the mail and the other arm is the task with same same logic as the batch job.

    that task will automatically run.

    that would be less performance intensive.

    maybe in that we can get the workitem for which we want as we will have the workflow id as well.

     

    • Hello Siddharth,

      Thank you for your suggestion.

      Actually we don’t need it in either Background Job or Workflow. Today while trying to make the solution better, I implemented an easier and much better one. I have updated the same in the blog post. Please try to go through it again. 🙂

      Regards,
      Harsh Bansal

      /
      🙂
  • Good one Harsh.

    I was also trying to build this since the FIORI launch pad was not responding to background tasks of the workflows. This really helps.

    Thanks

  • Hi Harsh,

    Thank you for really helpful blog, One thing I am trying to figure out with my Inbox app to have more information while approvals. for example a previous PO approval app gave lot of details in Info tab .But My inbox does not give that much information . any idea how we can enrich info tab in My inbox app to provide information like previous specific approval apps (e.g PO approval, Pr approval apps ).

    Regards,

    Hitesh

    • /
    • Hi Hitesh,

       

      You have to configure the Task into SWFVISU Tcode otherwise it does not display Header/Item display into My Inbox.

      You need to provide required OData service, Entity set and Annotation Model with link to Document. Refer standard Task of PO into SWFVISU, you will understand required steps to follow.

       

       

      Regards
      Samir

  • Thank you for that very interesting blog.

    I am wondering if you could achieve the same result with less effort if you did it this way:

    • instead of an email step, create a ‘notify’ step based on a decision task. The text of the email is in the decision task description
    • give the decision task a single decision option: ‘Confirm’

    I haven’t used Fiori My Inbox much, but I would expect the following result:

    • the workitem appears in My Inbox with the email text
    • the ‘Confirm’ button is automatically shown at the bottom (without config)
    • pressing the’Confirm’ button completes the workitem (without Badi coding)

    Am I hoping/expectng too much? I will try this myself when I have a chance! 🙂