Showing results for 
Search instead for 
Did you mean: 

SAP CAP CQL - Join a JS array with Database (like For All Entries in ABAP)


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 = => line.BUKRS);
const t_belnr = => 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 )
Bulent Balci

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

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.