Usage: usage/addon
setIniFileDirectory(iniFileDirectory: string)
Usage: usage/addon
reloadIniFile()
Usage: usage/addon
loadCryptoLibrary(cryptoLibraryPath: string)
Usage: usage/addon
cancelClient(client: Client, callback?: Function): void | Promise<void>;
Usage: usage/addon
languageIsoToSap(langIsoCode: string): string|Error
Usage: usage/addon
languageSapToIso(langSapCode: string): string|Error
Usage: usage/addon
setLogFilePath(langSapCode: string): string|Error
Usage: usage/client
environment
: Object, exposed at instance and class level
binding
: Object, the Client binding object
id
: Number, the client instance id
_id
: String, "extended" client instance id, with connection handle, pool id (if managed) and "direct"/"managed" attribute
config
: Object, Client configuration, exposing connectionParameters
and clientOptions
objects
connectionHandle
: Number, the client connection handle
alive
: Boolean, set to true
if connection handle is not NULL (connection open)
pool_id
: Number, set to non-zero value in managed clients
connectionInfo
: Object exposing RFC Connection attributes, or Error object if the connection is closed
The direct client is instantiated using connection parameters and optional client options:
constructor(
connectionParameters: RfcConnectionParameters,
clientOptions?: RfcClientOptions )
Another constructor is used by the Connection Pool only. The client instance is already created by Connection Pool and passed to Node.js for Node.js Client instance creation:
constructor(
clientBinding: RfcClientBinding,
clientOptions?: RfcClientOptions )
Example:
const Client = require("node-rfc").Client;
const direct_client = new Client({ dest: "QI3" }, { stateless: true });
The managed client is instantiated using the Connection Pool acquire()
method.
Client API methods accept optional callback argument, for callback invocation pattern. When callback not provided, the Promise is returned.
Sets the directory in which to search for the sapnwrfc.ini
file.
By default the sapnwrfc library searches for the sapnwrfc.ini
in the current working directory of the process. If you want to keep it in a different directory, use this function to tell the sapnwrfc library about the new path.
After you have changed the directory, the NW RFC lib automatically loads the contents of the new sapnwrfc.ini
file from that directory.
setIniPath(pathName: string, callback?: Function): void | Promise<void>
Open connection (direct client only):
connect(callback?: Function): void | Promise<Client> // for backwards compatibility, to be deprecated
open(callback?: Function): void | Promise<Client>
Close connection (direct client only):
close(callback?: Function): void | Promise<void>
Cancel connection:
cancel(callback?: Function): void | Promise<any>
RFC ping the ABAP backend system, returning:
- boolean
true
when successful - boolean
false
and RFC error object, when not - Error object when the connection is already closed
ping(callback?: Function): void | Promise<boolean>
Reset server context, making the next call ABAP stateless, like after opening new connection:
resetServerContext(callback?: Function): void | Promise<void>
Release the client connection back to Pool (managed client only). No arguments required:
release(callback?: Function): void | Promise<void>
Invoke the ABAP RFM rfmName
, providing RFM parameters rfmParams
and optional callOptions:
call(
rfmName: string,
rfmParams: RfcObject,
callOptions: RfcClientOptions = {}
): Promise<RfcObject>
The same as call, used in callback pattern:
invoke(
rfmName: string,
rfmParams: RfcObject,
callback: Function,
callOptions?: object
)
Usage: usage/connection-pool
environment
: Object, exposed at instance and class level
binding
: Object, the Pool binding object
id
: Number, the client instance id
config
: Object, exposing Pool configuration, with connectionParameters
clientOptions
and poolOptions
objects, which are available also as direct getters.
status
: Object, exposing the number of ready
and leased
connections
export interface RfcPoolConfiguration {
connectionParameters: RfcConnectionParameters;
clientOptions?: RfcClientOptions;
poolOptions?: RfcPoolOptions;
}
constructor(poolConfiguration: RfcPoolConfiguration)
Example:
const Pool = require("node-rfc").Pool;
const pool = new Pool({
connectionParameters: { dest: "MME" },
clientOptions: { filter: 2, bcd: "number" },
poolOptions: { low: 0, high: 4 },
});
The result is returned as a promise, unless the optional callback argument provided.
Acquire one or more managed clients, each with own open connection.
acquire(callback?:Function) // Acquire 1 client
acquire(1, callback?:Function) // Acquire 1 client
acquire(3, callback?:Function) // Acquire Array of 3 clients
Managed client:
const Pool = require("node-rfc").Pool;
const pool = new Pool({
connectionParameters: { dest: "QI3},
clientOptions: {stateless: true}, // optional
poolOptions: {low: 0, high: 1} // optional
});
pool.acquire().then(managed_client => {
console.log(managed_client.alive); // true
});
Release connections of one or more managed clients.
release(client1, callback?:Function) // Release 1 client
acquire([client1], callback?:Function) // Release 1 client
acquire([client1, client2], callback?:Function) // Release Array of 2 clients
Cancel connection:
cancel(client, callback?: Function): void | Promise<any>
Check if the number of ready connections is below the pool ready_low
and open new connections if needed.
Optionally, the number connections can be provided, to be used instead of the ready_low
.
pool.ready(); // check if pool ready_low connections are ready
pool.ready(5); // check if 5 connections are ready
pool.ready(5, callback); // check if 5 connections are ready and call the callback when they are
pool.ready(callback, 5); // check if 5 connections are ready and call the callback when they are
release(client1, callback?:Function) // Release 1 client
acquire([client1], callback?:Function) // Release 1 client
acquire([client1, client2], callback?:Function) // Release Array of 2 clients
:exclamation_mark: Internal use only.
Close all open connections, ready and leased. Not synchronized with client or pool mutexes, therefore not supported.
All open connections are anyway closed when Pool destructor called.
closeAll(callback?: Function) // close all ready and leased connections
Usage: usage/server
export type RfcServerConfiguration = {
serverConnection: RfcConnectionParameters;
clientConnection: RfcConnectionParameters;
serverOptions?: RfcServerOptions;
};
export interface RfcServerBinding {
new (serverConfiguration: RfcServerConfiguration): RfcServerBinding;
}
start(callback?: Function): void | Promise<void>
Launch Server instance.
stop(callback?: Function): void | Promise<void>
Stop Server instance.
addFunction(
abapFunctionName: string,
jsFunction: Function,
callback?: Function
): void | Promise<void>
Register JavaScript function as ABAP function on Node.js server.
removeFunction(
abapFunctionName: string,
callback?: Function
): void | Promise<void>
Un-register JavaScript function on Node.js server.
Usage: usage/throughput
status
providing the monitoring statistics:
export interface RfcThroughputStatus {
numberOfCalls: number;
sentBytes: number;
receivedBytes: number;
applicationTime: number;
totalTime: number;
serializationTime: number;
deserializationTime: number;
}
clients
exposing a Set of monitored clients
handle
exposing the internal Throughput object handle, assigned by SAP NWRFC SDK
constructor(client?: Client | Array<Client>)
Assign one or more clients to Throughput instance:
setOnConnection(client: Client | Array<Client>)
Example:
throughput.setOnConnection([client1, client2]);
The opposite of setOnConnection
:
removeFromConnection(client: Client | Array<Client>)
Reset Throughput counters:
reset();
Free the Throughput object, normally not needed becuse called in a destructor:
destroy();