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 question

Former Member
0 Likes
1,143

Hi All,

I would like to ask on select statement.

If I want to filter the data selection where the value is partly similar in 1 of the field, may I know how to write that?

for example in field A, I need to extract data where the position 4 with length 4 of the value in this field is AAXY. Actually the complete value i want to extract is

AAXY8530 , AAXY4532 and AAXY5643. Since only the first 4 letter the same, so may i know how to write it in select statement. i cannot use 'like' as i am afraid if AAXY not starts at position 4 also being extracted.

field A

012AAXY8530ZZZ

013AAXY4532AAA

014AAXY5643QQQ

select fieldA fieldB fieldC into table itab from table where fieldA

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,106

hi,

first get all the records and then use string operators

or use if conition with CO or CS to ur requirement inside a loop.

Thanks

Shiva

10 REPLIES 10
Read only

Former Member
0 Likes
1,107

hi,

first get all the records and then use string operators

or use if conition with CO or CS to ur requirement inside a loop.

Thanks

Shiva

Read only

athavanraja
Active Contributor
0 Likes
1,106

select fieldA fieldB fieldC into table itab from table where fieldA like '%AAXY% .

This will filter on fieldA if it contains 'AAXY' anywhere within fieldA value.

Raja

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,106

Hi,

select fieldA fieldB fieldC into table itab from table where fieldA

like '___AAXY_______'.

For each character put underscore.So three underscores before AAXY and 7 underscores after AAXY.

Kindly reward points by clicking the star on the left of reply,if it helps.

Read only

Former Member
0 Likes
1,106

First concatenate the '%' with the content u want.

For example u want some thing like 'AAXY', so u have to concatenate varible with 'AA' and '%' symbol.

Example:

CONCATENATE 'AA' '%' INTO l_v_field.

Then next u can use like in the where clause of ur select statment.

SELECT matnr matid zz08ol_at_kz zz08od_ers_dat AS zz08ol_ers_dat

FROM z08ol_material_1

INTO CORRESPONDING FIELDS OF TABLE p_it_agg

WHERE zz08ol_gruppennr LIKE l_v_field.

U can use something like the above.

Let me know if u face any problem.

Regards

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,106

Use LIKE '____AAXY' in your select

- sap online help -

f [NOT] LIKE g

Effect

The condition is met for a table entry if the statement "f (does not) equal the pattern in g" is true for the values of f and g. f must always be a field descriptor, and g an ABAP field. If f has the value NULL, then the result of the check for the statement is unknown. Within a pattern, there are two special characters:

'_' (underscore) stands for any single character.

'%' (percentage sign) stands for any sequence of characters, including an empty string.

Regards

Read only

Former Member
0 Likes
1,106

Hi All,

I use the combination of underscore and %.

like '___AAXY%'

i need to use underscore as the extraction position is fixed at position 4. is that correct?

thanks

Read only

0 Likes
1,106

Hi,

It is correct.Check my post.

Check here for further information.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/where.htm

Kindly reward points by clicking the star on the left of reply,if it helps.Close this thread by clicking blue star agaisnt the reply which solved your problem.If you solved on your own,click solved on my own.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,106

yes!

Read only

Former Member
0 Likes
1,106

you have to put 4' _' for specifying you are matching with 5th onwards character.

'_' means a single char and '%' means any no of character match.

regards

shiba dutta

Read only

Former Member
0 Likes
1,106

Hi All,

thanks for helping. i will reward point accordingly.