2022 Oct 26 10:43 AM
Hello Experts,
Would it be possible to write a hierarchy select statement (in ABAP / CDS / CTE) with dynamic start where-conditions?
below is a sample code
SELECT FROM HIERARCHY( SOURCE demo_cds_parent_child_source
CHILD TO PARENT ASSOCIATION _relat
START WHERE id = 'A'
OR id = 'D'
SIBLINGS ORDER BY id
MULTIPLE PARENTS ALLOWED)
FIELDS id,
parent
INTO TABLE @DATA(asql_result).
Below is the code I'm expecting. But it won't work and shows a syntax error like 'A Boolean expression was expected'
. DATA(lv_where) = | ID = 'A' OR ID = 'D' |.
SELECT FROM HIERARCHY( SOURCE demo_cds_parent_child_source
CHILD TO PARENT ASSOCIATION _relat
START WHERE(lv_where)
SIBLINGS ORDER BY id
MULTIPLE PARENTS ALLOWED )
FIELDS id,
parent
INTO TABLE @DATA(asql_result).
Thank you.
Best Regards,
Bhargava
2022 Oct 26 12:55 PM
Missing spaces + missing @ ? (NB: parentheses are optional)
WHERE @lv_where
2022 Oct 27 9:02 AM
Based on the syntax diagram of START WHERE and testing, it seems that dynamically specified relational expressions cannot be used here.
2022 Oct 27 6:46 PM
Lena is right, only fixed values are permitted, not dynamic values!