Skip to Content

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 collaboration scenario, i.e. using ABAP Push Channel (APC) and ABAP Messaging Channel (AMC) to push messages from ABAP sessions to WebSocket clients by binding publish/subscribe channels to a WebSocket connection.

 For live demonstration and step-by-step implementation look at Collaboration Video.

 

Collaboration of ABAP Messaging and Push Channels

The collaboration scenario (see figure 2.0) provides the possibility on the basis of publish/subscribe pattern of ABAP Messaging Channels to push messages from an ABAP session or from a WebSocket client (using ABAP Push Channel) to from publisher to subscribers of channels.

/wp-content/uploads/2014/04/amc_apc_simple_v2_431677.gif

  Figure 2.0: Simple interaction model of collaboration scenario.

 

One of the goals for the collaboration scenario is to overcome the manual refresh for an object list in the user-interfaces by introducing an “auto-update” or alternatively by using a notification pattern. This goal can easily be reached by notifying the user-agent having a WebSocket connection to the ABAP system about the changes on objects displayed in the user-agent.

AMC_APC_complex.gif

Figure 2.1 illustrates the technical interaction model for pushing messages between a WebSocket

In order to pass an event from an ABAP session to a WebSocket client and vice-versa the publish/subscribe infrastructure of the ABAP Messaging Channels is used. As in the figure 2.1 depicted the APC frame with the binding manager interface offers the possibility to bind an AMC channel to the underlying WebSocket connection to act as message consumer (receiver) for the corresponding channel. After a successful binding to an AMC channel, here <application>/<channel>, any messages published to the channel will
be forwarded by the AMC broker to the WebSocket client using corresponding WebSocket connection.

Creating an ABAP Push and Messaging Channel Application for Collaboration Scenario
This section outlines the additional steps required to extend the existing APC application (see ABAP Channels Part 1: WebSocket Communication Using ABAP Push Channels [1]) and AMC application (see ABAP Channels Part 2: Publish/Subscribe Messaging Using ABAP Messaging Channels [2]) to create the collaboration scenario.

 

First, the APC application will be extended:

  • In the existing APC application YCL_APC_WS_EXT_YAPC_WS_TESTthe coding of methodON_START (Figure 2.12 in [1]) will be replaced with coding to bind the
    WebSocket connection to the AMC application
    YAMC_TESTand channel “/ping”.

 

METHOD if_apc_ws_extension~on_start.

  TRY.
* bind the WebSocket connection to the AMC channel
DATA(lo_binding) = i_context->get_binding_manager( ).
lo_binding
->bind_amc_message_consumer( i_application_id = ‘YAMC_TEST’
i_channel_id     
= ‘/ping’ ).
CATCH cx_apc_error INTO DATA(lx_apc_error).
D
ATA(lv_message) = lx_apc_error->get_text( ).
MESSAGE lx_apc_error->get_text( ) TYPE ‘E’.
ENDTRY
.

ENDMETHOD.

 

  • Same for method ON_MESSAGE (figure 2.15 in [1]). Here the received messages from WebSocket client are forwarded to the AMC application YAMC_TEST and channel “/ping”.

METHOD if_apc_ws_extension~on_message.

  DATA: lo_producer TYPE REF TO if_amc_message_producer_text.
TRY.
* retrieve the text message
DATA(lv_text) = i_message->get_text( ).
lo_producer ?= cl_amc_channel_manager
=>create_message_producer(

                                                                                                 i_application_id = ‘YAMC_TEST’
i_channel_id      
= ‘/ping’ ).
lo_producer
->send( i_message = lv_text ).
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’.
  ENDTRY
.

ENDMETHOD.

 

  • In the next step the access rights will be maintained. For the AMC application YAMC_TEST and channel “ping” the activities “Receive via APC WebSocket” and Send” are referencing the implementation class YCL_APC_WS_EXT_YAPC_WS_TEST of APC application YAPC_WS_TEST. This is done in the AMC design time, transaction SAMC (figure 3.20 in [2]).

 

