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 statements

Former Member
0 Likes
860

I want to select a set of records from a table in which one of the field entries should start with 'XY-----'. How to do this?

Reagards,

ABAPer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
832

Hi,

Try this:

select field1 field2 field3 field4 from ztable into itab where field like 'XY%'.

Regards,

Vivek

7 REPLIES 7
Read only

Former Member
0 Likes
832

Hi

Select <field list>

into <internal table>

from <table>

where <b>field like 'XY%</b>'.

Regards,

Raj

Read only

Former Member
0 Likes
833

Hi,

Try this:

select field1 field2 field3 field4 from ztable into itab where field like 'XY%'.

Regards,

Vivek

Read only

Former Member
0 Likes
832

CP (Contains Pattern):

The complete string c1 matches the pattern c2 (c1 "matches" c2).

The pattern c2 can contain ordinary characters and wildcards.

'*' stands for any character string and '+' denotes any character.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of c2 in c1. The wildcard character '*' at the beginning of the pattern c2 is ignored when determining the value of SY-FDPOS.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

Examples:

'ABCDE' CP 'CD' is true; SY-FDPOS = 2.

'ABCDE' CP '*CD' is false; SY-FDPOS = 5.

'ABCDE' CP '+CD' is true; SY-FDPOS = 0.

'ABCDE' CP '+CD*' is false; SY-FDPOS = 5.

'ABCDE' CP 'BD*' is true; SY-FDPOS = 1.

The character '#' has a special meaning. It serves as an escape symbol and indicates that the very next character should be compared "exactly".

This allows you to search for:

- characters in upper or lower case

e.g.: c1 CP '#A#b'

- the wildcard characters '*', '+' themselves

e.g.: c1 CP '#' or c1 CP '#+*'

- the escape symbol itself

e.g.: c1 CP '##'

- blanks at the end of c1

e.g.: c1 CP '*# '

If c2 does not contain the wildcard character '*', the shorter field is padded with "soft blanks" to bring it up to the length of the longer field.

Examples:

'ABC' CP 'ABC ' is true,

'ABC ' CP 'ABC' is true,

but

'ABC' CP 'ABC+' is false,

'ABC' CP 'ABC# ' is false,

because a "soft blank" is neither any character ('+') nor a "real" blank ('# ').

The escape symbol does not affect the length of f2 ('A#a#B' still has the length 3).

The comparison is not case-sensitive.

Read only

Former Member
0 Likes
832

Hi,

Plz try out below codings.

select * from BKPF into table t_bkpf where

bukrs = s_bukrs

and BVORG = XY%

use XY and percentage symbol.

Regards

Divakar

Read only

Former Member
0 Likes
832

one option is using LIKE statement.

another option is to use

ranges.

r_matnr-low = 'XY*'.

R_MATNR-OPTION = 'CP'.

R_MATNR-SIGN = 'I'.

APPEND R_MATNR.

SELECT *

FROM <TABLE>

INTO TABLE <ITAB>

WHERE MATNR IN R_MATNR.

Regards,

Ravi

Read only

former_member404244
Active Contributor
0 Likes
832

HI ,

check the following code.

DATA : BEGIN OF itab OCCURS 0,

matnr TYPE matnr,

werks TYPE werks_d,

END OF itab.

SELECT matnr werks FROM marc INTO TABLE itab

WHERE matnr LIKE '15%'.

LOOP AT itab.

WRITE 😕 itab-matnr,itab-werks.

ENDLOOP.

in place of 15% use XY%.

regards,

Nagaraj

Read only

0 Likes
832

Hi,

If you know the case of the value you are looking for, then Vivek M's solution can be used.

I personally don't know a way to transparently select text of unknown upper/lower case from the data dict. tables (vrs 4.7)

Rgrds,

Dan Perecky