3.3.1 • Published 12 months ago

node-rfc v3.3.1

Weekly downloads
1,303
License
Apache-2.0
Repository
github
Last release
12 months ago

:heavy_exclamation_mark: Experimental N-API Port :heavy_exclamation_mark:

See open issues.

license

release

downloads

The nodejs SAP NW RFC Connector

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

  • Based on the latest nodejs N-API standard
  • Promise and callback interface
  • Connections pool (in progress)
  • Sequential and parallel calls, using single or multiple node-rfc cliens
  • Automatic conversion between JavaScript and ABAP datatypes
  • Decimal objects support
  • Extensive unit tests

Prerequisites

SAP NW RFC Library must be locally installed. It can be downloaded from SAP Service Marketplace Software Download Center, following instrunctions in SAP Note 2573790. SAP partner or customer is required for download.

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

Supported platforms

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

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

Usage

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 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.

'use strict';

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

var abapSystem = {
	user: 'name',
	passwd: 'password',
	ashost: '10.11.12.13',
	sysnr: '00',
	client: '100',
};

// 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 the unit tests source code.

The same example with promises:

'use strict';

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

let abapSystem = {
	user: 'name',
	passwd: 'password',
	ashost: '10.11.12.13',
	sysnr: '00',
	client: '100',
};

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

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

// and connect
client.open

	.then(() => {
		client
			.call('STFC_CONNECTION', { REQUTEXT: 'H€llö SAP!' })

			.then(res => {
				console.log('Result STFC_CONNECTION:', res);
			})

			.catch(err => {
				return console.error('Error invoking STFC_CONNECTION:', err);
			});

		let 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',
		};

		let importTable = [importStruct];

		client
			.call('STFC_STRUCTURE', { IMPORTSTRUCT: importStruct, RFCTABLE: importTable })
			.then(res => {
				console.log('Result STFC_STRUCTURE:', res);
			})
			.catch(err => {
				return console.error('Error invoking STFC_STRUCTURE:', err);
			});
	})

	.catch(err => {
		return console.error('could not connect to server', err);
	});

API and documentation

For API And full documentation please refer to node-rfc documentation, complementing SAP NW RFC Library programming guide and documentation.

Useful links:

Developer resources:

Install

To install and use:

npm install node-rfc

To test and develop, clone the repository, edit your backend system connection parameters, build and run tests locally:

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

Pre-compiled binaries for currently active nodejs LTS releases are provided in the lib folder.

For Developers

Issues

3.3.2-rc.1

12 months ago

3.3.1

12 months ago

3.2.0

1 year ago

3.0.0

1 year ago

2.7.2-rc.1

1 year ago

2.7.2-rc.2

1 year ago

2.7.2-rc.0

1 year ago

2.7.2-rc.5

1 year ago

2.7.2-rc.3

1 year ago

2.7.2-rc.4

1 year ago

3.3.0

1 year ago

3.1.0

1 year ago

3.0.0-rc.2

1 year ago

3.0.0-rc.1

1 year ago

3.0.0-rc.3

1 year ago

2.7.1

2 years ago

2.7.0

2 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.6.0-rc1

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.3

3 years ago

2.4.1

4 years ago

2.4.2

4 years ago

2.4.0

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc11

5 years ago

1.0.0-rc10

5 years ago

1.0.0-rc9

6 years ago

1.0.0-rc8

6 years ago

1.0.0-rc7

6 years ago

1.0.0-rc6

6 years ago

1.0.0-rc5

6 years ago

1.0.0-rc4

6 years ago

1.0.0-rc3

6 years ago

1.0.0-rc2

6 years ago

1.0.0-rc1

6 years ago

1.0.0-rc

6 years ago

0.2.0-rc7

6 years ago

0.2.0-rc6

6 years ago

0.2.0-rc5

6 years ago

0.2.0-rc4

6 years ago

0.2.0-rc2

6 years ago

0.2.0-rc1

6 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago