Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Ranges and Dynamic SQL

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

7 REPLIES 7

andreas_mann3
Active Contributor
0 Kudos

hi,

look this threads:

1)

2)

Andreas

Former Member
0 Kudos

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.

0 Kudos

hi Sailaja,

so use <a href="http://help.sap.com/saphelp_47x200/helpdata/en/9f/db999535c111d1829f0000e829fbfe/frameset.htm">subroutine pool</a>

A.

0 Kudos

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.

0 Kudos

Hi,

I originally thought of generating a subroutine pool, but i thought you could not pass it parameters??

Former Member
0 Kudos

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.

0 Kudos

Thanks sailaja,

I was not a having a dig at your knowledge, just did not realise this.