node-r3trans
Node.js wrapper for SAP R3Trans.
Installation
- Download the R3Trans program from SAP Software Download Center
- Create a directory and extract its content
- Create a new PATH enviroment variable named R3TRANS_HOME, pointing at the directory that was created earlier
- Install node-r3trans
npm install node-r3trans
Getting started
Start by importing the library and instantiating an object.
If your transport is in a folder, you can pass the path as a string, like this:
const R3Trans = require('node-r3trans');
const transport = new R3Trans('C:\\R3Trans\\R904009.RST');
If your transport is a buffer:
const R3Trans = require('node-r3trans');
const trBuffer = fs.readFileSync('C:\\R3Trans\\R904009.RST');
const transport = new R3Trans(trBuffer);
Optionally, you can also pass an object containing these values:
const R3Trans = require('node-r3trans');
const transport = new R3Trans('C:\\R3Trans\\R904009.RST', {
r3transHome: 'C:\\R3Trans'
tmpFolderPath: 'C:\\R3Trans'
});
Examples
Validate transport request
const R3Trans = require('node-r3trans');
const transport = new R3Trans('C:\\R3Trans\\R904009.RST');
transport.isValid().then(valid => {
if(valid){
console.log('OK');
}else{
console.log('NOT VALID');
}
}).catch(e => {
console.error(e);
});
List objects of a transport request
const R3Trans = require('node-r3trans');
const transport = new R3Trans('C:\\R3Trans\\R904009.RST');
transport.getTableEntries('TADIR').then(objects => {
console.log(JSON.stringify(objects.map(o => `${o.R3TR} ${o.OBJECT} ${o.OBJ_NAME}`)));
}).catch(e => {
console.error(e);
});
List all table entries of a transport request
const R3Trans = require('node-r3trans');
const transport = new R3Trans('C:\\R3Trans\\R904009.RST');
transport.getTableEntries().then(objects => {
console.log(JSON.stringify(objects.map(o => `${o.R3TR} ${o.OBJECT} ${o.OBJ_NAME}`)));
}).catch(e => {
console.error(e);
});