Application Development 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: 

Special Characters in SELECT Query

Former Member
0 Kudos

What is the right way of using Special character '*' in SELECT Query.

Say..

SELECT PSPID FROM PROJ

INTO TABLE IT_P_PROJ

WHERE PSPID EQ P_PROJ

.

In this P_PROJ is SS*. No value is populating for this . Pls suggest where am I going wrong?

8 REPLIES 8

suresh_datti
Active Contributor
0 Kudos

use the pattern option..

ie


P_proj = 'SS%'.
SELECT PSPID FROM PROJ
INTO TABLE IT_P_PROJ
WHERE PSPID like P_PROJ.

Regards,

Suresh Datti

Former Member
0 Kudos

HI Mohankumar,

replace '*' with '%'

Former Member
0 Kudos

hi Mohan,

I guess Select statement will not take SS* that you have passed to a field. So it is wrong way of Usage. So use <b>'%' </b>instead of '*'.

Regards,

Santosh

Former Member
0 Kudos

hi

chk this out

Field descriptor

Variants:

1. f

2. dbtab~field

3. tabalias~field

Effect

Used in the SELECT, OPEN CURSOR, UPDATE and DELETE commands to uniquely identify columns (fields) of database tables and views specified in FROM clauses.

Variant 1

f

Effect

Identifies the field f of a database table or view specified in the FROM clause. The name f may only occur once in all database tables or views, that is, it must be unique. You use this variant particularly when there is only one table specified in the FROM clause. If the uniqueness of the field cannot be guaranteed, you must use variant 2 or 3.

Example

Output a list of all customers whose names begin with 'A':

DATA: WA_SCUSTOM TYPE SCUSTOM.

<b>SELECT * FROM SCUSTOM INTO WA_SCUSTOM WHERE NAME LIKE 'A%'.

WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME.

ENDSELECT</b>.

Variant 2

dbtab~field

Effect

Identifies field f in the database table or view dbtab specified in the FROM clause. The combination dbtab~field must be unique. You can use this variant if table dbtab only appears once in the FROM clause. If this uniqueness cannot be assured, you must use variant 3.

Example

Output a list of all customers whose names begin with 'A':

DATA: WA_SCUSTOM TYPE SCUSTOM.

<b>SELECT * FROM SCUSTOM INTO WA_SCUSTOM

WHERE SCUSTOM~NAME LIKE 'A%'.

WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME.

ENDSELECT.</b>

Variant 3,,tabalias~field

Effect

Identifies field f in the table or view with the alias name tabalias specified in the FROM clause.

Example

Output a list of all customers whose name begins with 'A':

DATA: WA_SCUSTOM TYPE SCUSTOM.

SELECT * FROM SCUSTOM AS T INTO WA_SCUSTOM WHERE T~NAME LIKE 'A%'.

WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME.

ENDSELECT.

Additional help

Former Member
0 Kudos

This P_proj is coming form Selection Screen .. by using Parameters stmt.

0 Kudos

then pass it to a variable before the select ie


data w_proj like p_proj.
w_proj = p_proj.
replace '*' with '%' in w_proj.
SELECT PSPID FROM PROJ
INTO TABLE IT_P_PROJ
WHERE PSPID like W_PROJ

Reagrds,

Suresh Datti

Former Member
0 Kudos

Hi mohankumar,

1. use LIKE (instead of EQ)

use % (instead of *)

2. just copy paste to get a taste of it.

3.

report abc.

parameters : bukrs like t001-bukrs default '1%'.

data : itab like table of t001 with header line.

select * from t001

into table itab

where bukrs like bukrs.

break-point.

regards,

amit m.

Former Member
0 Kudos

If you are going for fetching records where PSPID value you are looking for values starting with SS then

give "SS%" -> This fetches all the records where the values are starting with SS.

if you are looking for only 1 character after this SS, give "SS_" -> fetches all 3 character words starting with SS.

regards

srikanth