Currently in Beta state.
Node-Red (http://nodered.org) nodes for communicating with SAP via node-rfc (https://github.com/SAP/node-rfc).
There are three nodes included:
This package is a wrapper for node-rfc, which relies on the SAP NW RFC SDK. Make sure you have a working install of node-rfc before continuing.
Run the following command after you have done a global install of Node-RED & node-rfc
npm install -g node-red-contrib-saprfc
You will need the connection parameters for your SAP system, which can usually be obtained from your SAP GUI Logon.
These nodes will appear in their own "sapRFC" catagory on the Node-Red pallet.
After adding the first node, you have to configure the connection to your SAP system.
This node sets up a node-rfc connection pool and an async queue which limits the amount of simultaneous connections to 4. In testing, there does not seem to be a performance gain for using more than 4 connections. The queue is processed first in first out.
The field list node is the easiest to use. It is a wrapper around RFC_READ_TABLE - you only need to enter the table name for which you would like to get the list of fields and wire it to a debug node to inspect the output.
Use the condense flag to convert the standard output from the RFC to a simple object where each property is the technical name of the table and it's value is the display name.
The read table node is a wrapper around RFC_READ_TABLE. It converts the result into a native Array of JS Objects, each representing one result row.
To use the node, enter the table name and click the Fetch Fields button to get all the fields of the table. Then select the fields you wish to include in the output. You will also want to use a function node pass a structure with additional parameters, such as ROWCOUNT, OPTIONS, etc. Here is an example function node which builds the import structure:
var date = new Date();
msg.payload = {
OPTIONS: ["ERSDA >= '"+date.getFullYear()+""+("0" + (date.getMonth() - 2)).slice(-2)+""+("0" + date.getDate()).slice(-2)+"'"],
ROWCOUNT: 10
}
return msg;
You could also specify the table and field list in the input payload instead of configuring them in the GUI:
msg.payload = {
QUERY_TABLE: "MARA",
FIELDS: ["MATNR","ERSDA","ERNAM"],
OPTIONS: ["ERSDA >= '"+date.getFullYear()+""+("0" + (date.getMonth() - 2)).slice(-2)+""+("0" + date.getDate()).slice(-2)+"'"],
ROWCOUNT: 10
}
The call node allows you to call any SAP RFC you would like. Just like the read table node, you must use a function node to build and pass the import parameters.
This example shows how you would build an import structure for BAPI_USER_CHANGE to update a user's email address:
msg.payload = {
USERNAME: "SOME_SAP_USER",
ADDRESS: {
E_MAIL: "myemail@company.com"
},
ADDRESSX: {
E_MAIL: "X"
}
}
return msg;
Currently the call node does not offer a way to use BAPI_TRANSACTION_COMMIT
or BAPI_TRANSACTION_ROLLBACK
. Major improvements need to be made to be able to accomodate commit and rollback.
If an error is encountered by any RFC, an error is throw. In order to see the full content of this error, drag a catch node into your flow and attach it to a debug node. The debug node must be configured to output msg.sapError.
Use these programs at your own risk.
Paul Wieland, https://github.com/PaulWieland
Submit any issues here on github, or ping me @Paul W on the node-red slack channel.