Application Development and Automation 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: 
Read only

Dynamic Ranges and Dynamic SQL

Former Member
0 Likes
1,546

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
Read only

Former Member
0 Likes
1,155

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
Read only

andreas_mann3
Active Contributor
0 Likes
1,155

hi,

look this threads:

1)

2)

Andreas

Read only

Former Member
0 Likes
1,155

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.

Read only

0 Likes
1,155

hi Sailaja,

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

A.

Read only

0 Likes
1,155

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.

Read only

0 Likes
1,155

Hi,

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

Read only

Former Member
0 Likes
1,156

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.

Read only

0 Likes
1,155

Thanks sailaja,

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