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.


/wp-content/uploads/2015/07/pcp_bnf_756197.gif

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:

/wp-content/uploads/2015/07/pcp_log_send_756198.gif

with the content:

/wp-content/uploads/2015/07/pcp_log_content_send_756199.gif


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:

/wp-content/uploads/2015/07/pcp_log_receive_756206.gif

with the content:

/wp-content/uploads/2015/07/pcp_log_content_receive_756208.gif


PCP Libraries


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”.
  • In SAP UI5 the class sap.ui.core.ws.SapPcpWebSocket provides the necessary PCP methods as an extension to the JavaScript WebSocket class.
  • In other alternative UI technologies, e.g. Web Dynpro, Business Server Pages, SAP GUI HTML, provides “sap-pcp-websocket.js” the necessary PCP methods. This library is available in the mime repository (under the repository path /sap/public/bc/ur) and in ABAP Application Server with 740 SP10. For accessing the library refer to note 2050139 (SAP Push Channel Protocol (PCP) JavaScript library for ABAP Push Channel).
To report this post you need to login first.

5 Comments

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

  1. Sergiu Popa

    Hi Masoud,

    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?

    Thank you!

    Sergiu

    (0) 
  2. Gregor Wolf

    Dear Masoud,

    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.

    Best regards

    Gregor

    (0) 
    1. Matthias Osswald

      Hi Gregor,

      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:

      jQuery.sap.require(“sap.ui.core.ws.SapPcpWebSocket”);

      The WebSocket Classes should be available since 1.16 (protocol parameter since 1.20).

      Cheers,

      Matthias

      (0) 

Leave a Reply