Skip to content
Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Branch: master
Clone or download
Latest commit 0f3612d Feb 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
demo string handling, c/c++ style guide May 8, 2018
doc Docu stealth mode fix Feb 20, 2019
exp memleak test May 16, 2018
issues memleak test May 16, 2018
lib v0.1.6 Nov 22, 2016
module_mods Version 0.1.7; continuous integration support Dec 23, 2016
src
test connection parameters May 15, 2018
.gitignore
.travis.yml
CHANGES README Jun 14, 2018
LICENSE
README.md documentation Feb 20, 2019
VERSION
binding.gyp
build.sh Version 0.1.7; continuous integration support Dec 23, 2016
index.js Version 0.1.7; continuous integration support Dec 23, 2016
package-lock.json
package.json 0.1.16 preparation Apr 30, 2018
release.sh

README.md

❗️ Notice ❗️

The package is ported to N-API, a ABI stable C interface provided by Node.js.

Only critical fixes will be provided for Nan based version.

Please continue using the N-API version, as a prerelease, considering minor incompatible changes.

SAP NW RFC SDK Client for Nodejs

Asynchronous, non-blocking SAP NetWeawer RFC SDK client bindings for Node.js.

NPM

license release downloads

Features

  • Based on the latest nodejs N-API standard
  • Stateless and stateful connections (multiple function calls in the same ABAP session (same context))
  • Async/await, promise and callback API
  • Sequential and parallel calls, using one or more clients
  • Automatic conversion between JavaScript and ABAP datatypes
  • Decimal and Date objects support
  • Connection pool
  • Extensive unit tests

Prerequisites

SAP NW RFC SDK C++ binaries must be downloaded (SAP partner or customer account is required) and locally installed. More information on SAP NW RFC SDK section on SAP Support Portal.

SAP NW RFC Library is fully backwards compatible, supporting all NetWeaver systems, from today S4, down to R/3 release 4.0B. Using the latest version is reccomended.

Supported platforms

Compiled binaries are provided for active nodejs LTS releases, for 64 bit Windows 7.1 and Ubuntu 16.04 Linux platforms.

Build from source is required on other platforms, supported both by SAP and by nodejs.

Usage and API

Note: the module must be installed before use.

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

Callback API example below shows basic principles. See also:

'use strict';

const rfcClient = require('node-rfc').Client;

// ABAP system RFC connection parameters
const abapSystem = {
	user: 'demo',
	passwd: 'welcome',
	ashost: '10.68.104.164',
	sysnr: '00',
	client: '620',
	lang: 'EN',
};

// create new client
const client = new rfcClient(abapSystem);

// echo SAP NW RFC SDK and nodejs/RFC binding version
console.log('Client version: ', client.version);

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

	// invoke ABAP function module, passing structure and table parameters

	// ABAP structure
	const structure = {
		RFCINT4: 345,
		RFCFLOAT: 1.23456789,
		// or RFCFLOAT: require('decimal.js')('1.23456789'), // as Decimal object
		RFCCHAR4: 'ABCD',
		RFCDATE: '20180625', // in ABAP date format
		// or RFCDATE: new Date('2018-06-25'), // as JavaScript Date object
	};

	// ABAP table
	let table = [structure];

	client.invoke('STFC_STRUCTURE', { IMPORTSTRUCT: structure, RFCTABLE: table }, function(err, res) {
		if (err) {
			return console.error('Error invoking STFC_STRUCTURE:', err);
		}
		console.log('STFC_STRUCTURE call result:', 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.

Installation

From npm:

npm install node-rfc@next

Build from the latest source:

# The SAPNWRFC_HOME env variable must point to root folder of
# SAP NW RFC SDK libraries on your system, like /usr/local/sap/nwrfcsdk
git clone -b napi https://github.com/SAP/node-rfc.git
cd node-rfc
npm install
node-pre-gyp configure build
# set connection properties in test/abapSystem
npm run test

Nan based version:

npm install node-rfc

Links

Developer resources:

You can’t perform that action at this time.