Microsoft Teams integration

The integration between PreBilt for EWM™ Operator Messaging and Microsoft Teams using Power Automate facilitates seamless communication between PreBilt for EWM™ users and your organisations' Teams channels, enabling notifications and real-time messaging. The guide is intended for SAP consultants and IT professionals tasked with implementing the integration.

Prerequisites

SAP requirements

  • SAP EWM system with PreBilt Operator Messaging enabled

  • Necessary authorizations for creating function modules, enhancements

Microsoft Teams/Power Automate requirements

  • Administrative access to the Microsoft Teams tenant

  • Agreed and set up dedicated Team within Microsoft Teams

  • Agreed and set up dedicated Channel(s) within the dedicated Microsoft Team

  • Access to Power Automate with rights to create workflows.

General Requirements:

  • Established communication between SAP and the internet (or middleware for closed network scenarios).

Architecture

The process begins in the PreBilt for EWM UI application when a user selects a specific message type associated with a receiver type “T” in /N/TCTM/EWM_OMCFG.

In the backend, the enhancement implementation ZTCTM_EWM_SRV_OM_NOTIF_MSTEAMS, configured with a filter value of RCV_TYP = T, within the BAdI /TCTM/EX_EWM_SRV_OMSG_NOTIF, manages the outbound message logic.

The implementing class method /TCTM/IF_EX_EWM_SRV_OMSG_NOTIF~SEND puts the function module call into an RFC queue.

The function module ZTCTM_EWM_SRV_OM_NOMST_SEND is responsible for constructing the payload. It retrieves a JSON-based wrapper and adaptive card templates from the SAP MIME Repository, replaces placeholders such as {team}, {channel}, and {message} with actual data, and sends the final payload via an HTTP POST request to the webhook URL of the "Post PB Message from Webhook" workflow.

The webhook connection is managed via an SM59 HTTP destination of type G. This allows environment-specific configuration (e.g., Dev/QA/Prod) to be maintained centrally without hardcoding URLs or using TVARV/Z tables.

The ABAP code retrieves the destination using cl_http_client=>create_by_destination, with the actual endpoint and proxy settings maintained in the SM59 configuration.

The webhook URL within the workflow acts as an endpoint to listen for incoming HTTP POST request, when it receives the payload, it will process the data and posts an adaptive card message to the appropriate Microsoft Teams channel,

The trigger for this workflow is “When a teams webhook is received”

When a user replies to an adaptive card message in Teams, the reply triggers the second Power Automate workflow “Handle PB Message Response”, which processes the reply and sends the data back to SAP with the help of a custom connector “API HUB PROXY”.

This reply is routed to the SAP ICF service ZTCTM_EWM_OM, which acts as the inbound endpoint for handling incoming messages. If the customer has implemented a Web Dispatcher, the reply is first routed through the Web Dispatcher, which securely forwards the HTTP request to the SAP backend.

The ICF service uses the handler class ZTCTM_EWM_OM_MSTEAMS_HANDLER.

The handler method IF_HTTP_EXTENSION~HANDLE_REQUEST validates the reply, identifies the SAP user based on the email address in the payload, and retrieves the original message details using the message ID. It then creates a new message in SAP using the core service class /TCTM/EWM_SRV_OM_CORE. The new message is delivered back to PreBilt device through the ewm_push_channel WebSocket service.

Last updated

Was this helpful?