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

Select Sql with Begin with value

Former Member
0 Likes
843

Dear Friends

this is my small select statement for search healp


 SELECT DISTINCT VBELN
    FROM  LIKP
    INTO  TABLE IT_VBELN.

but i want to select only begins with 80 values

i tried with as follows


 SELECT DISTINCT VBELN
    FROM  LIKP
    INTO  TABLE IT_VBELN
    WHERE VBELN LIKE '80%'.

but its not working

let me please solve to this matter

Thanks in advanced

Hope my question is clear for you

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
810

I guess it does not work because of the conversion exit on VBELN. Pls. check if the values in VBELN are shorter than 10 characters. If yes, it means there are leading zeros before the '80'

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
810

What is not working? Syntax error? Not returning the expected values?

You don't need DISTINCT, as VBELN is the unique key of LIKP, try to remove this first.

Thomas

Read only

Former Member
0 Likes
810

Hi:

use like

SELECT VBELN

FROM LIKP

INTO corresponding fields of TABLE IT_VBELN

WHERE VBELN LIKE '80%'.

have a look

[Using Like |http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3a1f358411d1829f0000e829fbfe/content.htm]

Read only

JozsefSzikszai
Active Contributor
0 Likes
811

I guess it does not work because of the conversion exit on VBELN. Pls. check if the values in VBELN are shorter than 10 characters. If yes, it means there are leading zeros before the '80'

Read only

0 Likes
810

<off-topic>Hi Eric, good to see you back around here ;)</off-topic>

Read only

0 Likes
810

just jumped in but let me finish:

If the above is correct than you can try the following: if the VBELN numbers are always n character long, than there will be 10 - n zeros before the 80 (for example: 8 long VBELN will look like: 0080...). in this case you can use;

SELECT vbeln
FROM likp
WHERE vbeln LIKE '0080%'.

if the the VBELN numbers can have different lengths, than you have to mention each possibilitiy in the WHERE:

SELECT vbeln
FROM likp
WHERE vbeln LIKE '0080%'
OR vbeln LIKE '00080%'
OR vbeln LIKE '000080%'.

Read only

0 Likes
810

Hi Eric

Thanks I got solution