Asynchronous, non-blocking SAP NetWeawer RFC SDK client bindings for Node.js.
- Based on 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
- Buffer, Decimal and Date objects support
- Connection pool
- Extensive unit tests
-
The node-rfc connector can be built from source on all platforms supported by SAP NW RFC SDK and by nodejs
-
Pre-built binaries are provided for active nodejs LTS releases, for 64 bit Windows 8.1, Ubuntu 16.04 and macOS 10.14.
-
SAP NW RFC SDK C++ binaries must be downloaded (SAP partner or customer account required) and locally installed (installation instructions). More information on SAP NW RFC SDK section on SAP Support Portal. Using the latest version is reccomended as SAP NW RFC SDK is fully backwards compatible, supporting all NetWeaver systems, from today S4, down to R/3 release 4.6C.
-
Build toolchain requires CMake
-
Build from source on macOS and older Linux systems, may require
uchar.h
file, attached to SAP OSS Note 2573953, to be copied to SAP NW RFC SDK include directory: documentation
-
Visual C++ Redistributable is required for runtime. The version is given in SAP Note 2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50
-
Build toolchain requires Microsoft C++ Build Tools, the latest version reccomended
- The macOS firewall stealth mode must be disabled (Can't ping a machine - why?):
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
- Remote paths must be set in SAP NWRFC SDK for macOS: documentation
After the SAP NW RFC SDK is installed on your system, you can install the node-rfc package from npm:
yarn add node-rfc
npm install node-rfc
Alternatively, or if the node-rfc package not provided for your platform, buld the package from the latest source and install:
git clone -b https://github.com/SAP/node-rfc.git
cd node-rfc
npm install
# set connection properties in test/abapSystem
npm test
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.
Connection parameters for remote ABAP systems are documented in sapnwrfc.ini file, located in the SAP NWRFC SDK demo
folder
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:
-
node-rfc documentation, complementing SAP NW RFC Library programming guide and documentation
"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.
- NAPI Type checks nodejs/node-addon-api/#265
If you encounter an issue or have a feature request, you can create a ticket.
Check out the SCN Forum (search for "node-rfc") and stackoverflow (use the tag "node-rfc"), to discuss code-related problems and questions.
Copyright (c) 2013 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.