环境要求:需要安装python、安装c++、nwrfcsdk
async function callRFC(functionName, inputParams) {
//省略datasource
const Pool = require("node-rfc").Pool;
const pool = new Pool({
connectionParameters: {
user: datasource.sapUser,
passwd: datasource.sapPasswd,
ashost: datasource.ashost,
sysnr: datasource.sapSysnr,
client: datasource.sapClient,
lang: 'ZH',
}, clientOptions: { stateless: true }, poolOptions: { low: 0, high: 5 }
});
return new Promise(async (resolve, reject) => {
try {
const client = await pool.acquire();
client.call(functionName, inputParams, {
timeout: 15,
}).then(async result => {
resolve(result);
await pool.release(client);
}).catch(async error => {
await pool.release(client);
reject(error);
})
} catch (error) {
console.error(error)
reject(error);
await pool.closeAll();
}
});
}
export { callRFC };