Skip to Content
Author's profile photo Olga Dolinskaja

How to implement and use ABAP Channels – Video Tutorials

The ABAP Channels infrastructure offers best support for native event-driven interactive and collaborative scenarios in ABAP and is generally available with ABAP 7.40 Support Package 5 (SP05). The ABAP 7.40 Support Package 8 (SP08) contains various enhancements including API refactoring to support WebSocket subprotocols.and message exchange with SAP Push Channel Protocol (PCP).

 

Take your time to watch these YouTube video tutorials to learn how to implement and use ABAP Channels.

 

See also the blog ABAP Channels Examples.

 

How to implement ABAP Push Channel (APC)
ABAP Push Channel enables bi-directional communication via WebSockets in ABAP. This video gives you step-by-step introduction on how to implement and use ABAP Push Channel.

 

 

 

How to implement ABAP Messaging Channel (AMC)
ABAP Messaging Channel enables event-driven communication based on publish/subscribe mechanism for message exchange between different ABAP sessions which can reside on different ABAP Servers. Any ABAP session can subscribe to channels and any ABAP session can publish messages to channels. This video gives you step-by-step introduction on how to implement and use ABAP Messaging Channel.

 

 

How to implement collaboration using ABAP Push Channel (APC) and ABAP Messaging Channel (AMC)

 

