Created
September 13, 2024 09:02
-
-
Save anggakharisma/c9248edc2784cc0b2f0580c385edce4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rfc = require('node-rfc'); | |
module.exports = async (query, skip, count, cb) => { | |
try { | |
const abapSystem = { | |
user: process.env['SAP_USER'], | |
passwd: process.env['SAP_PASSWD'], | |
ashost: process.env['SAP_ASHOST'], | |
sysnr: process.env['SAP_SYSNR'], | |
client: process.env['SAP_CLIENT'] | |
}; | |
console.log(abapSystem); | |
const client = new rfc.Client(abapSystem); | |
await client.connect(async (err)=>{ | |
if (err) { | |
throw err; | |
} | |
let params = { | |
QUERY_TABLE: query | |
}; | |
if(skip){ | |
params.ROWSKIPS = parseInt(skip); | |
} | |
if(count){ | |
params.ROWCOUNT = parseInt(count); | |
} | |
await client.invoke('RFC_READ_TABLE', params, (err, res) => { | |
if (err) { | |
throw err; | |
} | |
// console.log('Result RFC_READ_TABLE:', res); | |
cb(res.FIELD, res.DATA); | |
}); | |
}); | |
} catch (error) { | |
return console.error('Error invoking RFC_READ_TABLE:', error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment