Skip to Content

In this blog i want to describe my new project on Sap Code Exchange : Abap Pusher ( https://cw.sdn.sap.com/cw/groups/abap-pusher )
With Abap Pusher we can use Html5 websockets for adding realtime functionalities in Abap World.

What is a WebSocket?

(from http://en.wikipedia.org/wiki/WebSocket )
WebSocket is a technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket. It is designed to be implemented in web browser and web servers but it can be used by any client or server application

What is Pusher?

Pusher ( http://pusher.com , docs here http://pusher.com/docs/ ) is a simple hosted API for quickly, easily and securely adding realtime bi-directional functionality via WebSockets to web and mobile apps, or any other Internet connected device.

Pusher web service will send our messages to all connected clients that have subscribed our channel (using Html5 WebSockets protocol).

What is Abap Pusher?

Abap Pusher is an abap project for publishing/triggering events from ABAP using  Pusher REST API . In these way we can push realtime events from Abap to Browsers or any other connected clients without using Ajax,long polling..etc…. Server will push the messages to all clients.
Pusher provides many client libraries (Javascript , iOs , Android , Ruby , Arduino ,..).In my examples  I used Javascript library ( http://pusher.com/docs/client_libraries ).

Main class is ZCL_PUSHER

A simple Example.

First of all we need a Pusher account : there are many plans but the “Sandbox” Free plan (20 max connection) is good for our demo purposes.
Exploring Pusher dashboard, we can create “Apps” (an app called “Main” is created by default ) and on tab “Api Access” we found App_id , Key Token and Secret Token.
These 3 parameters are mandatory to create a ZCL_PUSHER instance. The message can be in any format but Pusher recommends  JSON;we can create JSON Strings using Json Abap Document Class by Uwe Fetzer ( https://cw.sdn.sap.com/cw/groups/zjson)

You can optionally specify socket id to avoid duplicates (see http://pusherapp.com/docs/duplicates )

Server Side (Abap)

Trigger an event ( PROG ZDEMO_PUSHER )

Client Side (Javascript )

So I can connect to my simple page http://www.alessandrospadoni.it/test_pusher.html from Chrome and Ipod Touch (iOs , Safari).

Both clients are connected to Pusher websocket.

Now i execute ZDEMO_PUSHER and this is the result!

This solution can be very useful in all “Real Time” situations , for example a simple application that displays realtime stock levels to the customers. (watch this video  ).
This is a simple example using a channel that doesn’t need authentication (Public channels ).

I will write another blog about “private” channels,prefixed with “private-“, “presence” channels ,prefixed with “presence-“ (useful for Chat apps) and Pusher WebHooks.

update 5.11.2012

This is the link to the 2nd part about “Private Channels that needs an Authorization” : http://scn.sap.com/community/code-exchange/blog/2012/10/01/abap-pusher-abap-authorization-objects-and-private-channels

This is a simple video recorded for Sap Inside Track Milan about Public Channels:

Links:

Abap Pusher

Pusher docs

To report this post you need to login first.

12 Comments

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

  1. Sergio Ferrari
    Alessandro you rock!
    Waiting for a standard SAP implementation of WebSocket (e.g. in a new kernel and SICF handler) your implementation seems very useful.

    I think that the integration between SAP and other powerful products/services represents really the spirit of the SCN Community

    Sergio

    (0) 
    1. Sascha Wenninger
      +1! Very cool blog Alessandro!

      Marrying up some of the cutting-edge solutions from the “real world” of IT with existing SAP solutions is what we need more of – especially when it means SAP customers can make use of this right now, without upgrading their backend to the latest version or buying more licencses.

      Well done!

      Sascha

      (0) 
  2. Hendrik Brandes
    Hello Alessandro,

    very very cool! Although it is not implemented directly in the SICF/Kernel, it should be a solution for enabling first webapps with websocket-requirements. I am looking forward it!

    Kind regards,
    Hendrik

    (0) 
  3. Anton Wenzelhuemer
    Thanks for sharing!

    While giving it a quick try I instantly found out about an instance of HTML/JS features I love sooo much. Usually you instantiate a websocket object with ‘WebSocket(address)’, but in Firefox you instantiate the same with ‘MozWebSocket(address)’. But hey, don’t we all know that – just a little browser detection script and a switch and everything is cool ;-))

    regards,
    anton

    (0) 
  4. Graham Robinson
    Thanks for this blog. Websockets are becoming and increasingly important feature that modern servers should all support IMO.

    I continue to encourage SAP to build websockets support into the ICM. Let’s hope it happens soon.

    Cheers
    Graham Robbo

    (0) 
  5. Torsten Manhardt

    Hello Mr.Spadoni,

    i’m very interested in your ABAP Pusher implementation. Unfortunatly code exchange is closed. I read about ABAP Pusher in the documentation of Netwaever 7.40. Probably that corresponds to your Pusher?

    But our Netweaver ist still 7.31, is there any implementation availabe for that release?

    Thank you in advance and best wishes

    Torsten Manhardt

    (0) 
    1. Alessandro Spadoni Post author

      Hi Torsten,

      the ABAP Push Channel on 7.4 is not related to abap pusher , but it’s the SAP Standard way to manage Web Sockets in Abap WAS,differently my Abap Pusher project was an Abap library to use the pusher.com SAAS.

      Now there is a SAP standard implementation integrated to Abap , my abap pusher project is no longer maintained (no time and other projects 🙂 ) but if you want to try it , the code-exchange project was migrated to assembla. Here is the link to download it

      https://www.assembla.com/code/abap-pusher/subversion/nodes/6/trunk/build/ABAP_PUSHER_0.1.nugg?_format=raw

      You need SAPLINK to import the nugg file

      (0) 

Leave a Reply