Monday, December 21, 2015

ABAP Channels: ABAP Messaging and Push Channels

Traditionally interaction between user using e.g. SAP GUI and SAP system is like follows. User does some interaction (e.g. mouse click) and this is send to ABAP server to process. The ABAP server processes it and as per application logic it sends data back to client = SAP GUI where it is presented to the user (e.g. screen is refreshed with the newest data. This is what is called traditional SAP user interface design. It follows request/response model of interaction. However this is one of traditional obstacles in SAP systems. The traffic between client and server is very high. They basically exchange the data constantly and it also always requires user interaction (e.g. hitting refresh button). This approach is also called polling or event driven communication.
On other hand today’s application requires real-time data and interaction must be collaborative in way where user is not supposed to be inquiring information every time but as the information in application (e.g. in underlying database table) is changed but the user is supposed to get automatically instead. Means the application is not waiting for the user but it sends information (e.g. notifications) directly to the user instead of waiting for the request.

In SAP Application Server ABAP 7.40 Support Package 05 a new concept is introduced via infrastructure for event based communication. The new concept is called ABAP channels created in SAP NetWeaver Application Server ABAP. Now let’s take closer look how it is actually implemented.

SAP Web UIs such as WebGUI, Business Server Pages (BSP), Web Dynpro ABAP (WD4A) or SAPUI5 can use the ABAP Push Channel (APC) which enables such a real-time communication via WebSockets (over TCP/IP socket). The APC is bidirectional message based communication channel representing the WebSockets integration in ABAP. There is a possibility of push notifications to UI as soon as data change happened in the ABAP backend. This is a sign for a user to request the changed data from ABAP backend and update UI. The APC basically provides real-time UI access to ABAP’s data.

What we need in addition is to make interaction between events possible. Means event driven communication between ABAP sessions across different ABAP application servers. This is because the data might be processed by many sessions. So this would a way how the sessions are communicating between each other. Traditionally there would be a many polling performed to inquire the status of the data processing. Instead of this publish/subscribe mechanism is used to prompt the notifications. The ABAP Messaging Channel (AMC) infrastructure replaces the traditional polling. It acts as a broker for the messages exchange between different ABAP sessions (on different ABAP application servers). The AMC basically provides real-time communication between ABAP sessions.

Now how the two – APC and AMC plays together? By employing both of them scenarios when different users are working with same data of particular business object data. In here a changed data must be displayed on GUI of all users in the real-time without locking the object for changes by other users. With support of push channels, messaging channels and collaboration scenarios it is possible to use WebSockets to facilitate the exchange of messages between different ABAP sessions and enable users to collaborate over the infrastructure in real time.
Let’s go further. Imagine all possibilities that will come with Internet of Things (IoT). Having ABAP Messaging and Push Channels in place can enable many scenarios in management of shop floor and inventory areas be handled simultaneously.

Finally how is this done technically? It is implemented by Push Channel Protocol (PCP). It is SAP proprietary message based protocol. It is very similar to HTTP protocol. The PCP messages consist of header fields and a plain body. The body is separated by line feeds. Field values entries are in pairs of name-value separated by “:” sign. Implementation in the ABAP backend comprises of class CL_AC_MESSAGE_TYPE_PCP and interface IF_AC_MESSAGE_TYPE_PCP PCP which is having API. Implementation in SAPUI5 is within the class For other UI technologies there is a library sap-pcp-websocket.js for particular PCP methods.

More information:
Specification of the PCP

No comments: