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

extracting data from database table containg perticular string.

Former Member
0 Likes
1,120

hi every body ,

can any body provide me a solution for extracting the OT01 data from kna1 table where the OT01 ends with the string 'town' .

exe : the O/P should be

midTOWN

newTOWN

:

:

:

there is one more query i am not able to execute the following statement .......why?

select ORT01 from KNA1 where ORT01 CS 'TOWN'.

write:/ kna1-ort01.

endselect.

it is showing a syntax error.......

Thank You.

1 ACCEPTED SOLUTION
Read only

BH2408
Active Contributor
0 Likes
1,092

Hi ,

try this one.

select ORT01 from KNA1 where ORT01 CS '%TOWN'.

write:/ kna1-ort01.

endselect.

Regards,

Bharani

9 REPLIES 9
Read only

Former Member
0 Likes
1,092

Hi Tippu,

You need to create a range for the where clause and assign that value CS 'Town'.

and then execute that range from your query this will fix your problem

Thanks,

Chdianand

Read only

0 Likes
1,092

can you please hint me more from a coding side ....

Read only

BH2408
Active Contributor
0 Likes
1,093

Hi ,

try this one.

select ORT01 from KNA1 where ORT01 CS '%TOWN'.

write:/ kna1-ort01.

endselect.

Regards,

Bharani

Read only

Former Member
0 Likes
1,092

when i used where CS .....

it showed a syntax error

Read only

Former Member
0 Likes
1,092

It's "LIKE" not "CS".

and you will probably run into problems with case sensitivity.

Rob

Edited by: Rob Burbank on Oct 21, 2008 1:46 PM

Read only

BH2408
Active Contributor
0 Likes
1,092

Hi,

select ORT01 from KNA1 where ORT01 like '%TOWN'.

write:/ kna1-ort01.

endselect.

Regards,

Bharani

Edited by: SeethaRamaiah Bharani on Oct 21, 2008 7:47 PM

Read only

Former Member
0 Likes
1,092

Hi Tippu,

Your select statement consists of CS whcih may not be a valid comparision operator because of which error is displayed have look of this..

data itab like kna1 occurs 0 with header line.

parameters: s_town like kna1-ORT01.

select ORT01 from KNA1 into table itab where ORT01 = s_town.

Fetch the city and concatenate with TOWN your issue will be sloved.

Cheers!!

Balu

Edited by: Balu CH on Oct 21, 2008 11:13 PM

Read only

0 Likes
1,092

i was meant the existing city in kna1 which ends with town.

like midtown , newtown ....etc.

Read only

Former Member
0 Likes
1,092

Hi Tippu,

Below is the code for your requirement.


RANGES: R_ORT01 FOR KNA1-ORT01.

    R_ORT01 -SIGN = 'I'.
    R_ORT01 -OPTION = CS'.
    R_ORT01 -LOW = '*TOWN'.
    append R_ORT01 .

select ORT01 from KNA1 where ORT01 IN R_ORT01 .
write:/ kna1-ort01.
endselect.

Thanks,

Chidanand