Specification of the Push Channel Protocol (PCP)
The Push Channel Protocol is a message based protocol, which is used in context of ABAP Channels, i.e. ABAP Messaging Channels and ABAP Push Channels. The message structure is very similar to a simple HTTP message (see RFC2616) without having the start-line (request-line, response-line) entry. In other words the PCP messages consist of (header) fields and a plain body which is separated by line feeds (LF, i.e. \n – 0x0A (hexadecimal) – 10 (decimal)). A field entry contains name-value pair separated by “:” character, i.e. <name>:<value>. The names and values are in UTF-8 characters and case-sensitive. The names and values should not contain the special characters LF, “:” and “\”. In that case the special characters must be escaped with the escape character “\” whereas LF is replaced by “\n”. Each field entry, i.e. <name>:<value>, is terminated by a line feed. The last field entry is completed with double LF, i.e. LFLF, independently of the existence of a body. In case of the existence of a body this content is appended after the double LFs. The body contains only UTF8 characters. A body in binary is encoded in Base64 format. Additionally field name or values must not contain leading or trailing spaces, i.e. white spaces. The field names starting with the prefix “pcp-” are reserved for PCP library and must not be used by application.
For the usage of the PCP protocol in context of ABAP Push Channel, i.e. the WebSocket support in ABAP Application Server, the WebSocket subprotocol “v10.pcp.sp.com”, i.e. version 1.0 of the PCP protocol, is to be used.
Augmented Backus-Naur Form (BNF)
A Push Channel Protocol (PCP) message can be more formally described using the Backus-Naur Form (BNF) grammar used in HTTP/1.1 RFC 2616. Figure 1 shows the structure of a PCP message.
Figure 1: BNF grammer of Push Channel Protocol message structure
The WebSocket log of a WebSocket connection to an ABAP Push Channel application using subprotocol “v10.pcp.sap.com” will show following records, when the client sends a PCP message with two fields and a body and the following values.
- Field 1 consisting of field name “field1” and field value “value1”
- Field 2 consisting of field name “field2” and field value “field2”
- A body containing the text “this is the body !”
In Chrome developer tools will show the following log entries:
with the content:
In this example the APC application returns the received message including the additional field with the field name “counter” and the field value “1” back:
with the content:
There exist up to now the following libraries for different use-cases:
- In ABAP Application Server and in the context of ABAP Channels the class CL_AC_MESSAGE_TYPE_PCP and interface IF_AC_MESSAGE_TYPE_PCP PCP provide the necessary APIs. Furthermore the PCP message type is an inbuilt message type in in ABAP Messaging Channels and in ABAP Push Channels as WebSocket subprotocol “v10.pcp.sap.com”.
Thanks again for a useful blog post. It is just what I was looking for 🙂 .
Regarding using V1 of the PCP protocol with ABAP Push Channel, giving the mention of a specific PCP protocol version, I was wondering whether another version of PCP is available? If so, could you please give me some quick hints about where I could find out more info about this?
the v10 version is the latest PCP protocol version and there is no other version of PCP protocol available.
I've tried to implement the example shown in the Videos How to implement ABAP Push Channel (APC) and How to implement collaboration using ABAP Push Channel (APC) and ABAP Messaging Channel (AMC). Unfortunately the code line:
this.oWs = new sap.ui.core.ws.SapPcpWebSocket("/sap/bc/apc/sap/zapc_echo", sap.ui.core.ws.SUPPORTED_PROTOCOLS.v10);
causes the Java Script error:
Uncaught TypeError: Cannot read property 'SapPcpWebSocket' of undefined
Which minimum Version of SAPUI5 do I need to make it work? On my ABAP Stack it is only 1.22.3.
did you miss to require the module first?
As it is not a control (lazyloading) and not loaded by default you have to manually require it:
The WebSocket Classes should be available since 1.16 (protocol parameter since 1.20).
thank you for your tip. In the meantime I've figured it out myself and already blogged about it:
ABAP Push / Messaging Channel and SAPUI5 Demo Application