on 12-19-2023 11:05 AM
Hi , I'm coding something on SAP CAP on NodeJS , I've a question about a CQL query :
imagine I have a JS array with 2 fields, something like below :
const t_header = [
{bukrs: "1000", belnr: "00001"},
{bukrs: "2000", belnr: "00001"},
{bukrs: "2000", belnr: "00002"}
]
I need to query another db (items) table corresponding to the entries in JS array above,
So I've taken out "bukrs" field as a separate array and "belnr" field as another separate array and then used them with "in" operator as below :
const t_bukrs = t_header.map(line => line.BUKRS);
const t_belnr = t_header.map(line => line.BELNR);
const t_item =
await SELECT.from(BSEG).where({BUKRS: { in: t_bukrs}, BELNR: { in: t_belnr}});
But it's resulting some unwanted entries,
for example I don't need an entry with fields : bukrs: "1000" and belnr: "00002" in above example.
How can I properly code it ?
( P.S. it's just same thing what "FOR ALL ENTRIES" statement does in classical ABAP )
Thanks
Bulent Balci
Hi bulent-balci
One way is you can create a dynamic select query looping through all records using 'and' (where bukrs = '1111' and belnr = '123456789' Or where bukrs = '2111' and belnr = '223456789' .)
Do post if you find a better way, will be great to know.
Thanks
Kanika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.