08-15-2006 10:13 AM
Hi,
I have built a table of ranges and would like to use them in an sql query. Ive had a look but cannot think of a way to get this to work.
I have a table of fieldnames and a table of ranges. Does abap have a way of selecting a element from a table so I can generate the following sql.
select * from table
into some_table
where
'FIELD0' IN range[0] AND
'FIELD1' IN range[1] AND
'FIELD2' IN range[2] AND
'FIELD3' IN range[3] AND
.......
I know how to build dynamic sql thats the easy bit. The hard bit is inserting a reference to a table element dynamically into the sql :S
Any help would be much appretiated,
Thanks,
James
08-15-2006 10:53 AM
hi,
Yes, We can make use of Subroutine pools.
This is from F1 help about dynamic where..
1. This variant is exclusively for use with SELECT. The
internal table itab can only have one field which must be of
type C and not be greater than 72 characters. itab must be
specified in parentheses with no blanks between the
parentheses and the table name. The condition specified in
the internal table itab must have the same form as a
condition in the ABAP/4 source code. The following
restrictions apply:
- You can only use literals as values, not variables.
<b> - The operator IN cannot be used in the form f1 IN itab1. </b>
Regards,
Sailaja.
08-15-2006 10:32 AM
08-15-2006 10:38 AM
hi,
We can have a dynamic where condition.
But even in dynamic where condition, we can not specify IN. So, we can not use dynamic ranges.
Regards,
Sailaja.
08-15-2006 10:42 AM
hi Sailaja,
so use <a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/db999535c111d1829f0000e829fbfe/frameset.htm">subroutine pool</a>
A.
08-15-2006 10:45 AM
Why could you not use IN, in a dynamic sql statement??
Im no abap expert but surely at runtime the dynamic sql is converted into normal open sql, where you can use the in statement.
08-15-2006 10:49 AM
Hi,
I originally thought of generating a subroutine pool, but i thought you could not pass it parameters??
08-15-2006 10:53 AM
hi,
Yes, We can make use of Subroutine pools.
This is from F1 help about dynamic where..
1. This variant is exclusively for use with SELECT. The
internal table itab can only have one field which must be of
type C and not be greater than 72 characters. itab must be
specified in parentheses with no blanks between the
parentheses and the table name. The condition specified in
the internal table itab must have the same form as a
condition in the ABAP/4 source code. The following
restrictions apply:
- You can only use literals as values, not variables.
<b> - The operator IN cannot be used in the form f1 IN itab1. </b>
Regards,
Sailaja.
08-15-2006 11:03 AM
Thanks sailaja,
I was not a having a dig at your knowledge, just did not realise this.