Bindings for the SAP NetWeaver RFC SDK
This module provides bindings to the SAP Netweaver RFC SDK. With it, you will be able to call remote enabled function modules of a SAP system. Opening the connection and function invocations are fully/partially asynchronous operations, which will call a callback function upon completion.
Note: In order to use this module you will have to obtain the SAP NW RFC SDK via http://service.sap.com. For further instructions see OSS note 1025361.
./SAPCAR_3-20002089.EXE -xf NWRFC_8-20004549.SARcd nwrfcsdkcp ./lib/* /usr/libcp ./include/* /usr/inlude
OS X is not supported due to the fact that there is no suitable SAP RFC NW SDK available. The module will compile but fail when trying to lazy-load its dependencies.
npm install sapnwrfc
As with all other Node.js modules, you need to require it:
var sapnwrfc = require'sapnwrfc';
var conParams =ashost: '192.168.0.10'sysid: 'NPL'sysnr: '42'user: 'DEVELOPER'passwd: 'password'client: '001'lang: 'E';
Before you can invoke a remote function, you will have to open a connection to the SAP system.
ConnectionOpen connectionParameters callback errorObject
versionInfo = ConnectionGetVersion
var con = ;conOpenconParamsif errconsole.logerr;return;console.log'sapnwrfc: ' + conGetVersion;;
This is a two step process:
However, you can use the Function object subsequently multiple times for invocations, without having to do another lookup upfront.
functionObject = ConnectionLookup functionModuleName
FunctionInvoke functionParameters callback errorObject result
For the sake of simplicity, the following example will neither pass arguments to the remote function nor receive a result:
var func = conLookup'RFC_PING';funcInvokeconsole.log'Got pong!';;
Assigning primitive types (non-structures, non-tables) is straightforward. You will, however, have to take care that the argument matches the parameter's data type. E.g. if the parameter type is an integer, you may not assign a string value to it.
var params =QUESTION: 'How are you'var func = conLookup'STFC_STRING';funcInvokeparamsif errconsole.logerr;return;console.logresult;;
var params =IMPORTSTRUCT: RFCFLOAT: 3.14159 RFCINT1: 123 RFCTIME: '094500' RFCCHAR4: 'NODE'var func = conLookup'STFC_STRUCTURE';funcInvokeparamsif errconsole.logerr;return;console.logresult;;
var table =I: 1 C: 'A' STR: 'String1'I: 2 C: 'B' STR: 'String2'I: 3 C: 'C' STR: 'String3';var params =IMPORT_TAB: tablevar func = conLookup'STFC_DEEP_TABLE';funcInvokeparamsif errconsole.logerr;return;for var i = 0; i < resultEXPORT_TABlength; i++console.log'Row ' + i + 1 + ':';console.logresultEXPORT_TABi;console.logresultRESPTEXT;;
(The MIT License)
Copyright (c) 2011-2012 Joachim Dorner
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.