Hi everyone,
I'm unable to find a way to loop over a dynamic table with a dynamic where clause.
Here's what I'm trying to do:
1. Create a data reference as a sorted table of a DSO line type
2. Read data into that reference
3. create a dynamic where clause and put it into a string.
3. Trying to loop across it using that string in a where clause, that's where I get a CX_SY_ITAB_DYN_LOOP
I checked the string, the where-clause looks OK and all fields in the where clause are present in the data. Odd thing is, if I change the where-string to something random (such as "1=1"), it will still throw the same exception, but if I replace the dynamic table by a static one, the loop will run.
I didn't find anything in the documentation of LOOP saying that one couldn't loop across a dynamic table with a dynamic where clause...
For the sake of completeness, here's the relevant pieces of code (yes, it's the MM condition table):
<lp_matp_cond> TYPE SORTED TABLE
<lfs_data> TYPE ANY
I_MATP_COND TYPE REF TO DATA
CREATE DATA I_MATP_COND TYPE SORTED TABLE OF (dso_line_type) WITH UNIQUE DEFAULT KEY.
ASSIGN I_MATP_COND->* TO <lp_matp_cond>.
lv_matp_where = 'SOURSYSTEM=' && I_SOURSYSTEM && ' AND VENDOR=' && I_VENDOR &&
' AND MATERIAL=' && I_MATERIAL && ' AND PURCH_ORG=' && I_PURCH_ORG &&
' AND KAPPL=M AND INFO_TYPE=2'.
LOOP AT <lp_matp_cond> ASSIGNING <lfs_data> WHERE (lv_matp_where).
Your help is very much appreciated!