Skip to Content

ABAP Push / Messaging Channel and SAPUI5 Demo Application

Based on the Blog series published by Masoud Aghadavoodi Jolfaei:

ABAP Channels Part 1: WebSocket Communication Using ABAP Push Channels

ABAP Channels Part 2: Publish/Subscribe Messaging Using ABAP Messaging Channels

ABAP Channels Part 3: Collaboration Scenario Using ABAP Messaging and ABAP Push Channels

Specification of the Push Channel Protocol (PCP)

I’ve created an SAPUI5 Demo application using the ABAP Push Channel (APC, WebSockets) and ABAP Messaging Channel (AMC). To benefit from the WebSocket technology in your browser please check the support matrix at At the ABAP Backend I’ve used a NetWeaver ABAP Application Server 7.40 SP8.

ABAP Push Channel

Let’s define the ABAP Push Channel first. Check out the above mentioned Blog’s for details:


Here’s the source code of the class Implementation:

CLASS zcl_apc_wsp_ext_zapc_echo DEFINITION
  INHERITING FROM cl_apc_wsp_ext_stateless_pcp_b
    METHODS if_apc_wsp_ext_pcp~on_message
    METHODS if_apc_wsp_ext_pcp~on_start
    CLASS-METHODS prepare_message_for_ui
        !iv_text       TYPE string
        VALUE(rv_text) TYPE string .
CLASS zcl_apc_wsp_ext_zapc_echo IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_MESSAGE                      TYPE REF TO IF_AC_MESSAGE_TYPE_PCP
* | [--->] I_CONTEXT                      TYPE REF TO IF_APC_WSP_SERVER_CONTEXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_apc_wsp_ext_pcp~on_message.
    DATA: lo_producer TYPE REF TO cl_amc_message_type_pcp.
* retrieve the text message
        DATA(lv_text) = i_message->get_text( ).
        lo_producer ?= cl_amc_channel_manager=>create_message_producer(
          i_application_id = 'ZAMC_ECHO'
          i_channel_id     = '/echo' ).
        lv_text = prepare_message_for_ui( lv_text ).
        DATA(lo_msg) = cl_ac_message_type_pcp=>create( ).
        lo_msg->set_text( i_message = lv_text ).
        lo_producer->send( i_message = lo_msg ).
      CATCH cx_ac_message_type_pcp_error INTO DATA(lx_pcp_error).
        MESSAGE lx_pcp_error->get_text( ) TYPE 'E'.
      CATCH cx_amc_error INTO DATA(lx_amc_error).
        MESSAGE lx_amc_error->get_text( ) TYPE 'E'.
      CATCH cx_apc_error INTO DATA(lx_apc_error).
        MESSAGE lx_apc_error->get_text( ) TYPE 'E'.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_CONTEXT                      TYPE REF TO IF_APC_WSP_SERVER_CONTEXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_apc_wsp_ext_pcp~on_start.
* bind the WebSocket connection to the AMC channel
        DATA(lo_binding) = i_context->get_binding_manager( ).
          i_application_id = 'ZAMC_ECHO'
          i_channel_id     = '/echo' ).
      CATCH cx_apc_error INTO DATA(lx_apc_error).
        DATA(lv_message) = lx_apc_error->get_text( ).
        MESSAGE lx_apc_error->get_text( ) TYPE 'E'.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_TEXT                        TYPE        STRING
