‎2017 Sep 06 12:52 PM
Halo,
Below open SQL statement is giving a run time error.
CALL FUNCTION 'CRS_CREATE_WHERE_CONDITION'
TABLES
ti_range = lt_range
to_cond = lt_condition
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
SELECT tab1~fld1
tab1~fld2
tab2~fldA
tab3~fld
FROM tab1
INNER JOIN tab2 ON
tab1~fld4 = tab2~fld6 AND
tab1~fld5 = tab2~fld7
INNER JOIN tab3 ON
tab3~guid = tab2~guid
INTO TABLE lt_result
WHERE (lt_condition).
Now the where condition is a internal table of type mcondition which is of type CHAR 72.
lt_range will be filled up with the list of values as below
tab2 fldA I EQ <value1>
tab2 fldA I EQ <value2>
upon execution of generating dynamic where condition the select statements dumps.
The following error text was processed in the system:
The column name 'FLDA' is ambiguous.
The SELECT clause was specified at runtime in an internal table. The field name 'FLDA' appears in several of the database tables from the FROM clause. Thus the field name is not unique.
The same select query works well in Q systems.I have checked the SP level and versions. everything are on same level. The error occurs in Dev & Prod.
However, if I replace the lt_condition table with the below entries is working fine in dev
( tab2~FLDA="VAL1" OR tab2~FLDA="VAL1 )
I am not sure why it dumps in Dev and Prod. Need some help in understanding the above point. Can I go ahead and replace the lt_condition with the above mentioned condition.
Thanks,
Pavan
‎2017 Sep 06 1:14 PM
The error seems pretty straightforward to me. It suggests that field FLDA only occurs in table tab2 in QA, but in the other systems it also occurs in tab1 or tab3. Compare tables.
And to your second part of your question, yes it is always good practice to specify table names explicitly, especially in dynamic code.
‎2017 Sep 06 1:14 PM
The error seems pretty straightforward to me. It suggests that field FLDA only occurs in table tab2 in QA, but in the other systems it also occurs in tab1 or tab3. Compare tables.
And to your second part of your question, yes it is always good practice to specify table names explicitly, especially in dynamic code.