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: 

Select Statement

Former Member
0 Kudos
112

Hi,

I am facing problem in the select statement ,

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE PERNR = IPERNR

AND CUNAME CS VAR1.

I am facing problem in the select statement in the selection of cuname, I want to fetch cuname from the ztable if it contains the string var1 contents.

Thanks in Advance,

IFF

8 REPLIES 8

Former Member
0 Kudos
84

Hello,

The VAR1 should<b> XYZ* or XYZ%</b>

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE PERNR = IPERNR

<b>AND CUNAME LIKE VAR1.</b>

If useful reward.

Vasanth

Former Member
0 Kudos
84

Check this way ...

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE PERNR = IPERNR
AND CUNAME CS %VAR1%.

0 Kudos
84

Hi Santosh,

I am getting as

CS is not a valid comparison operator.

0 Kudos
84

Hi ,

Use the following statement

concatenate '%' var '%' into v_string.

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE PERNR = IPERNR

AND CUNAME like v_string.

Regards

Arun

jayanthi_jayaraman
Active Contributor
0 Kudos
84

Hi,

Concatenate '%' var1 '%' into var1.

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE PERNR = IPERNR

AND CUNAME like VAR1.

0 Kudos
84

Do this way ...

concatenate '%' var1 '%' into var2.

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE PERNR = IPERNR
AND CUNAME like var2.

Regards,

Santosh

0 Kudos
84

use this demo code -

tables zgill_main.

data: begin of itab occurs 0.

include structure zgill_main.

data end of itab.

select * from zgill_main into table itab where name like '%AM%'.

loop at itab.

write:/ itab.

endloop.

Former Member
0 Kudos
84

try jayanthi code... it is correct.

use like operator

add % to the first and end of the string

as

concatenate '%' var1 '%' into var2.

SELECT * FROM ZTABLE INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE PERNR = IPERNR

AND CUNAME like VAR2.