The collaboration scenario provides the possibility on the basis of publish/subscribe mechanism of ABAP Messaging Channels and WebSocket implementation of ABAP Push Channel to exchange messages between different WebSocket Clients. This video gives you step-by-step introduction on how to implement collaboration scenario using ABAP Messaging Channel and ABAP Push Channel.

 

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Florian Henninger
      Florian Henninger

      Hi Olga,

      nice blog as usual. Can you release something about the dynpro push channels? I read somewhen a bit about it, but I'm not sure if the APC/AMC is the same?

      Can I look forward to something other?

      Thank you

      ~Florian

      Author's profile photo Olga Dolinskaja
      Olga Dolinskaja
      Blog Post Author

      Hi Florian,

      you can use AMC for message exchange between ABAP sessions, which can even belong to different ABAP application servers. The example of AMC communication between two dynpro applications is explained in the "How to implement ABAP Messaging Channel (AMC)" video here and in Masoud's blog http://scn.sap.com/community/abap/connectivity/blog/2014/03/26/abap-channels-part-2-publish-subscribe-messaging-using-abap-messaging-channels

      Best Regards,

      Olga.

      Author's profile photo Adi Mogilevsky
      Adi Mogilevsky

      Could I use this WebSocket channel from non-SAP third party WS protocol?

      Author's profile photo Stefan Hagen
      Stefan Hagen

      Hi Adi,

      Yes, raw websocket communication is possible. At the point where you can select the PCP protocol, leave the field empty and go without protocol.

      Then you can implement your own protocol handling in ABAP by accessing the payload data directly and parse it to your liking.

      Best Regards,
      Stefan

      Author's profile photo Former Member
      Former Member

      Hello Olga,

      thank you very much for these interesting tutorials.

      Can't wait to try out this functions.

      Our Development System is on 7.4 SP 6.

      Do you think it will be possible to create the echo example with this version?

      Thanks,

      Thomas

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei

      Hi Thomas,

      in releases < 7.40 SP8 the Push Channel Protocol (PCP) handling can be done in application which is per default available with releases >= 740 SP08. The PCP type is per default a text based message type (very similar to HTTP message format without the request/response line
      part). In ABAP the PCP is realized via class CL_AC_MESSAGE_TYPE_PCP and the respecting interface IF_AC_MESSAGE_TYPE_PCP. In UI5/Fiori the PCP library is provided as sap.ui.core.ws.SAPPcpWebsocket and the messages transferred to an APC application can be deserialized to an PCP object via following line of codes included in ON_MESSAGE method:

      TRY.

           DATA(lo_pcp) = CL_AC_MESSAGE_TYPE_PCP=>DESERIALIZE(´i_message->get_text( ) ).
         CATCH  cx_ac_message_type_pcp_error INTO DATA(lx_pcp_error).

           " apply error handling

          CATCH cx_apc_error INTO DATA(lx_apc_error).

           "apply error handling

      ENDTRY.

      Furthermore to create a PCP message in an 740 SP05-S=7 release you will use following code
      snippet, e.g. in ON_MESSAGE:

        TRY.
            DATA(lo_message_mgr) = i_message->get_context( )->get_message_manager( ).
            DATA(lo_message) = lo_message_mgr->create_message( ).
            " transfer of a message via PCP

            DATA(lo_pcp) = cl_ac_message_type_pcp=>create( ).

            lo_pcp->set_text( “some text” ).

            lo_pcp->set_field( i_name = “myname” i_value = “myvalue” ).
            lo_message->set_text( lo_pcp->serialize( ) ).
            lo_message_mgr->send( lo_message ).
          CATCH  cx_ac_message_type_pcp_error INTO DATA(lx_pcp_error).

           "apply error handling
          CATCH cx_apc_error INTO DATA(lx_apc_error).

           "apply error handling
        ENDTRY.

      Cheers,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi Masoud,

      thanks fot the fast reply.

      I will try this out.

      Cheers,

      Thomas

      Author's profile photo Simon Gaudek
      Simon Gaudek

      Thanks Olga, this is very interesting!

      But can you please upload the code of your UI5 controller.

      Would be very helpfull to me.

      Thanks!

      Author's profile photo Olga Dolinskaja
      Olga Dolinskaja
      Blog Post Author

      Hi Simon,

      please find attached to the blog the Echo.controller.js example.

      Best regards,

      Olga.

      Author's profile photo Nitesh Jain
      Nitesh Jain

      Hi Olga/Masoud,

      I have a normal ABAP dynpro which has an ALV grid which needs to be refreshed based on some event.

      Using AMC and APC i have got the message in the module pool program but tried to find a way as to how do i refresh the ALV grid table data.

      Any ideas? I hope this is possible with normal ABAP dynpro screens.

      regards

      Nitesh

      Author's profile photo Mathias Bischoff
      Mathias Bischoff

      Hello Olga,

      Which package version is needed to use the Websocket Client Class: CL_APC_WS_CLIENT

      Support Package 5 or Support Package 8.

      Are there examples existing. I want to write a Socket IO Client Lib.


      Best regards


      Mathias

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei

      Hi Matthias,

      the WebSocket client, i.e. APC client, is not released in NW ABAP 740 SPx and is only available as prototype ! The  general  availability is with NW ABAP 750.

      Best regards,

      Masoud

      Author's profile photo Mathias Bischoff
      Mathias Bischoff

      Hi Masoud,

      Thanks for the quick response. When is it intended to be available :-)?

      Best Regards

      Mathias

      Author's profile photo Masoud Aghadavoodi Jolfaei
      Masoud Aghadavoodi Jolfaei

      Hi Matthias,

      just have a look into the blog SAP Netweaver 7.5 - One common foundation for SAP Business Suite and SAP S/4HANA, om-premise edition .

      Best regards,

      Masoud

      Author's profile photo Former Member
      Former Member

      Hi all,

      Thank you for guides. Could you please clarify is there any way to process AMC messages in async mode (run if_amc_message_receiver~receive asynchronously)?

      Thank you.

      Author's profile photo Olga Dolinskaja
      Olga Dolinskaja
      Blog Post Author

      Hi Iegor,

      you can start e.g. an asynchronous RFC (aRFC) in your main program and in this aRFC implement subscription to the AMC to get AMC messages there. As soon as an AMC message is received in this aRFC, it will return to the main program via callback. Just take a look at the Masoud's reply in the "Comments" section of the blog “Say Goodbye to Polling: Real-time eventing in ABAP with ABAP Channels”. There you will find an example report with explanation how to implement it.


      Best Regards,

      Olga.

      Author's profile photo Former Member
      Former Member

      Hi Olga,

      thank you for the reply. I have considered such approach, but messages still will be processed successively, the only difference is the main thread is not blocked. So the total processing time will be the same. Apparently it is impossible to build something like rest-service using channels, am I right?

      Author's profile photo Olga Dolinskaja
      Olga Dolinskaja
      Blog Post Author

      Hi Jegor,

      yes, ABAP Messaging Channel (AMC) is not like a REST-based services infrastructure. AMC is based on the publish-subsribe mechanism and acts as a broker between ABAP sessions to exchange messages.

      Regards,

      Olga.

      Author's profile photo Sami Alyasin
      Sami Alyasin

      Hi,

      I know this old thread, but I am new to ABAP Channel.

       

      1. Is this considered as a message BUS in SAP ?

      2. I am trying to understand the use case for this. For SOA, I understand that the receiver should be always a live "WAITING" and listing for the SENDER. But, when I receive a message, my intention should be that to do some database/transaction action and get back into WAITING mode. As currently with ABAP Channel, I can't add a commit work or submit within the if_amc_message_receiver_text~receive .The WAITING must end to do a DATABASE commit. Can you please explain how can I use this as always WAITING to perform an Action.

      How can I get publish/subscribe if I can not do some  Like

      WAIT=>RECIVE A MESSAGE=>ACTION(with DB reflection)=>WAIT

      I missing something, but not sure what it is. Should each "receiving action" program needs to end to do a commit work ?1

       

      Thanks for your time