* | [<-()] RV_TEXT                        TYPE        STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD prepare_message_for_ui.
    TYPES: BEGIN OF t_message,
             text TYPE string,
             user TYPE uname,
             date TYPE timestamp,
           END OF t_message.
    DATA: ls_message TYPE t_message.
    ls_message-text = iv_text.
    ls_message-user = sy-uname.
    GET TIME STAMP FIELD ls_message-date.
    DATA(lo_json_witer) = cl_sxml_string_writer=>create(
                            type = if_sxml=>co_xt_json
    CALL TRANSFORMATION id SOURCE ls_message = ls_message
                        RESULT XML lo_json_witer.
    DATA(lv_xstr) = lo_json_witer->get_output( ).
        im_xstring = lv_xstr
*       im_encoding = 'UTF-8'
        ex_string  = rv_text.

ABAP Messaging Channel

For the ABAP Messaging Channel it is important to define the Authorized Programs:


HCP Git to GitHub

This is just to document how to bring an app developed in SAP Web IDE from the HCP Trial Git repository to GitHub. I’ve used the following steps adopted from the documentation:

Adding an existing project to GitHub using the command line – User Documentation

First of all clone the HCP Git repository to the local system and switch to the new folder:

git clone https://<HCP Username><HCP Accountname>/<HCP GIT Repository Name>
cd apcecho/

Now create a new repository on GitHub and add this repository. I’ve named it “github”:

git remote add github

As I’ve created some files (Readme, License) in the GitHub Repository this files have to be pulled from the repository:

git pull github

And merged with the master:

git merge github/master

Then push the changes to both repositories:

git push github master
git push origin master

SAPUI5 Frontend

I’ve used the SAPUI5 Application Template in SAP Web IDE to bootstrap my app. You can get the source at:


You can use the Project SAPUI5-Deployer by Graham Robinson to import this Git repository directly into your ABAP stack.

That’s for the moment. Looking forward for your feedback.

You must be Logged on to comment or reply to a post.
  • Thanks Greg, It's a really good example to follow,

    I will try to replicate the same here in our sandbox to get the better end-to-end understanding on the ABAP Push.


    Warm Regards


  • Hi Gregor,

    first of all I have to thank you for that blog. We are working in a project where we have appr. 10 apps for workers in a yard. And we want to be able to send them messages while they are working on their tasks.

    Your blog helped me to build a similar demo application. And immediately after finishing it and considering to use it in the project - two questions arise

    - We want to send messages from our backend to Fiori apps. And we do not want to create APC to the backend. How to integrate the (Fiori) Gateway? I.e. how exchange messages across several systems?

    - What about the lifecycle of the web socket? Will it be closed automatically if the user exits the app and returns to the Launchpad? What happens in case of navigating to another app?
    I did not find information on that. Maybe you have a link or something?

    Best regards


    • Dear Meinrad,

      sorry for the late reply. Regarding your question:

      > how exchange messages across several systems?

      If you don't have a NetWeaver ABAP 7.50 infrastructure you have to fall back to use RFC calls between the systems. In 7.50 ABAP Push Channels also support acting as a client.

      > What about the lifecycle of the web socket? Will it be closed automatically if the user exits the app and returns to the Launchpad? What happens in case of navigating to another app?

      Without having done any real world testing I would think that the websocket is closed. Perhaps Masoud Aghadavoodi Jolfaei has some experience on that.

      Best regards


      • Hi Meinrad,

        for a "system2system" communication (a kind of ABAP Channel bridge between systems)  based on APC I recommend to check the "APC Detached Client" pattern. With this you are able to spawn WebSockets between systems their life cycle does not bound to the client report. A sample code is provided in  "Developing an APC Detached Client" section. I think the question regarding the lifecycle of WebSockets used in apps running inside Fiori Lunchpad (FLP) has to be answered by FLP colleagues.I have forwarded this question to the colleagues.



        • Hi Masoud,

          thanks for this answer. Unfortunately we are still on NW7.40. But it looks interesting and I think I'll have to keep it in mind for next project.



  • Hi Gregor,

    is this scenario based on a embedded gateway hub?

    If I am right, this will actually not work in a central gw-hub scenario, correct?


    Thanks for short clarification...



    • Hi Michael,

      you could use the SAP Gateway Push to bring the message to the central hub and register an ICF handler where you implement the translation to the ABAP Push Channel.

      Best regards

  • i am stoped in error msg WebSocket-dbg.js:383 WebSocket connection to 'wss://' failed: Error during WebSocket handshake: Unexpected response code: 501 ... nothing make it work!! my CloudConn is on 2.12 and i´ve created the same push channel and MC... there is any secret on the destination on SCP ?

    • Unfortunately the HTML5 runtime doesn't support Web Sockets yet. The Cloud Connector does, but you would need an additional Java App to make it pass through.

      • OK thank´s!
        Would you have any tips on how to do it with a Java APP? Could you tell me if the procedure indicated in the link below would be what you said?

    • Hi Anderson,

      Did you achieve this by creating an additional Java app on SCP?

      I guess we need to create a Socket endpoint in SCP and at the same time a WebSocket client that listens to the socket on the SAP system.

      But I still confused about how to put it all together. If you achieved by doing the same then would describe a little bit about that?


  • I can´t execute this demo, i have uploaded the code in my local eclipse, i have created the APC and AMC, like you, and i have share with my ABAP repository system, and i only have the following message: " Websocket connection closed". what is missing?, please help me.




    • Have you checked if you see any errors in the developer tools of your browser? Maybe you have not yet activated the endpoint in transaction SICF?

  • All documentation shows that APC can be 'easily' used for Fiori applications. Fiori development is done in WebIDE. And to build applications to use APC, there should be a way to integrate WSS call as easily as an oData call.

    I tried this example but in Web IDE, WSS can't be authenticated. I can pass the password in the URL but how to build actual production ready Fiori applications using this?

    • Hi Anuraag,

      as SAP Web IDE will be replaced by SAP Business Application Studio I don't think that SAP will invest in any improvements to make Web Socket Development possible in Web IDE for an on Premise System. Perhaps you try it with SAP Business Application Studio or directly in VS Code. In any case you would need to configure the @sap/approuter with the websocket property. Let us know how it goes.

      Best regards