Skip to content

Berdmanfolk/node-rfc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The nodejs RFC Connector

This node module provides bindings for SAP NetWeawer RFC Library, for a comfortable way of calling ABAP modules from nodejs, via SAP Remote Function Call (RFC) protocol.

NPM

Platforms & Prerequisites

The node-rfc has been initially built with nodejs v0.10.26, on Linux 64 bit platform and later enhanced, mostly used and tested on Linux and Windows 64 platforms.

OS X and ARM platforms are currently not supported, as SAP NW RFC Library is not available for those platforms.

To start using node-rfc you need to obtain SAP NW RFC Library from SAP Service Marketplace, following these instructions.

A prerequisite to download is having a customer or partner account on SAP Service Marketplace and if you are SAP employee please check SAP OSS note 1037575 - Software download authorizations for SAP employees.

SAP NW RFC Library is fully backwards compatible, supporting all NetWeaver systems, from today, down to release R/3 4.0. You can therefore always use the newest version released on Service Marketplace and connect to older systems as well.

Documentation

For full documentation please refer to node-rfc documentation, complementing SAP NW RFC Library programming guide and documentation provided on SAP Service Marketplace.

Install

Install from npm

npm install node-rfc

or clone from the GitHub repository to build and run tests and examples locally

git clone https://github.com/SAP/node-rfc.git
cd node-rfc
npm install

Getting started

In order to call remote enabled ABAP function module, we need to create a client with valid logon credentials, connect to NetWeaver system and then invoke a remote enabled ABAP function module from node. The client can be used for one or more subsequent RFC calls.

"use strict";

var rfc = require('node-rfc');

var abapSystem = {
  user: 'name',
  passwd: 'password',
  ashost: '10.11.12.13',
  sysnr: '00',
  client: '100',
  saprouter: '/H/111.22.33.177/S/3299/W/tdkf9d/H/132.139.17.14/H/'
};

// create new client
var client = new rfc.Client(abapSystem);

// echo the client NW RFC lib version
console.log('RFC client lib version: ', client.getVersion());

// and connect
client.connect(function(err) {
  if (err) { // check for login/connection errors
    return console.error('could not connect to server', err);
  }

  // invoke remote enabled ABAP function module
  client.invoke('STFC_CONNECTION',
    { REQUTEXT: 'H€llö SAP!' },
    function(err, res) {
      if (err) { // check for errors (e.g. wrong parameters)
        return console.error('Error invoking STFC_CONNECTION:', err);
      }

      // work with result;  should be something like:
      // { ECHOTEXT: 'Hello SAP!',
      //   RESPTEXT: 'SAP R/3 Rel. 702   Sysid: E1Q      Date: 20140613   Time: 142530   Logon_Data: 001/DEMO/E',
      //   REQUTEXT: 'Hello SAP!' }
      console.log('Result STFC_CONNECTION:', res);
    });


  // invoke more complex ABAP function module
  var importStruct = {
    RFCFLOAT: 1.23456789,
    RFCCHAR1: 'A',
    RFCCHAR2: 'BC',
    RFCCHAR4: 'DEFG',

    RFCINT1: 1,
    RFCINT2: 2,
    RFCINT4: 345,

    RFCHEX3: 'fgh',

    RFCTIME: '121120',
    RFCDATE: '20140101',

    RFCDATA1: '1DATA1',
    RFCDATA2: 'DATA222'
  };

  var importTable = [importStruct];

  client.invoke('STFC_STRUCTURE',
    { IMPORTSTRUCT: importStruct, RFCTABLE: importTable },
    function(err, res) {
      if (err) {
        return console.error('Error invoking STFC_STRUCTURE:', err);
      }
      console.log('Result STFC_STRUCTURE:', res);
  });

});

Finally, the connection is closed automatically when the instance is deleted by the garbage collector or by explicitly calling the client.close() method on the client instance.

For more examples, check files in the demo folder. Maintain your NW test system parameters first in the source code, before running those examples.

node demo\demo
node demo\demo1, 2 ...

REST API

Example how to create REST APIs using node-rfc, node, express and gulp: https://github.com/Adracus/noderfc-restapi.

About

SAP RFC Connector for NodeJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 65.2%
  • JavaScript 29.9%
  • Python 4.9%