‎2008 Mar 28 8:43 AM
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.
‎2008 Mar 28 8:55 AM
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
‎2008 Mar 28 8:50 AM
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
‎2008 Mar 28 8:55 AM
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
‎2008 Mar 28 8:59 AM
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.
‎2008 Mar 28 9:23 AM
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.
‎2008 Mar 28 10:06 AM
*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.