Skip to Content

Open SQL Dynamic Where condition Error


Below open SQL statement is giving a run time error.

      ti_range      = lt_range
      to_cond       = lt_condition
      invalid_input = 1
      OTHERS        = 2.

  SELECT tab1~fld1
  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.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Sep 06, 2017 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded