Skip to Content
Author's profile photo Masoud Aghadavoodi Jolfaei

ABAP Channels Part 1: WebSocket Communication Using ABAP Push Channels

Introduction

For introduction to ABAP Channels please refer to Introduction to ABAP Channels. For tangible examples in the system see also the blog ABAP Channels ExamplesSee also FAQ – ABAP Channels.

This blog focuses on the WebSocket integration in ABAP, also known as ABAP Push Channel (APC).

For live demonstration and step-by-step implementation take a look at ABAP Push Channel Video.

 

Integration of WebSocket into ABAP engine

In order to pass an event from the ABAP engine to an HTML5 based user agent we decided to integrate the WebSocket protocol into the ABAP engine.WebSocket provides a bi-directional communication channel over a TCP/IP socket. It is designed to be implemented in web browsers and web servers, but in general it can be used by any client or server application. The WebSocket JavaScript API is standardized by the W3C, whereas the WebSocket protocol (RFC 6455) is standardized by the IETF. The WebSocket protocol is supported by many new browsers, e.g.  Chrome 14, Firefox 7.0, IE 10 and Safari on iOS6 (and higher).

 

The implementation of the WebSocket protocol (RFC 6455) in ABAP is called ABAP Push Channel (APC).The APC communication is stateless per default, i.e. each WebSocket message leads to he creation of an individual ABAP session for execution of the respective method. After termination of the method the session will be released. In contrast to the existing request-response-based communication protocols, e.g. Remote Function Call (RFC) and HTTP(S), APC is a message-based protocol, i.e. per default the execution of a message does not lead to a response. However on top of the messaging protocols various communication patterns can be built, also a request-response-based communication. This is possible because the APC session has been implemented as a new session type..

 

It is important to have an understanding for the WebSocket events and methods before starting to explain how the WebSocket protocol has been integrated into the ABAP engine. The following simple sample code snippet shows how to use the JavaScript WebSockets interface (the essential events and methods are in bold format):

 

WebSocket JavaScript example code

   // open a WebSocket connection

     var ws = new WebSocket(“ws[s]://host.domain:port/path?query_string”);

 

     ws.onopen = function()

     {

        // WebSocket is connected, send data using send()

        ws.send(“Sending Message ….”);

        alert(“Message is sent…”);

     };

 

     ws.onmessage = function (msg)

     {

        // process received Message

        alert(msg.data);

 

        // optionally close connection
         ws.close();

     };

 

     ws.onclose = function()

     {

         // WebSocket is closed.

         alert(“Connection is closed…”);

     };

 

 

In APC framework the involved events and methods are very similar. A simple APC class handler would have the following events and methods.

In order to support WebSocket specification for subprotocols according to RFC 6455 has the APC server interface IF_APC_WS_EXTENSION been refactored and the new interface IF_APC_WSP_EXTENSION with 740 SP08 has been established.

 

APC example code (before 740 SP08)

CLASS YCL_APC_WS_EXT_YEXAMPLE IMPLEMENTATION.

 

     METHOD if_apc_ws_extension~on_start( i_context type ref to  if_apc_ws_context ).

      ” WebSocket connection has been established

     ENDMETHOD.

 

     METHOD if_apc_ws_extension~on_message( i_message type ref to  if_apc_ws_message ).

       ” Message has been received

        TRY.

         “ Echo the message on WebSocket connection

              data(lo_message_manager) = i_message->get_context( )->get_message_manager( ).

              lo_message = lo_message_manager->create_message( ).

              lo_message->set_text( i_message->get_text( ) )

 

              ” Send message

              lo_message_manager->send( lo_message ).

           CATCH cx_apc_error INTO lx_apc_error.

              …

          ENDTRY.

     ENDMETHOD.

 

     METHOD if_apc_ws_extension~on_close.

       ” WebSocket is closed

     ENDMETHOD.

 

ENDCLASS.

 

The new version of APC class handler would have the following events and methods, which also supports the Push Channel Protocol (PCP) as subprotcol.

APC example code (from 740 SP08)

CLASS YCL_APC_WSP_EXT_YEXAMPLE IMPLEMENTATION.

 

     METHOD if_apc_wsp_extension~on_start(
i_context type ref to if_apc_wsp_server_context
i_message_manager type ref to if_apc_wsp_message_manager ).

      ” WebSocket connection has been established

     ENDMETHOD.

 

     METHOD if_apc_wsp_extension~on_message(
i_message type ref to if_apc_wsp_message
i_message_manager type ref to if_apc_wsp_message_manager
i_context type ref to if_apc_wsp_server_context ).

       ” Message has been received

        TRY.

         “ Echo the message on WebSocket connection

              lo_message = i_message_manager->create_message( ).

              lo_message->set_text( i_message->get_text( ) )

 

              ” Send message

              i_message_manager->send( lo_message ).

           CATCH cx_apc_error INTO lx_apc_error.

              …

          ENDTRY.

     ENDMETHOD.

 

     METHOD if_apc_wsp_extension~on_close(
i_reason type string
i_code type type i
i_context_base type ref to if_apc_wsp_server_context_base ).

       ” WebSocket is closed

     ENDMETHOD.

 

ENDCLASS.

 

The following diagram (figure 2.0) shows the interaction model of WebSocket client, e.g. HTML5-enabled browser, and APC framework in the ABAP engine of the NetWeaver application server.

 

APC_WebSocket_Interaction.jpg

Figure 2.0: WebSocket/APC interaction model in ABAP

 

The main advantage of the integration model is based on the fact that WebSocket connections are administrated by an ICM process, i.e. the end-point of a connection is the ICM process and not the ABAP session. This design helps to reduce resource consumption during inactivity phases of WebSocket communication. Furthermore APC applications are stateless per default.This means that each received message is handled in a dedicated session. The  application can preserve its state information either in shared object areas or database tables.

 

Creating an ABAP Push Channel (APC) application

This section contains a step by step description of the creation of an ABAP Push Channel application.

 

Before starting with development of an APC application we should check the prerequisites for the WebSocket environment in ABAP. From support package 5 upwards the WebSocket configuration is active per default. The WebSocket connection uses the same ports as the maintained HTTP and HTTPS ports and there is no explicit entry for “WEBSOCKET” and “WEBSOCKETS” services in service entries of transaction SMICM. This is different in lower releases. In NetWeaver 740 support package 2 up to support package 4, the WebSocket port parameters were maintained actively. This can be done in two different ways:

    • Manually and  temporarily in the transaction SMICM (via menu entry “Goto” -> “Service” and again in menu “Service” -> “Create“) you can choose a proper port number for the field “New Service Port” , e.g. 50090 or 44390 for secure or non-secure WebSocket (WS), and then in the field Protocolenter “WEBSOCKET” (non-secure WebSocket) or “WEBSOCKETS” (secure WebSocket).
    • Alternatively, enabling ABAP to use WebSockets can be performed by setting ICM profile parameters. In the profile of the instances supporting WebSockets, some parameters must be added. Example:

icm/server_port_101 = PROT=WEBSOCKET,PORT=0,TIMEOUT=-1
icm/server_port_102 = PROT=WEBSOCKETS,PORT=0,TIMEOUT=-1

assuming that 101 and 102 are not yet used by other server_ports.

Port number is always 0. Timeout is always -1.

 

An ABAP Push Channel (APC) application can be created in two ways.

 

    • In transaction SE80 using the context menu entry (“Right-Click on top-level package object) “Create” -> “Connectivity” -> “ABAP Push Channel(see figure 2.1):

APC_CREATE_SE80.png

Figure 2.1.

 

 

    • As of release 740 SP5: In the transaction SAPC using the context menu entry (“Right-Click”) on the “ABAP Push Channel” entry and selecting “Create(see figure 2.2):APC_CREATE_SAPC.png

      Figure 2.2.

      In the next step, the name of the APC application has to be enteredand the popup screens have to be confimed (press “Enter”). In this example “YAPC_WS_TEST” is used as application name (see figure 2.3):

      /wp-content/uploads/2013/11/popup_1_311060.pngFigure 2.3.

       

       

      Also choose an appropriate package entry, in this case as “Local Object(see figure 2.4):

      /wp-content/uploads/2013/11/popup_object_catalog_311062.png

      Figure 2.4.

       

       

      Additionally, the field “Description” has to be maintained (see figure 2.5):

      /wp-content/uploads/2013/11/apc_description_311081.png

      Figure 2.5.

       

       

      Next step: save the application (see figure 2.6):

      /wp-content/uploads/2013/11/apc_application_save_311182.png

      Figure 2.6.

       

       

      Now the associated design time entities, i.e. in the transaction SICF service path /sap/bc/apc/<name space>/<application name> and the corresponding APC application class, have to be generated (see figure 2.7):

      /wp-content/uploads/2013/11/apc_application_generation_311222.png

      Figure 2.7.

       

      Confirm the generation step.

       

       

      In the next steps the basic implementation of the APC extension class will be initiated. To do so, double-click on the class name, here YCL_APC_WS_EXT_YAPC_WS_TEST (see figure 2.8):

      /wp-content/uploads/2013/11/apc_class_impl_311279.png

      Figure 2.8.

       

       

      The before-mentioned action leads to the display of the class YCL_APC_WS_EXT_YAPC_WS_TEST in the class builder environment (see figure 2.9):

      /wp-content/uploads/2013/11/se24_class_display_mode_311280.png

      Figure 2.9.

       

       

      Change the display mode to change, i.e.click “Display” <-> “Change” (see figure 2.10).

      /wp-content/uploads/2013/11/se24_class_display_change_mode_311281.png

      Figure 2.10.

       

       

      The required actions are the implementation of the methods ON_START and ON_MESSAGE. The ON_START method is executed as soon as the WebSocket connection setup phase is accomplished successfully. The ON_MESSAGE method is executed when receiving a message. As the extension class is inherited from an abstract class to implement the ON_START and ON_MESSAGE methods these methods have to be redefined. Optionally also the method ON_CLOSE and ON_ERROR can be redefined, i.e. implemented, as well. To do so, choose the respective method, i.e. ON_START, and press “Redefine” (see figure 2.11):

      /wp-content/uploads/2013/11/se24_method_on_start_redefine_311291.png

      Figure 2.11.

       

       

      In this example the only action which is processed during ON_START execution is to send a text message to the WebSocket client, after inserting the following code in the method ON_START:

       

      The example coding for 740 with support package less than SP08 is:

      METHOD if_apc_ws_extension~on_start.

        TRY.

      * send the message on WebSocket connection

            DATA(lo_message_manager) = i_context->get_message_manager( ).

            DATA(lo_message) = lo_message_manager->create_message( ).

            lo_message->set_text( |{ sy-mandt }/{ sy-uname }: ON_START has been successfully executed !| ).

            lo_message_manager->send( lo_message ).

          CATCH cx_apc_error INTO DATA(lx_apc_error).

            MESSAGE lx_apc_error->get_text( ) TYPE ‘E’.

        ENDTRY.

      ENDMETHOD.
      And the coding for 740 SP08 and later is:

      METHOD if_apc_ws_extension~on_start.

        TRY.

      * send the message on WebSocket connection

            DATA(lo_message) = i_message_manager->create_message( ).

            lo_message->set_text( |{ sy-mandt }/{ sy-uname }: ON_START has been successfully executed !| ).

            i_message_manager->send( lo_message ).

          CATCH cx_apc_error INTO DATA(lx_apc_error).

            MESSAGE lx_apc_error->get_text( ) TYPE ‘E’.

        ENDTRY.

      ENDMETHOD.

      the method contains the code below (see figure 2.12):

      ON_START_implementation.JPG

      Figure 2.12.

       

       

      Save the method (click “Save”) in the Class Builder” (see figure 2.13):

      /wp-content/uploads/2013/11/se24_method_save_311390.png

      Figure 2.13.

       

       

      and leave the method (click “Back”), see figure 2.14:

       

      /wp-content/uploads/2013/11/se24_leave_method_311401.png

      Figure 2.14.

       

      In the ON_MESSAGE method both a message text and the received message are sent to the WebSocket client, after inserting the following code in the ON_MESSAGE method:

      The example coding for 740 with support package less than SP08 is:

       

      METHOD if_apc_ws_extension~on_message.

        TRY.

      * retrieve the text message

            DATA(lv_text) = i_message->get_text( ).

       

      * create the message manager and message object

            DATA(lo_context) = i_message->get_context( ).

            DATA(lo_message_manager) = lo_context->get_message_manager( ).

            DATA(lo_message) = lo_message_manager->create_message( ).

       

      * send 1st message

            lo_message->set_text( |{ sy-mandt }/{ sy-uname }: ON_MESSAGE has been successfully executed !| ).

            lo_message_manager->send( lo_message ).

       

      * send 2nd message, i.e. echo the incoming message

            lo_message->set_text( lv_text ).

            lo_message_manager->send( lo_message ).

          CATCH cx_apc_error INTO DATA(lx_apc_error).

            MESSAGE lx_apc_error->get_text( ) TYPE ‘E’.

        ENDTRY.

      ENDMETHOD.

       

      And for 740 SP08 and later release is:

       

      METHOD if_apc_ws_extension~on_message.

        TRY.

      * retrieve the text message

            DATA(lv_text) = i_message->get_text( ).

       

      * create the message object

            DATA(lo_message) = lo_message_manager->create_message( ).

       

      * send 1st message

            lo_message->set_text( |{ sy-mandt }/{ sy-uname }: ON_MESSAGE has been successfully executed !| ).

            i_message_manager->send( lo_message ).

       

      * send 2nd message, i.e. echo the incoming message

            lo_message->set_text( lv_text ).

            i_message_manager->send( lo_message ).

          CATCH cx_apc_error INTO DATA(lx_apc_error).

            MESSAGE lx_apc_error->get_text( ) TYPE ‘E’.

        ENDTRY.

      ENDMETHOD.

       

      The method contains the code below (see figure 2.15):

      ON_MESSAGE_implementation.JPG

      Figure 2.15.

       

       

      Additionally save the method (click “Save”) in the Class Builder” (transaction SE24), see figure 2.16:

      /wp-content/uploads/2013/11/se24_method_save_311390.png

      Figure 2.16.

       

      and leave the method (click “Back”), see figure 2.17:

      :

      /wp-content/uploads/2013/11/se24_leave_method_311401.png

      Figure 2.17.

       

       

      Finally, activate the class (click “Activate”) in the “Class Builder”, see figure 2.18:

      /wp-content/uploads/2013/11/se24_class_activate_311424.png

      Figure 2.18.

       

       

      and leave the Class Builder” via Back (see figure 2.19):

      /wp-content/uploads/2013/11/se24_class_builder_leave_311425.png

      Figure 2.19.

       

       

      Optionally, you can maintain the virus/content scan IDs for incoming and outgoing messages at any time (see figure 2.20):

      virus_scan_ID.docx.png

      Figure 2.20.

       

      Now the APC application has to be activated as well, to do so press Activate /wp-content/uploads/2013/11/apc_activate_icon_311438.png (see figure 2.21):

      /wp-content/uploads/2013/11/sapc_activate_application_311426.png

      Figure 2.21.

       

      To test the application just press the Test icon/wp-content/uploads/2013/11/apc_execute_icon_311428.png (see figure 2.22):

      /wp-content/uploads/2013/11/apc_application_test_311436.png

      Figure 2.22.

       

       

      This action launches the Web Dynpro application WDR_TEST_APC in a browser (see figure 2.23) which supports the WebSocket protocol (RFC 6455) (e.g. Chrome version >= 16, Firefox version >= 11, Internet Explorer version >= 10 and Safari on iOS version >= 6). In case of any issue it should be double checked that the Web Dynpro service path “/sap/bc/webdynpro/sap/wdr_test_apc” in the transaction SICF is active.

      /wp-content/uploads/2013/11/wdr_test_apc_325615.png

      Figure 2.23.

 

 

Limitation: In the present version of APC framework is the size of WebSocket/APC messages exchanged between client and server limited to ~64 kbytes.  Furthermore the WebSocket support in Web Dispatcher is released with the version 7.41 and for installation of a new version of Web Dispatcher please refer to SAP note 908097.

 

APC Security

Each APC application has a path entry in the transaction SICF. With a new installation this entry is inactive per default. For an active usage of an APC application the associated APC path in SICF transaction has to be activated before. The path to an APC application is /sap/bc/apc/<name space>/<application name>. For each APC application you can maintain a dedicated virus/content scan ID for outgoing and incoming messages. Furthermore we recommend to use the existing escape methods in ABAP, e.g. the ESCAPE statement, to escape the WebSocket content that is exchanged between client and server. Finally we highly recommend to use the secure varaint of WebSocket, i.e. wss instead of ws, for the communication.

 

For cross-origin-access to an APC application the APC framework also supports some aspects of the “The Web Origin Concept”, i.e. RFC 6454. In order to allow the access to APC application from an external server the white list maintenance via transaction SAPC_CROSS_ORIGIN has to be done accordingly.

 

 

APC Supportability

WIth external breakpoints you can debug the execution of the ON_START, ON_MESSAGE, ON_CLOSE and ON_ERROR methods similarily to HTTP handler i.e. by setting breakpoints in the respective methods.

 

In transaction SAPC you can activate/deactivate the following supportability tools for a specific APC application:

be initiated:

 

  • Debugging: choose menu bar the entry “Utilities” -> “Debugging” -> “Activate Debugging“/Deactivate Debugging
  • Runtime Analysis: choose menu bar the entry Utilities” -> “Runtime Analysis” -> “Activate“/Deactivate
  • Kernel Trace: choose menu bar the entry Utilities” -> “Trace” -> “Reset Trace“/”Display Trace/”Activate Trace“/“Deactivate Trace

 

The  runtime analysis records which start with the prefix “APC:<application path>”, e.g. “APC:/sap/bc/apc/sap/ping” for a PING application, can be monitored in transaction SAT.

 

Furthermore, transaction SMWS shows the list of active WebSocket connections and their associated APC application on each application server.

 

 

Conclusion and outlook

As you can see from the lines above, the ABAP Push Channel provides the infrastructure for WebSocket communication in ABAP. The present implementation of APC supports only the server side of communication based on stateless sessions, i.e. stateless APC communication similar to stateless HTTP communication. A stateful APC communication and also an APC client library are under development.

 

The next related blog to ABAP Channels is ABAP Messaging Channel (AMC). AMC blog describes the eventing framework for messages exchange between different ABAP sessions based on publish/subscribe channels.

 

Assigned Tags

      63 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Hey Masoud,

       

      Very useful feature. Congrats to your team for building this into ABAP stack. I am exited by its possibilities.

       

      I am building SAP UI5 applications based on NW Gateway services. One of the very required feature is pessimistic resource locking. Example: If I am editing a purchase order in UI5 app, no other user using UI5 app should be able to change it.

       

      This is my thought process after reading your blog.

      Within my UI5 application, as soon as someone enters into change mode, I would create a websocket connection for that client (UI5 library provides an API) and send the resource id (say PO number). In the server side I would make an entry in a Z table (with a generated GUID connection ID and PO number) and give back a success message to the client. If the Z table already has an entry for that PO, then the server would refuse the lock and push a suitable message. Whenever the user closes the browser/tab, I suppose that the websocket connection would end, and in the on_close method, I would remove the entry from the Z table. If the user is inactive for more than 10 mins, I would end the websocket connection in the client javascript.

       

      As I understand Z Table would not be required in a stateful websocket, since that should allow me to make use of SAP Lock objects.

       

      How does this sound?

       

      Please let me know your comments about this approach.

       

      Thanks

      Krishna

      Author's profile photo Samson Dass
      Samson Dass

      Hi Krishna,

      We too have similar requirements for Pessimistic Locking. Please share your insights of how you were able to achieve this solution. Also find below some data points for your consideration.

      • All the objects are Z-Objects so no locking is expected from anywhere else, apart from UI5 browser.
      • APC/AMC supported in our current package
      • What would happen if user simply closes his system or there is a timeout? Can web sockets address these cases?

      I was planning to use your above suggested approach for locking.

      Regards,

      Samson

       

      Author's profile photo Venkat dattatreya
      Venkat dattatreya

      Hello Krishna,

      I have done the same requirement for Master detail  custom UI5 application. it is working like a charm.

       

      CLASS zcl_apc_wsp_ext_z802_apc DEFINITION
      PUBLIC
      INHERITING FROM cl_apc_wsp_ext_stateful_base
      FINAL
      CREATE PUBLIC .

      PUBLIC SECTION.

      DATA lock TYPE string .

      METHODS if_apc_wsp_extension~on_close
      REDEFINITION .
      METHODS if_apc_wsp_extension~on_message
      REDEFINITION .
      METHODS if_apc_wsp_extension~on_start
      REDEFINITION .
      PROTECTED SECTION.
      PRIVATE SECTION.
      ENDCLASS.

      CLASS ZCL_APC_WSP_EXT_Z802_APC IMPLEMENTATION.

      * <SIGNATURE>---------------------------------------------------------------------------------------+
      * | Instance Public Method ZCL_APC_WSP_EXT_Z802_APC->IF_APC_WSP_EXTENSION~ON_CLOSE
      * +-------------------------------------------------------------------------------------------------+
      * | [--->] I_REASON                       TYPE        STRING
      * | [--->] I_CODE                         TYPE        I
      * | [--->] I_CONTEXT_BASE                 TYPE REF TO IF_APC_WSP_SERVER_CONTEXT_BASE
      * +--------------------------------------------------------------------------------------</SIGNATURE>
      METHOD if_apc_wsp_extension~on_close.

      ENDMETHOD.

      * <SIGNATURE>---------------------------------------------------------------------------------------+
      * | Instance Public Method ZCL_APC_WSP_EXT_Z802_APC->IF_APC_WSP_EXTENSION~ON_MESSAGE
      * +-------------------------------------------------------------------------------------------------+
      * | [--->] I_MESSAGE                      TYPE REF TO IF_APC_WSP_MESSAGE
      * | [--->] I_MESSAGE_MANAGER              TYPE REF TO IF_APC_WSP_MESSAGE_MANAGER
      * | [--->] I_CONTEXT                      TYPE REF TO IF_APC_WSP_SERVER_CONTEXT
      * +--------------------------------------------------------------------------------------</SIGNATURE>
      METHOD if_apc_wsp_extension~on_message.

      TRY.

      * retrieve the text message
      DATA(lo_messagei_message_manager->create_message).
      DATA(lv_texti_message->get_text).
      SPLIT lv_text AT space INTO DATA(lvDATA(lv1).
      DATAaufnr TYPE aufnr.
      aufnr |{ lv ALPHA IN }|.

      IF lv1 'ENQUEUE' AND me->lock IS INITIAL.

      CALL FUNCTION 'ENQUEUE_ESORDER'
      EXPORTING
      mode_aufk      'E'
      mandt          sy-mandt
      aufnr          aufnr
      x_aufnr        ' '
      _scope         '2'
      _wait          ' '
      _collect       ' '
      EXCEPTIONS
      foreign_lock   1
      system_failure 2
      OTHERS         3.
      IF sy-subrc <> 0.
      IF sy-subrc 1.

      lv_text |Already someone using the same Production Order { aufnr ALPHA out }|.
      ENDIF.
      ELSEIF sy-subrc 0.
      lv_text |Production Order { aufnr ALPHA out } is locked successfully|.
      me->lock aufnr.
      ENDIF.
      ELSEIF me->lock IS NOT INITIAL.
      CALL FUNCTION 'DEQUEUE_ESORDER'
      EXPORTING
      mode_aufk 'E'
      mandt     sy-mandt
      aufnr     aufnr
      x_aufnr   ' '
      _scope    '3'
      _synchron ' '
      _collect  ' '.

      IF sy-subrc 0.
      lv_text |Dequeue of Production Order { aufnr ALPHA out } is successful|.

      me->lock ''.

      ENDIF.

      ENDIF.

      lo_message->set_textlv_text ).

      i_message_manager->sendlo_message ).

      CATCH cx_apc_error INTO DATA(lx_apc_error).
      lo_message->set_textlx_apc_error->get_text).

      i_message_manager->sendlo_message ).

      *        MESSAGE lx_apc_error->get_text( ) TYPE 'E'.

      ENDTRY.
      ENDMETHOD.

      * <SIGNATURE>---------------------------------------------------------------------------------------+
      * | Instance Public Method ZCL_APC_WSP_EXT_Z802_APC->IF_APC_WSP_EXTENSION~ON_START
      * +-------------------------------------------------------------------------------------------------+
      * | [--->] I_CONTEXT                      TYPE REF TO IF_APC_WSP_SERVER_CONTEXT
      * | [--->] I_MESSAGE_MANAGER              TYPE REF TO IF_APC_WSP_MESSAGE_MANAGER
      * +--------------------------------------------------------------------------------------</SIGNATURE>
      METHOD if_apc_wsp_extension~on_start.

      TRY.

      DATA(lo_messagei_message_manager->create_message).

      lo_message->set_text|{ sy-mandt }/{ sy-uname }Websocket connection has been successfully executed !| ).

      i_message_manager->sendlo_message ).

      CATCH cx_apc_error INTO DATA(lx_apc_error).
      lo_message->set_text(  lx_apc_error->get_text).
      i_message_manager->sendlo_message ).

      ENDTRY.

      TRY.
      DATA(lo_bindingi_context->get_binding_manager).
      lo_binding->bind_amc_message_consumer(
      i_application_id = <AMC ID>
      i_channel_id '/prodorder' ).
      CATCH cx_apc_error INTO DATA(lx_error).
      lo_message->set_text(  lx_apc_error->get_text).
      i_message_manager->sendlo_message ).

      *        DATA(lv_message) = lx_error->get_text( ).
      ENDTRY.
      ENDMETHOD.
      ENDCLASS.

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Krishna,

      your proposal sounds good as far as those lock entities, e.g. purchages orders, are not accessed by other classical transactions, e.g. from within SAPGUI or RFC, using ABAP enqueue based locks. In that case the enqueue locks and your custom table for recording of locks are not anymore in sync and this could lead to side effects, e.g. accessing the order though the order is already marked as locked in the Z* table .

       

      Best regards,

      Masoud

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Thanks Masoud for your insight.

      Author's profile photo Former Member
      Former Member

      Hi Masoud,

       

      Thanks for this blog.

        I have also implement same web socket in gateway service. When I am calling from    browser it's calling Accept method then immediately it's calling close method.

       

        how I will handle  close method . it should call on only when user  explicitly call  close or browser close 

            

      Thank.

      Author's profile photo Shadab Shafiq
      Shadab Shafiq

      HI Masoud,

       

      I was trying your example. The part of send/receive works perfectly. But now I wanted to experiment further based on what you have written about "exchange of messages between either user sessions". I first tried to run two instances of same application and in parallel browser windows and was trying to send message hoping it should also be received in the other window. But this does not work. I also ceated a simple html page using the websocket URL just created, but this also works in its own context it only listens and transmits its own message.

       

      Would the class need to be enhanced further. I tried this on Basis 740 SP-Level 0000.

       

      Warm Regards

       

      Shadab Shafiq

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Shadab,

      this blog is one of the up-coming 3-4 articles around ABAP Channel capabilities. As I mentioned in the introduction:

      ...

      The ABAP channels supports the following use-cases:

      1. 1. ABAP Push Channel (APC): The WebSocket integration in ABAP.
      2. 2. ABAP Messaging Channel (AMC): Eventing framework for messages exchange between different ABAP sessions based on publish/subscribe channels.
      3. 3. Collaboration scenario: Using APC and AMC to push messages from ABAP sessions to WebSocket clients by binding publish/subscribe channels to the WebSocket connection.

       

      In this article we focus on the WebSocket framework in ABAP called ABAP Push Channel.

      ...

      Well I am writing at the moment a blog about ABAP Messaging Channel (AMC) and additionally I will spend time for the collaboration article which will contain the information you are looking for. But in the mean time you can have a look into one of my example in the system.  Just execute the APC test application "http(s)://<host>:<port>/sap/bc/apc_test/ping" in Chrome/Firefox browser, preferably in several browser windows. Before executing the URL you have to activate the paths "/sap/bc/apc_test/ping" and "/sap/bc/apc/sap/ping" in the transaction SICF. The proposed URL executes the APC application "PING" (look into the html source code)  which itself take use of AMC application APC_SIMPLE_TEST to exchange of messages between different WebSocket connections. You may debug the ON_START and ON_MESSAGE methods of the APC application "PING" during execution of the URL.


      Best regards,

      Masoud

      Author's profile photo Shadab Shafiq
      Shadab Shafiq

      Hi Masoud,

       

      Thanks.

       

      Please update this article with followup link to your new articles. Really looking forward to it.

       

      Warm Regards

       

      Shadab

      Author's profile photo Vikas Lamba
      Vikas Lamba

      Hi Masoud,

       

      Excellent blog. Thanks for sharing.

       

      I was trying what you did and have a question now. I see that all the test client examples are using a Web Dynpro application which is of course hosted in the same NW server and have no security issue communicating.

       

      I tried to write a JS page to make a client and then realized that JS WS API does not provide any way to pass authorization information to server. So I was getting HTTP 401 instead of a WS upgrade.

       

      Can you share some light on how can I use a JS client to open a WS connection with ABAP and does it need any additional configurations on server to enable this. I Have NW 7.4 SP06 installed.

       

      Cheers,

      Vikas

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Vikas,

      you can pass the logon data (just for testing) as cgi form parameters, i.e. sap-client=<client number>&sap-user=<username>&sap-password=<password>. If the JS WS client page does not reside on the same ABAP system, then you have to maintain the cross origin access white list accordingly (refer to cross-origin-access in APC security section). Each WS access rejection due to cross  origin access  is reported in ABAP log, i.e.transaction SM21 on the respective application server.

      Alternatively you  can create the JS WS client in ABAP system and this either as a BSP application or as a free style HTTP handler (just have look into the SICF handler maintained for the path /sap/bc/apc_test/ping (also have a look to my reply to Shadab).

      Best regards,

      Masoud

      Author's profile photo Horst Keller
      Horst Keller

      Can you share some light on how can I use a JS client to open a WS connection with ABAP

      In my blog ABAP News for Release 7.40 - WebSocket Communication with ABAP Channels I show an example, where I drilled down the web client that communicates with ABAP to the absolute minimum - no BSP, no WDY, only a slim JS. Maybe that's what your looking for or is it already too primitive? B.T.W. if you are on NW 7.4 SP06, you find that example ready for execution as program DEMO_APC in the ABAP Example Library (see APC-Example).

       

      Best

       

      Horst

      Author's profile photo Vikas Lamba
      Vikas Lamba

      Hi Horst,

       

      Thanks for the example. I was already able to get this working.

       

      But just to describe my goal I was trying to use WS connections to achieve a real time push to browser based applications on mobile phones (iOS).

       

      I hit a dead end when I realized that iOS terminates all WS connections originating from a mobile device when the app goes to background.

       

      Is there any solution that you are aware of for this problem?

       

      Regards,

      Vikas

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Vikas,

      the only workaround I am aware of is that you try to establish the WebSocket connection in WeSocket onclose event again (in order to overcome an endless loop just limit the number of trials). This event is processed as soon as the application gets activated again. This will help to reload the content through WebSocket connection.

       

      A real event-driven push can be achieved with the push platforms, e.g. SAP/Sybase Unwired Platform (SUP) which also take use of apple push notification service in case of iOS to notify/awake the application.

       

       

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi, Vikas

      We also run into the similar issue as you.

      We are making some web application deployed in public internet. And it is confused that how to let the ERP system in internal network to authenticate the connection from outside.

      Do you use the wss URL like

      wss://ldai3ebj.wdf.sap.corp:44315/sap/bc/apc/sap/zhar_apc_center?sap-client=<client number>&sap-user=<username>&sap-password=<password>? Do you encode the password in BASE64?

      And do you make other configuration in ERP system except the cross-domain config?

       

      Author's profile photo Michael Stürmer
      Michael Stürmer

      Hi Masoud,


      while experimenting, I wanted to do some connection-specific cleanup in the ON_CLOSE-method and ended up enhancing CL_APC_MANAGER=>DISPATCH to get to the initial request. Is there any official way to access the initial request from within ON_CLOSE?


      Also, I noticed some WebSocket-related (but unfortunately not released) notes in the web dispatcher patch documentation. Do you know if/when there'll be official support for WebSockets in web dispatcher?


      Thanks,

      Michael

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Michael,

      ON_CLOSE/ON_ERROR handling of APC has been enhanced with NW 740 SP08 release. In the 740 SP08 release contains ON_CLOSE/ON_ERROR method the initial request interface parameter as well. The solution to establish WebSocket context information for a WebSocket connection is to identify the WebSocket connection id, which is stable for the whole life time of the connection. The connection is then used as key to temporarily persist the context information on the backend, either by using a (buffered) database table or shared objects areas. Usually you would establish the context information for the WebSocket connection, i.e. APC application context, either in ON_START or in ON_MESSAGE method. And the cleanup should take place in ON_CLOSE method.

      By the way we do not guarantee that the ON_CLOSE method will be executed under all circumstances, as there are worst-case scenarios which this hinder us to execute any ABAP coding.

       

      For the identification of the WebSocket connection id following steps has to be applied:

      1. For NW 740 SP05 release (for correct extended passport (EPP) handling for WebSocket) please apply the kernel patch level 35, i.e. download from service.sap.com/swdc => Browse our Download Catalog => Additional Components => SAP Kernel
      2. Use follwoing ABAP coding in ON_START/ON_MESSAGE or ON_CLOSE methods to retrieve the connection id out of EPP:

             DATA: lv_connection_id TYPE epp_root_context_id.

             TRY.

                DATA(lo_epp_global) = cl_epp_global_factory=>get_section( ).

               lv_connection_id         = lo_epp_global->get_root_context_id_as_uuid( ).

             CATCH cx_epp_error INTO DATA(lx_epp_error).

                " bad luck/should not happen !!!

             ENDTRY.

       

      Web Dispatcher supports WebSocket out of the box without any additional configuration since 7.40 patch level 15 and with 7.41 patch level 0.


      Enjoy the ABAP Channels,

      Masoud

      Author's profile photo Daniel Rothmund
      Daniel Rothmund

      Hi ,

       

      what are the correct settings to use the APC with an SAP WebDispatcher infront ?

      I doesn't find anything about it at help.sap.com

       

      Regards

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Daniel,

      Web Dispatcher supports WebSocket out of the box without any additional configuration since 7.40 patch level 15 and with 7.41 patch level 0.

      Kind regards,

      Masoud

      Author's profile photo Daniel Rothmund
      Daniel Rothmund

      thx now it works

      Author's profile photo Sergiu Popa
      Sergiu Popa

      Hi Masoud,

       

      First of all thank you for writing this blog! I find it very useful as well as the technology it relates about.

       

      Now to get to the point of this question, I would like to use APC in some applications, but I have a few concerns regarding limitations in terms concurrent connections to an APC. Is there any hard-coded restriction in terms of the number of concurrent connections to an APC?

       

      Best regards,

      Sergiu

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Sergiu,

      the limitation based on the application server/ICM/WebDispatcher profile parameter configurations. In our lab tests with the respective server we reached 20000 parallel WebSocket connections, which in certain cases led to memory issues in backend. The respective profile parameter for ICM/WebDispatcher are:

      rdisp/max_websocket_connections=20000

      icm/max_conn=20000

       

      Best regards,

      Masoud

      Author's profile photo SANOOP P S
      SANOOP P S

      Can ABAP Push Channel framework be configured in SAP Netweaver 7.30 ?

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi,

      this feature is only available in AS ABAP 740 releases.

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi Masoud,

       

      Really nice Blogs. I really appreciate the time you have put in to show make it available for SDn users. I was experimeting a bit around this to get rid of the notification service used in my WD application. So right now I have a WD application with a HTMLISLAND and have a JavaScript added into it as a Mime Object. I am creating a Websocket object within my JS function. What I am trying to do is to pass a value from my actual WD application to the JS function and from JS function I am trying to pass on the value to the APC~ON_START method. The first part seems to be easy enough. But I am finding it difficult to pass any value to the ON_START method. I did checked the Websocket API but I didnt find anything useful for my purpose.

       

      I would really appreciate if you could put some inputs here.

       

      Regards,

      Manish

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Manish,

      you can pass any name-value pairs as part of the WebSocket URL (and query string) to the APC application, such as wss://host:port/sap/bc/apc/sap/<myapplication>?name1=value1&name2=value2. In the APC application <myapplication> in ON_START or ON_MESSAGE the parameters can be accessed via context interface IF_APC_WS_CONTEXT and as follow:

       

      METHOD if_apc_ws_extension~on_start.

      DATA: lo_binding    TYPE REF TO if_apc_ws_binding_manager.

      DATA: lo_request    TYPE REF TO if_apc_ws_initial_request.

      DATA: lx_apc_error TYPE REF TO cx_apc_error.

      DATA: lt_fields        TYPE tihttpnvp.

      DATA: lv_value        TYPE string.

      DATA:

         TRY.

             lo_binding = i_context->get_binding_manager( ).

             lo_request = i_context->get_initial_request( ).


      "determine cgi parameters aka form fields

             lo_request->get_form_fields( CHANGING c_fields = lt_fields ).

             lv_value  = lo_request->get_form_field( 'name1' ).


           CATCH cx_apc_error INTO lx_apc_error.

             data(lv_message) = lx_apc_error->get_text( ).

             MESSAGE lv_message TYPE 'E'.

         ENDTRY.

      ENDMETHOD.


      Just check out in your development system the ON_START & ON:MESSAGE methods of the APC application ECHO in the SAPC transaction as example


      Cheers,

      Masoud

      Author's profile photo Klaus Keller
      Klaus Keller

      Hi Manish,

       

      To pass values from Web Dynpro to the HTMLIsland (JavaScript), you'll need to add a script call. See the HTMLIsland Developer Guideline for examples on how to do this: http://scn.sap.com/docs/DOC-34098

       

       

      Regards,

      Klaus

      Author's profile photo Former Member
      Former Member

      Hello,

       

      I have created mu APC just as described in this document.

      However when I want to 'Test' my APC from Tx SE80, I get the error 'Function not yet implemented'

      Any ideas what can be the problem ?

       

      Regards,

       

      Erwin

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Erwin,

      we couldn't reproduce the issue in different ABAP Application Server support packages (SP) >= SP5. If you still observe the issue and not able to identify the reason please create a CSN ticket for the component BC-MID-AC and provide the affected system release (ABAP Application Server support package ??).

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hello,

       

      Our system is currently SP2

      Do we need SP5 before we can use the Abap Push Channel ?

      Because I was able to create the pushchannel fine.

      He generated the class and service.

      The service I needed to activate manually in SICF

       

      Best regards,

       

      Erwin

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Erwin,

      we have released the "basic functionality" for the ABAP Channels with SP5. I personally recommend - if/as soon as possible - to use at least SP8. As with the SP8 we have established additional capabilities for the ABAP Push Channel (see the CSN note 2105389).

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Thank you. this really helped..

      Author's profile photo Former Member
      Former Member

      Hi Masoud Aghadavoodi Jolfaei,

      Thanks for Sharing The Knowledge.  and i have one Doubt in my Development.

       

      is it Posible To Pass any parameter from Back end and Retrieve it in WD Componet??

       

      If it so, how to Achieve it??

       

      Pls Help me.

       

      Thanks in Advance.

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Siva anand,

      I do not understand the (end to end) use case. If you like to push messages/parameters from an ABAP session to another one (WD component), wheres the target session is a stateful session (here Web Dynpro session), in this case the ABAP Messaging Channels provide the necessary infrastructure. Alternatively using the ABAP Channels collaboration scenario you can push messages/parameters from an ABAP session to your Web Dynpro UI (HTML island) running in browser and additionally forward it to your Web Dynpro session/component. 

      I also recommend to you to place the Web Dynpro related subjects in the Web Dynpro discussion room.

      Best regards,

      Masoud

      Author's profile photo Nitesh Jain
      Nitesh Jain

      Hi Masoud,

       

      Thanks for the wonderful blog series.

       

      I built a UI5 application using websockets and I integrated this application into our SAP Enterprise Portal. When the UI5 application is executed from the portal the websocket connection with the backend was getting established successfully. We tried this from multiple PCs and it worked.

       

      Next we modified the application, redeployed it in the backend and re-run the application from the portal and am facing the following issues:

      a. The websocket connection is NOT getting established and I am getting the error 'Error during websocket handshake: unexpected response code: 403'.

      b. Then i tried executing the application from another PC and in this case the websocket connection is getting established however the modifications made to the application are not getting reflected.

       

      Then I tried executing the UI5 application directly from the browser and in this case it worked correctly.

       

      Would appreciate you help in trying to resolve the issues I am getting when executing the UI5 application from the portal.

       

      Server versions: Portal: SAP EP 7.4, Backend ECC - ECC6 EHP7 SP06

       

      regards

      Nitesh

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Nitesh,

      the response code 403 is usually processed because of a cross origin access issue (see also the section APC Security of my blog). You will find in the system log of the corresponding ABAP application server, i.e. in the transaction SM21, further information to the APC issues. I also recommend  to read the SAP note "2123214 - Error handling for ABAP Channels using SYSLOG entries" any apply the necessary cross-origin configuration in the affected system.

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi Masoud,

       

      Thanks for your contribution. It really helps. Right now I'm developing an UI5 application with ABAP push channel and the APC works fine when test with WebDynpro WDR_TEST_APC. But I'm stuck when I try to integrate it with UI5. Here is my JS codeCapture3.PNG

      And I configured the proxy in neo-app.json so that it can redirect request.

      {

            "path": "/sap/bc/apc",

            "target": {

              "type": "destination",

              "name": "ER9CLNT001",

              "entryPath": "/sap/bc/apc"

            },

            "description": "ER9 client 001"

          }

       

      But the app ends with an error when running in Chrome.

      WebSocket connection to 'wss://webidetesting3973187-fiori.dispatcher.neo.ondemand.com/sap/bc/apc/sap/zqchart_ws' failed: HTTP Authentication failed; no valid credentials available.

       

      And the error changed to Firefox can't establish a connection to the server at wss://webidetesting3973187-fiori.dispatcher.neo.ondemand.com/sap/bc/apc/sap/zqchart_ws. when running in Firefox. Do you have any idea about this issue?

       

      Best Regards,

      Kevin Zhang

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Kevin,

      I assume you are using WebIDE to develop your UI5/Fiori application in HCP. If so up to now the cloud connector and Helium and its destination service (in HCP) does not support  any WebSocket communication. Here you have to setup the connection directly to the ABAP backend system.

      Cheers,

      Masoud

      Author's profile photo Kenneth Moore
      Kenneth Moore

      Hello Masoud,

       

      When I test the Push Channel it does not connect.  I push the connect button, but nothing happens and there is no message.  Any ideas?

       

      Thanks,

       

      Kenneth

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Kenneth,

      in Chrome browser you usually find in the developer tools (F12) -> Network -> WS log entries regarding the connection setup issues.

      Cheers,

      Masoud

      Author's profile photo Kenneth Moore
      Kenneth Moore

      Hi Masoud,

       

      There are no log entries.

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Kenneth,

      this is very strange. This means somehow that the browser has problems to process the WS(S) command. Here you have to analyze/debug the JavaScript page in Chrome.

      Cheers,

      Masoud

      Author's profile photo Daniel Rothmund
      Daniel Rothmund

      Hello Masoud,

       

      ist it possible to have fixed user for a wss  connection ?

      I tried to add a service user to sicf but I get an 403 from icm.

       

      Regards

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Daniel,

      sure, in that case you have to choose in the respective (external) SICF service and in the tab "Logon Data" as "Procedure" the option "Required with Logon Data". By the way the response code 403 arises (I assume) since the cross origin policy check of APC failes. Here you have to apply the SAP note "2123214 - Error handling for ABAP Channels using SYSLOG entries" .

      Cheers

      Masoud

      Author's profile photo Daniel Rothmund
      Daniel Rothmund

      Thx Masoud ,

       

      the problem was the cross origin policy !

      And also thanks for the hint with the note. I did not know "RS_AC_READ_SYSLOG".

       

      BR

       

      Daniel

      Author's profile photo Paul Hardy
      Paul Hardy

      Dear All,

       

      In the above comments I have seen several people attempting to add code to a UI5 application in order to initiate a web socket connection and then send a message from a UI5 application to SAP.

       

      As this works with the test tool in transaction SAPC it must be possible, but no-one here at least seems to be able to get this to work.

       

      Has anyone in fact managed to write some code in any part of a UI5 application - be it XML or JS - that manages to establish a connection and then send a message from the UI5 front end to the SAP back end?

       

      Cheersy Cheers

       

      Paul

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Paul,

      I have recently released a new blog called ABAP Channels Examples. One of my intention for this blog was to provide several "simple use cases" for the ABAP Channels developer, including the involved ABAP and UI coding in the system. So I recommend to you to look at the Sohbat Slider example which from UI perspective consists of a single BSP/Fiori (/sap/bc/bsp/sap/sohbat_slider) application.

      Cheers,

      Masoud

      Author's profile photo Dren Selimi
      Dren Selimi

      Hello Masoud,

      I am having trouble receiving a message from javascript in the method ON_MESSAGE, for example, using the code on javascript that you provided above I can connect to the WebSocket and I can see that if I use a break-point in the ON_START method in SAP, but the part for " ws.send("hello);"  " won't trigger ON_MESSAGE, is that what should happen, or I have got it wrong, I that is what should happen why doesn't happen, where do you think is my problem ?

      Thanks, Dren

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Dren,

      sorry for the late response. Please have a look into the FAQ – ABAP Channels.and also note 2353453.

      Cheers,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi Masoud,

       

      I'm getting a 501 (Not Implemented) error when trying to connect to the WS. What could be causing this, and how could I go about debugging?

       

      Thanks,
      Kyle

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Kyle,

      sorry for late response. I assume there is something wrong with the creation of you application. Just refer to the FAQ – ABAP Channels, and the related question “My APC WebSocket connection to the ABAP application server does not work. Are there known pitfalls? What are the first steps for troubleshooting?".

      Good luck!

      Masoud

      Author's profile photo Serdar Simsekler
      Serdar Simsekler

      Hello Masoud

      Thanks for the blog series. Can I ask how we can have the ABAP side send messages directly to the e.g. UI5 application through the defined APC without AMC?

      So, a running ABAP session decides to send a message to any/all frontend applications hooked on the defined APC, i.e. established connection to the APC service, and just sends it without an incoming message from the frontend applications.

      Thanks

      Serdar

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Serdar,

      sorry for the late response. From ABAP Server release >= 7.50 we have established the concept of system-wide access or attach handle to be able to push data from a session to an existing WebSocket connection. For this please refer to teh documentation and examples available here.

      Cheers,

      Masoud

       

      Author's profile photo manish sethia
      manish sethia

      Hello Masoud,

      If I call a BAPI inside the method on_message and that BAPI internally calls a function module which raises an error message then the session ends abruptly. In normal report programs or classes, that is not the case and standalone BAPI is also executed successfully.

      Is it normal behavior in case of APC?

       

      Thanks,

      Manish

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Manish,

      if you are using an APC stateless application, then this behavior should not happen, abstractly speaking. It could be that the BAPI runtime checks some session type specific context information which are not available in an APC session. That is, if you run a BAPI from withing a SAPGUI and thus SAPGUI session in SE38 or SE24 in this case the SAPGUI session has GUI (interaction) capability which is not given in an APC session. What is the error text of the raised message ? I would propose to debug both situation, i.e. good and bad case and check what causes the error.

      Cheers,

      Masoud

      Author's profile photo manish sethia
      manish sethia

      Hello Masoud,

      Thanks for the reply.

      I am trying to use ‘BAPI_PR_CREATE’ to create purchase requisition. I suspect that it is the same as you suggested.

      In the above screenshot, it raises an error at line 33 and session ends here itself abruptly.

      When I call the same BAPI via a report program, the error is still raised but program continues.

       

      Do you have any idea how this can be avoided?

       

      Thanks,

      Manish

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei
      Blog Post Author

      Hi Manish,

      the E/A/X message handling in ABAP is context dependent, i.e. E message handling in  SAPGUI ia SE38, is different then in a Batch Input or an RFC or APC session. For a detail analysis of the reported issue you have to open/create a customer message@SAP for the responsible component, e.g. purchase requisition. A workaround, which might help, without knowing the end to end scenario, is the execution of the BAPI not locally in APC session but as a synchronous RFC out of APC session via CALL FUNCTION  ‘BAPI_PR_CREATE’ DESTINATION 'NONE'.

      Good luck !

      Masoud

      Author's profile photo manish sethia
      manish sethia

      Dear Masoud,

       

      Thanks for your help. I tried with the suggested approach and it worked like a charm. I'll raise an SAP note for the message part in APC.

       

      Thanks again for your quick inputs.

       

      Regards,

      Manish

       

      Author's profile photo Miroslav Dano
      Miroslav Dano

      Dear Masoud,

       

      Thank you very much, your blog helped me a lot to understand and to implement.

       

      Best Regards

       

      Miroslav Dano

      Author's profile photo Abdul Kadir
      Abdul Kadir

      Hi Masoud,

      My system landscape is ECC and GATEWAY system separate.

      I have created APC in ECC system but my UI5 application is calling gateway system.  I am trying to trigger the same APC in ECC system with the same hostname and its not working.

      Do you have any solution for this?

      Thanks

      Abdul

      Author's profile photo Anupama P
      Anupama P

      Hi ,

      Is it possible to transfer Excel data(like messages stored in Excel sheet) from Client to server using ABAP Push channels?

       

      Thanks and Regards

      Anupama

      Author's profile photo DEEPTHI B
      DEEPTHI B

      Thank you Masoud for detailed blog.

      We are trying to connect to NON SAP system thru ABAP Channel . Able to test the ABAP channel from web  .Non SAP system added ABAP channel  wss URL in their application but they are unable to receive any message from SAP.

      Before calling Abap push channel do we need to establish connectivity with Non SAP system? If so how should that be done.

       

      Thanks & Regards

      Deepthi

       

      Author's profile photo zakaria aissari
      zakaria aissari

      hello everyone im beginner on abap / sap developer i have a subject and i need some help to

      understand and which document i have to consult for establish that subject  << migration of WS

      (WebServices) STS to ABAP channels >>

      and thank you !