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

substring in select statement

Former Member
0 Likes
9,795

hi all,

may i know how to have substring in select? i got the error when i define so.

pls advise.

thanks

SELECT SINGLE * FROM mara

WHERE matnr0(1) = fieldvalue0(1).

6 REPLIES 6
Read only

Former Member
0 Likes
4,647

Hi El,

You cannot do that way.

Do this way:

concatenate fieldvalue+0(1) '%' into v_str.

select single * from mara

where matnr like v_str.

Regards,

Ravi

Read only

Former Member
0 Likes
4,647

you cannot use substrings to the left of the WHERE condition , only right hand side you can use substrings

May be you have to select data into one internal table and then use offsets

loop at itab.

if itab-matnr0(1) = fieldvalue0(1).

endloop.

Read only

Former Member
0 Likes
4,647

hi ,

dont use it in that way

first concatenate the field in an variable

then use that variable in u r select query

cheers

Read only

Former Member
0 Likes
4,647

el,

data : v_var(1),

v_per value '%',

v_final(2).

v_var = fieldvalue+0(1).

concatenate v_var v_per into v_final.

SELECT SINGLE * FROM mara

WHERE matnr like v_var.

Pls. mark if useful

Read only

Former Member
0 Likes
4,647

Hi,

You can use offset only at the right side, if the left side value is less tahn the right side value you can use this as

WHERE matnr = name+0(10).

Hope you are clear. Please reward and close the thread if ur problem got solved else get back with queries.

Read only

Former Member
0 Likes
4,647

thanks