Skip to Content

Recently, on a journey through the internet I discovered Node.js which looked to me like a suitable tool for various integration scenarios. In short, Node.js is an asynchronous, event-driven application server based on Google’s V8 JavaScript engine.

Unlike web servers like Apache, lighttpd etc. it doesn’t spawn a process or thread for every incoming connection, but handles everything within a single process. This is achieved by using asynchronous I/O operations which won’t block the engine’s execution. Instead, after calling a asynchronous function, execution of program code will instantaneously be continued and a callback handler will be executed upon completion of the I/O operation.

Node.js features a full-fledged HTTP server out of the box – and that is just the beginning. Like any other multi purpose programming language, it offers access to network sockets, file system, tty devices, process management and so on. Additionally there’s an endless collection of modules which is being provided by a broad community. Amongst other things, there are modules for database connectivity, SMTP server and message bus implementations.

Just out of curiosity I have implemented bindings for the SAP NetWeaver RFC SDK for use with Node.js. The usage resembles Piers Harding’s implementation for PHP but differs concerning the callback mechanism:

var sapnwrfc = require('sapnwrfc');

var connectionParams = {
  ashost: '192.168.0.10',
  sysid: 'NPL',
  sysnr: '42',
  user: 'DEVELOPER',
  Passwd: 'password',
  client: '001',
  lang: 'E'
};

var con = new sapnwrfc.Connection;

con.Open(connectionParams, function(err) {
  if (err) {
    console.log(err);
    return;
  }
 
  var funcParams = {
    IMPORTSTRUCT: { RFCFLOAT: 3.14159, RFCINT1: 123, RFCTIME: '094500', RFCCHAR4: 'NODE' }
  }

  var func = con.Lookup("STFC_STRUCTURE");
  func.Invoke(funcParams, function(err, result) {
    if (err) {
      console.log(err);
      return;
    }

    console.log(result);
  });
});

The source code has been made available via GitHub but you are also encouraged to install it easily via npm (node package manager). Please read the README on GitHub for further instructions because you will have to download the RFC SDK beforehand.

To report this post you need to login first.

9 Comments

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

  1. Alisdair Templeton
    Hi Joachim,

    I’ve been using NodeJS to build system monitoring dashboards, but have always used HTTP to talk with SAP directly, or via an intermediate event store such as CouchDB which provides a streaming API that Node can listen too. Having an RFC option to allow connection to older SAP systems will be very very useful.

    Looking forward to trying the RFC library.

    Thanks!
    AT

    (0) 
    1. Joachim Dorner Post author
      Hi Alisdair,

      that sounds interesting. IMHO Node is a very good tool for monitoring because of it’s ability to manage lots of open connections (see socket.io library) without running out of resources.

      Would like to get some further feedback from you.

      Regards,
      Joachim

      (0) 
    2. riaz munshi

      Hi Alisdair,

           I was trying to connect to SAP Business data using NodeJS over Http, and I was successful in sending data to server(node js), but was unable to push updated data back to the SAP Server.I was trying to use if_http_response to retrieve data.

           I am trying to create a real-time scheduler like application using sencha, so i need you help.

           I hope you reply soon………………..

      Also, I was referring the following post for my purpose:

      1 – http://scn.sap.com/community/technology-innovation/blog/2013/02/04/websockets-with-nodejs-socketio-and-abap–part-2-node-server-app

      2 – http://scn.sap.com/community/technology-innovation/blog/2013/02/04/websockets-with-nodejs-socketio-and-abap–part-2-node-server-app

      3  – http://scn.sap.com/community/technology-innovation/blog/2013/02/06/websockets-with-nodejs-socketio-and-abap–part-3-the-magic

      (0) 
  2. Michelle Crapo
    Any chance I can convince you to put your code in a code block?  It makes it easier to copy!  I love reusing solutions where someone else has already don the hard work.

    Michelle

    (0) 
  3. Gregor Wolf
    Hi Joachim,

    that you for that great work. It’s nice to see another SCN contributor from Siteco. Hope to find time to test it soon.

    Best regards
    Gregor

    (0) 
    1. Joachim Dorner Post author
      Hi Gregor,

      you’re welcome. I’m looking forward to get some valuable feedback from you. As a side note: it won’t compile on Windows platforms without some modifications to the installation script (compiler flags etc.).

      Regards,
      Joachim

      (0) 

Leave a Reply