Closed MartinStenzig closed 4 years ago
@MartinStenzigRiz I believe you can call BAPI_TRANSACTION_COMMIT
with node-rfc
.
See this example where I update the name and description of a cost center:
'use strict';
const rfcClient = require('node-rfc').Client;
// ABAP system RFC connection parameters
const abapSystem = {
user: 'USER',
passwd: 'SUPERSECRET',
ashost: '10.x.x.x',
sysnr: '27',
client: '100',
lang: 'EN',
};
// create new client
const client = new rfcClient(abapSystem);
// echo SAP NW RFC SDK and nodejs/RFC binding version
console.log('Client version: ', client.version);
// open connection
client.connect(function(err) {
if (err) {
// check for login/connection errors
return console.error('could not connect to server', err);
}
// invoke ABAP function module, passing structure and table parameters
// ABAP structure
const structure = {
CONTROLLINGAREA: "1000",
TESTRUN: "",
LANGUAGE:{
LANGU:"E",
LANGU_ISO:"EN"
},
COSTCENTERLIST:[
{
COSTCENTER: "ABCA003341",
DESCRIPT: "TEST123",
NAME: "TEST456"
}]
};
client.invoke('BAPI_COSTCENTER_CHANGEMULTIPLE', structure, function(err,res){
client.invoke('BAPI_TRANSACTION_COMMIT',{}, function(err,res){
console.log('committed?');
console.log(err);
console.log(res);
});
if (err) {
return console.error('Error invoking BAPI_COSTCENTER_CHANGEMULTIPLE:', err);
}
console.log('update cc res:', res);
});
EDIT: That being said, I do not know how to use BAPI_TRANSACTION_COMMIT
with a connection pool. @bsrdjan is that possible?
With or without pool is the same, pool only provides connections.
There are more possibilities for sequential calls, like callbacks, as in @PaulWieland example, async/await or promises, like here.
If more questions, please reopen.
I really like the library, but the limitation of not being able to perform multiple RFC calls on one connection is very much limiting the application. Any chance you are planning to add that in?
The examples I have are the following: