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

Variable in the where condition how?

Former Member
0 Likes
2,246

Hello Expert Abapers,

how to use a variable in the where condition..

select * from (Var_tab_name)

into itab

where (var1) = 'A'

but i know this expression where (var1) is not allowed, but what is the alternative to this.

Thanks for any suggestions.

BWer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,136

Hi,

<b>Dynamic Conditions</b>

To specify a condition dynamically, use:

SELECT ... WHERE (<itab>) ...

where <itab> is an internal table with line type C and maximum length 72 characters. All of the conditions listed above except for selection tables, can be written into the lines of <itab>. However, you may only use literals, and not the names of data objects. The internal table can also be left empty.

If you only want to specify a part of the condition dynamically, use:

SELECT ... WHERE <cond> AND (<itab>) ...

You cannot link a static and a dynamic condition using OR.

You may only use dynamic conditions in the WHERE clause of the SELECT stateme

example:

data: begin of myselection occurs 0,

line(72),

end of myselection.

data char(1) value 'A'.

myselection-line = 'var1 = char'.

append myselection.

select * from (Var_tab_name)

into itab

where (myselection) .

Message was edited by: Svetlin Rusev

1 REPLY 1
Read only

Former Member
0 Likes
1,137

Hi,

<b>Dynamic Conditions</b>

To specify a condition dynamically, use:

SELECT ... WHERE (<itab>) ...

where <itab> is an internal table with line type C and maximum length 72 characters. All of the conditions listed above except for selection tables, can be written into the lines of <itab>. However, you may only use literals, and not the names of data objects. The internal table can also be left empty.

If you only want to specify a part of the condition dynamically, use:

SELECT ... WHERE <cond> AND (<itab>) ...

You cannot link a static and a dynamic condition using OR.

You may only use dynamic conditions in the WHERE clause of the SELECT stateme

example:

data: begin of myselection occurs 0,

line(72),

end of myselection.

data char(1) value 'A'.

myselection-line = 'var1 = char'.

append myselection.

select * from (Var_tab_name)

into itab

where (myselection) .

Message was edited by: Svetlin Rusev