Send SAP workflow notifications to Microsoft Teams
Send SAP workflow notifications to Microsoft Teams using Looply
This is a step-by-step guide to triggering a notification in Teams from an SAP workflow.
In this example we have defined a simple workflow that is triggered from an event. We start by identifying the event for a customer master change, using the Event Trace (SWEL).
The event trace shows that event BUS1006 – CHANGED is triggered, so we take that as the starting place for the workflow definition.
Next we add binding from the triggering object to the workflow container.
In this case we just take one field, the customer number. We create a custom variable in the SAP workflow ‘PARTNER’ for this purpose.
Next we add a step to trigger Looply. Normally we would add this step to an existing workflow.
The Looply step is based on a standard task to trigger Looply using /LOOPLY/WF_OUT->TRIGGER
We need these 4 fields in the Looply binding.
Optionally you could pass in partner number or other data to &IM_DATA&.
Now the SAP workflow can be activated.
The final step for the SAP workflow is to activate the event type linkages.
We use the same object type and event as in the workflow triggering event, and set the receiver to be the workflow ID.
Next we set up the Looply Process Determination table.
The key is based on the fields we set in the workflow binding.
This table is used to determine the Looply Workflow ID and the function to prepare the data for Looply.
The trigger function can include lots of process-specific data lookup, or pass the contents of the SAP workflow container.
FUNCTION zlooply_wf_trigger_generic. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(IM_WORKITEMID) TYPE SWW_WIID *" VALUE(IM_DATA) TYPE SWF_STRING *" EXPORTING *" VALUE(EX_CONT_DATA) TYPE SWF_STRING *" VALUE(EX_SUBRC) TYPE SYSUBRC *" VALUE(EX_MESS) TYPE BAPIRET2 *" CHANGING *" VALUE(CH_LOOPLY_DATA) TYPE /LOOPLY/TRIGGER_DATA_T *"---------------------------------------------------------------------- * This function is called by Looply Core when task 90000004 is used inside an SAP Workflow. * IM_WORKITEMID: This will contain the workitem id (assuming you bound it to it in swdd when creating the wf). It can be used to get data from the workflow container using fm SAP_WAPI_READ_CONTAINER *----------------------------------------------------------------------------------------- * Data Declarations DATA: ls_looply_data TYPE /looply/trigger_data_s, *----------------------------------------------------------------------------------------* *----------------------------------------------------------------------------------------* CALL FUNCTION 'SAP_WAPI_READ_CONTAINER' * Transform to JSON * Get the latest workitem * Get the approver(s) IF lt_recipients IS INITIAL. LOOP AT lt_recipients INTO ls_recipients. * Read approver email address ls_looply_data-recipient_email = ls_address-e_mail. ENDLOOP. ENDIF. ENDFUNCTION. |
To the above generic code, we add this code to make the partner number easier to map in Looply
* Get partner number read table lt_simple_cont into ls_simple_cont with key element = 'PARTNER'. ls_looply_data-UTIL_DATA = ls_simple_cont-value. |
In the Looply Workflow Studio we define the Looply Workflow. Once created, this gives us the workflow ID to put into the Looply Process Determination table.
In this example we just show a card, wait a minute, and then delete it.
We can use data from SAP in the card definition.
This card consists of two text fields, and the second one is bound to the ‘util_data’ field that we filled in the triggering function.
In this way, we can add the customer number field to the adaptive card.
That’s it – now we’re ready to test or add more information, links and actions to the card.
See the result in the video: