Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
masoud_aghadavoodijolfaei
Active Participant

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.


  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.


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).



  Figure 3.1


 


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



Figure 3.2



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



Figure 3.3



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



Figure 3.4



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



Figure 3.5


 


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



Figure 3.6



Click Save (see figure 3.7).



Figure 3.7


And Activate. (see figure 3.8).



Figure 3.8


Click Continue .(see figure 3.9)..



Figure 3.9



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



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.




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.



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) 




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).



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).


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.


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.
20 Comments
Former Member
0 Kudos

Thanks for all the 3 articles :smile: Very useful!

Former Member
0 Kudos

Hi Masoud,

Really Great explanation. could you please explain how to get notifications in my own bsp page rather than a web dynnpro application.

Thanks,

Santosh.


masoud_aghadavoodijolfaei
Active Participant
0 Kudos

Hi Santosh,

unfortunately I did not have time to cantact the BSP team regarding your question. I see that you have already released the SCN blog ABAP Push Channel with BSP application explaining how to support notfictaions in BSP applications using APC & AMC. Thanks for the blog.

Masoud

Former Member
0 Kudos

HI Friends,

Is it Possible to achieve one to One Chat using this websocket Technique in WebDynPro ?

if so, pls Suggest me an Idea.

Thanks,

Siva

masoud_aghadavoodijolfaei
Active Participant
0 Kudos

Hi Siva,

with the help of the AMC  channel extension ID the group of the recipients of a message can be defined fine grained. Just have look to my response to Ekansh on Dec. 23 2014 in my blog

"ABAP Channels  Part2. Publish/Subscribe Messaging Using ABAP Messaging Channels".

Best regards,

Masoud

ChrisXu
Advisor
Advisor
0 Kudos

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.

From figure 2.1. I think the behavior is correct.

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



Thanks,

Chris Xu

masoud_aghadavoodijolfaei
Active Participant
0 Kudos

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

ChrisXu
Advisor
Advisor
0 Kudos

Hi Masoud,

Thanks for your quick response and good solution.

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

Chris.

0 Kudos

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 Kudos

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.

Former Member
0 Kudos

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

masoud_aghadavoodijolfaei
Active Participant
0 Kudos

Hi Dren,

to localize the reason of the issue I propose to follow the instructions in the note 2353453 and also double check the correctness of the application based on the Collaboration Video.

Cheers,

Masoud

Former Member
0 Kudos

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:

     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

masoud_aghadavoodijolfaei
Active Participant
0 Kudos

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

MadhuJ
Explorer
0 Kudos
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.

henning_duerholt
Explorer
0 Kudos
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

 
jasonwangcn
Participant
0 Kudos

Hi All,

Can APC AMC be used for production propose or it is still under POC phase?

 

BR Jason

masoud_aghadavoodijolfaei
Active Participant
0 Kudos
Hi Jason,

AMC & APC are already released (and in use) for productive usage since NetWeaver AS ABAP 7.40 SP8 release. Please have a look into ABAP Channels FAQ section https://blogs.sap.com/2016/10/13/faq-abap-channels/#_Toc570164251.

Cheers,

Maosud
aldo_buson
Explorer
0 Kudos
still relevant in 2022 with minor modifications
RieSe
Contributor
0 Kudos
Hmmmh, send/receive between the Teports succeeds, but not from WebDynpro to WebDynpro and not between report and WebDynpro.

Also some typos in the coding.
Labels in this area