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 query

Former Member
0 Likes
713

Hi experts,

Now im encountered with one big issue.

Ok now my scenario is based on user inputs i need to display some values to table control from data base.

Based on user inputs means if user enters a* means i need to displays all data's that are starting with a.

For that i tried with this following select query.

select * from sflight into corresponding fields of table itab_sflight where carrid like 'a%' .

The above code is working fine. But my problem is the user input is stored in one variable. For example the user input now stored in variable 'Temp'.

Now how can i write the select query.

select * from sflight into corresponding fields of table itab_sflight where carrid like temp% .

every body knows the above select quey is not working. So i want to replace the above variable 'temp' to data 'a'.

Hope i explained clearly. Other wise i'll come again.

Thanks and points will rewarded for all responces.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

Hi

The second statement wont accept since the special chars are mentioned which are not allowed

the % should within the quote or move it to a variable

check the below code

parameter: temp type sflight-carrid.

data : itab_sflight type standard table of sflight.

concatenate temp '%' into temp.

select * from sflight into corresponding fields of table itab_sflight

up to 10 rows

where carrid like temp.

regards

Shiva

5 REPLIES 5
Read only

Former Member
0 Likes
696

Hi

Do the following:

parameter: p_string type string.

data: gv_string type string.

start-of-selection.

gv_string = p_string+1(1) "To take only 1st position

concatenate gv_string '%' into gv_string.

select * from sflight into corresponding fields of table itab_sflight where carrid eq gv_string.

Thanks

Vijay

Read only

Former Member
0 Likes
697

Hi

The second statement wont accept since the special chars are mentioned which are not allowed

the % should within the quote or move it to a variable

check the below code

parameter: temp type sflight-carrid.

data : itab_sflight type standard table of sflight.

concatenate temp '%' into temp.

select * from sflight into corresponding fields of table itab_sflight

up to 10 rows

where carrid like temp.

regards

Shiva

Read only

Former Member
0 Likes
696

hi do like this...

data: begin of itab occurs 0,

matnr like mara-matnr,

end of itab.

select matnr from mara into table itab up to 10 rows where matnr like '0%'.

loop at itab where matnr ca '0'.

write:/ itab-matnr.

endloop.

regards,

venkat.

Read only

Former Member
0 Likes
696

Hi Vijay,

Your answer is almost correct. You gave the answer like 'carrid eq gv_string'. But it should be 'carrid like gv_string'.

Siva Solves the issue.

Anyway thanks experts.

Read only

Former Member
0 Likes
696

*p_carr is the selection parameter.

  • declare a dummy variable to hold the *, here tmp2 is used

PARAMETER : p_carr TYPE sflight-carrid.

tmp = p_carr.

SPLIT tmp AT '' INTO tmp tmp2. " here the characters before '' is moved to tmp.

CONCATENATE tmp '%' INTO tmp.

SELECT *

FROM sflight

INTO TABLE it_sflight

WHERE carrid LIKE tmp.