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 VARIABLE IN SELECT QUERY

Former Member
0 Kudos

hi all,

i m selecting a belnr from one table and want to fire another query on different table wherein this belnr falls somewhere in middle of the whole field.

eg: wa-belnr = 4000

select * from cdhdr where

objectclass = '%wa-belnr%.

i want to select records which contains this belnr.

but %wa-belnr% doesnt work.

pls suggest if theres any solution.

4 REPLIES 4

Former Member
0 Kudos

You need to do this

concatenate '%'

wa_belnr

'%'

into w_field

then use w_field on your select.

Former Member
0 Kudos

HI

for ex if belnr is the 10 characters in middle of field starting from 6th character

u can use

select * from cdhdr where objectclass = field+5(10).

0 Kudos

Hi,

select * from cdhdr where

objectclass = '%wa-belnr%.

In the above query use LIKE instead of '='.

Also instead of %wa-belnr% Use like this

<b>DATA: str type string.

concatenate '%' wa_belnr '%' into str.

select * from cdhdr where

objectclass LIKE str.</b>

Regards,

Sesh

dev_parbutteea
Active Contributor
0 Kudos

Hi,

use

concatenate '%'

wa_belnr

'%'

into lv_BELNR

select * from cdhdr where

objectclass LIKE lv_BELNR

regards