Reputation: 545
I need to fetch table data from a SAP system with node-rfc library. Need help where I can pass table name or parameters so that I can get proper data to build Node.js API.
Do you have any idea what is wrong? I'm out of ideas :(
const noderfc = require("node-rfc");
const client = new noderfc.Client({ dest: "MME" });
(async () => {
try {
// unlike the connection acquired from pool,
// the direct client connection is initially closed
await client.open();
// invoke ABAP function module, passing structure and table parameters
// ABAP structure
const abap_structure = {
RFCINT4: 345,
RFCFLOAT: 1.23456789,
RFCCHAR4: "ABCD",
RFCDATE: "20180625", // ABAP date format
// or RFCDATE: new Date('2018-06-25'), // as JavaScript Date object, with clientOption "date"
};
// ABAP table
let abap_table = [abap_structure];
const result = await client.call("STFC_STRUCTURE", {
IMPORTSTRUCT: abap_structure,
RFCTABLE: abap_table,
});
// check the result
console.log(result);
GetDataTableFromRFCTable(result.RFCTABLE);
} catch (err) {
// connection and invocation errors
console.error(err);
}
})();
// Assuming DataTable, GetDataTableFromRFCTable, etc., are defined elsewhere
function GetDataTableFromRFCTable(lrfcTable) {
console.log("lrfcTable", lrfcTable);
}
Response I am getting like.
{
ECHOSTRUCT: {
RFCFLOAT: 1.23456789,
RFCCHAR1: '',
RFCINT2: 0,
RFCINT1: 0,
RFCCHAR4: 'ABCD',
RFCINT4: 345,
RFCHEX3: <Buffer 00 00 00>,
RFCCHAR2: '',
RFCTIME: '000000',
RFCDATE: '20180625',
RFCDATA1: '',
RFCDATA2: ''
},
RESPTEXT: 'SAP R/3 Rel. 750 Sysid: QP3 Date: 20240105 Time: 130159',
IMPORTSTRUCT: {
RFCFLOAT: 1.23456789,
RFCCHAR1: '',
RFCINT2: 0,
RFCINT1: 0,
RFCCHAR4: 'ABCD',
RFCINT4: 345,
RFCHEX3: <Buffer 00 00 00>,
RFCCHAR2: '',
RFCTIME: '000000',
RFCDATE: '20180625',
RFCDATA1: '',
RFCDATA2: ''
},
RFCTABLE: [
{
RFCFLOAT: 1.23456789,
RFCCHAR1: '',
RFCINT2: 0,
RFCINT1: 0,
RFCCHAR4: 'ABCD',
RFCINT4: 345,
RFCHEX3: <Buffer 00 00 00>,
RFCCHAR2: '',
RFCTIME: '000000',
RFCDATE: '20180625',
RFCDATA1: '',
RFCDATA2: ''
},
{
RFCFLOAT: 2.23456789,
RFCCHAR1: 'X',
RFCINT2: 1,
RFCINT1: 1,
RFCCHAR4: 'QP3',
RFCINT4: 346,
RFCHEX3: <Buffer f1 f2 f3>,
RFCCHAR2: 'YZ',
RFCTIME: '130159',
RFCDATE: '20240105',
RFCDATA1: '',
RFCDATA2: ''
}
]
}
Upvotes: 0
Views: 221