Open the definition of application YAMC_TEST and click Insert line (see figure 3.1).

/wp-content/uploads/2014/04/fig_3_1_431725.jpg

  Figure 3.1

 

Open the value help in the Authorized Program field (see figure 3.2).

/wp-content/uploads/2014/04/fig_3_2_431765.jpg

Figure 3.2

Insert the class YCL_APC_WS_EXT_YAPC_WS_TESTand click Accept (see figure 3.3).

/wp-content/uploads/2014/04/fig_3_3_431766.jpg

Figure 3.3

Select the entry C Receive via APC WebSocket (see figure 3.4).

/wp-content/uploads/2014/04/fig_3_4_431767.jpg

Figure 3.4

Insert additional line as above and select the entry S Send (see figure 3.5).

/wp-content/uploads/2014/04/fig_3_5_431774.jpg

Figure 3.5

 

Optionally a Virus Scan ID (outgoing) can be specified (see figure 3.6).

/wp-content/uploads/2014/04/fig_3_6_431837.jpg

Figure 3.6

Click Save (see figure 3.7).

/wp-content/uploads/2014/04/fig_3_7_431838.jpg

Figure 3.7

And Activate. (see figure 3.8).

/wp-content/uploads/2014/04/fig_3_8a_431845.gif

Figure 3.8

Click Continue .(see figure 3.9)..

/wp-content/uploads/2014/04/fig_3_9_431852.jpg

Figure 3.9

To test the application just press the Test icon (see figure 3.10).

/wp-content/uploads/2014/04/fig_3_10_431853.jpg

Figure 3.10

This action launches the Web Dynpro application WDR_TEST_APC in a browser (see figure 3.11) 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). If it does not launch, double check the Web Dynpro service path /sap/bc/webdynpro/sap/wdr_test_apc” in the transaction SICF is active.

/wp-content/uploads/2014/04/fig_3_11_431854.jpg

Figure 3.11

 

Just starts a second time the Web Dynpro test application for APC application YAMC_TEST in browser (see figure 3.12) .After a successful connection setup any messages send in a browser will be received also by the second browser.

/wp-content/uploads/2014/04/fig_3_12_431855.jpg

Figure 3.12

Furthermore any report which apply any actions on the AMC application YAMC_TEST and channel “/ping” will be involved in the collaboration interaction. In other words the execution of the AMC send report YRS_AMC_SEND_MESSAGE (refer [2] figure 3.15) will lead to receiving the send message by the browser(see figure 3.13) 

/wp-content/uploads/2014/04/fig_3_13_431857.jpg

Figure 3.13

 

And the execution of the AMC receive report YRS_AMC_RECEIVE_MESSAGE (refer blog [2]figure 3.25) will lead to receiving the send message by the browser(see figure 3.14).

/wp-content/uploads/2014/04/fig_3_14_431864.jpg

Figure 3.14

 

 

Collaboration Scenario Security

The security of collaboration scenario is handled by the underlying APC and ac frameworks.

 

 

Collaboration Scenario Supportability

Whereas for AMC channels with the transaction SMAMC (refer blog [2] figure 4.0) canthe subscribed channels be monitored also here a navigation to the bound WebSocket connection in SMWS (see [1] ) transaction. The transaction SMWS provides also the total number of bound AMC channels per WebSocket  connection (see figure 4.0).

/wp-content/uploads/2014/04/fig_4_0_431865.jpg

Figure 4.0

 

The transaction SMAMC (see figure 4.1) shows the list of the AMC channels which are registered in sessions (Type “Session”) or in case of “Collaboration scenario” the WebSocket connections (Type is “WebSocket”) in the system as AMC consumers.

/wp-content/uploads/2014/04/fig_4_1_431866.jpg

Figure 4.1

 

 

Conclusion and outlook

This article showed the collaboration scenario based on AMC and APC for exchange of messages between different WebSocket clients. Currently the message exchange based on best/effort strategy and no guaranteed delivery is available. In a future article best practices will be outlined.

To report this post you need to login first.

16 Comments

You must be Logged on to comment or reply to a post.

  1. Chris Xu

    Hi Masoud,

    Thanks for your great post.

    I followed this blog and created a demo like yours. And I have a question now.

    You mentioned in the post that:

    Just starts a second time the Web Dynpro test application for APC application YAMC_TEST in browser (see figure 3.12) .After a successful connection setup any messages send in a browser will be received also by the second browser.

    I found that the sender browser also received the message what it sent out. Is this behavior correct? Like below. Top browser acts the sender, bottom acts the receiver.

    /wp-content/uploads/2015/05/amcapc_711531.png

    From figure 2.1. I think the behavior is correct.

    /wp-content/uploads/2015/05/amcapc_711531.png

    So my question is: will the sender always receive what it send out?



    Thanks,

    Chris Xu

    (0) 
  2. Masoud Aghadavoodi Jolfaei Post author

    Hi Chris,

    yes, the sender always receives what it sent out. In this case you can add a kind of “sender id” which is generated as UUID per Web Dynpro instance and inserted to the PCP message as a PCP field. This allows the reciupients to identify their own messages and if required to filter/skip those message (with JavaScript means).

    Best regards,

    Masoud

    (0) 
    1. Chris Xu

      Hi Masoud,

      Thanks for your quick response and good solution.

      So my understanding of the work mechanism is correct. Thank you again.

      Chris.

      (0) 
  3. Kamal el Marzgioui

    Dr. Masoud,

    Thank you for taking the time to write these 3 very elaborated and useful articles!

    I have witnessed the APC/AMC Collaboration scenario working at the Barcelona TECHED (hands-on workshop).

    It is definitely an interesting feature in ABAP and can be put to use right away.


    Regards,

    Kamal.

    (0) 
  4. Kamal el Marzgioui

    Dr. Masoud,

    Thank you for taking the time to write these 3 very elaborated and useful articles!

    I have witnessed the APC/AMC Collaboration scenario working at the Barcelona TECHED Hands-On Workshop.

    It is definitely an interesting feature in ABAP and can be put to use right away.

    Regards,

    Kamal.

    (0) 
  5. Dren Selimi

    Hello Dr.Masoud,

    I am having a problem Sending data from SAP to Web, and from Web to Web,

    Could you help me out, I have followed all the steps as described by you.

    Regards,

    Dren Selimi

    (0) 
      1. Dren Selimi

        Hi Dr.Masoud,

        I am facing another problem, I am now trying to create a TCP Socket, but I do net get all the options that I found in the official documentation for creating a TCP Socket Server in SAP, I will attach two images and you can see the differences between the documentation an what I get in my system, in the part for setting the protocol.

             My screen:

        /wp-content/uploads/2016/10/2016_10_05_16_25_46_1048698.png

             the doc screen:Creating a TCP Socket Application

        The link for the documentation

        Implementing a TCP Socket Server – ABAP Channels – SAP Library

        Do you have any idea for this problem ?

        Thanks, Dren

        (0) 
        1. Masoud Aghadavoodi Jolfaei Post author

          Hi Dren,

          it seems that your development system is not on ABAP release >= 750. The TCP Socket protocol as part of ABAP Channels infrastructure is available with ABAP release >= 750.

          Cheers,

          Masoud

          (0) 
  6. Madhusudhanarao Jyothul

    Hi Masoud,

    It is a very nice blog and very useful feature to implement the User-interface automation for some of the requirements. There are two questions

    1. There is a APC for CRM_IU_PFC is not working for testing. Is there anyway to know if all are released for customers to use or internally released.
    2. Are there any example for SAP CRM WEBUI interfacing or any special tags introduced.
    (0) 
    1. Henning Duerholt

      Hello Madhusudhanarao,

      regarding your question 2.: an example for using the ABAP channels in SAP CRM Interaction Center is described in this blog:

      regarding your first question: could you explain in more detail waht you mean by CRM_IU_PFC ?

      thanks a lot and best regards,
      Henning Dürholt

       

      (0) 

Leave a Reply