Skip to Content
author's profile photo
Former Member

DYNAMIC VARIABLE IN SELECT QUERY

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Aug 22, 2007 at 09:46 AM

    You need to do this

    concatenate '%'

    wa_belnr

    '%'

    into w_field

    then use w_field on your select.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Aug 22, 2007 at 09:48 AM

    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).

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2007 at 09:51 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2007 at 09:59 AM

    Hi,

    use

    concatenate '%'

    wa_belnr

    '%'

    into lv_BELNR

    select * from cdhdr where

    objectclass LIKE lv_BELNR

    regards

    Add comment
    10|10000 characters needed characters exceeded