‎2009 Jan 19 2:24 AM
Hi All,
From To Temp
101 200 1111
201 300 2222
301 400 3333
401 500 4444
501 600 5555
From, To & Temp are three Fields.
Consider the above table, if i enter input as 150, need to pick 1111.
If the input is inbetween of From & To values means I want to pick the exact
Data from temp field.
Thanks
Hema
Edited by: hema prabakaran on Jan 19, 2009 7:54 AM
Edited by: hema prabakaran on Jan 19, 2009 8:30 AM
‎2009 Jan 19 3:44 AM
Hi,
If it is ur R/3 database table than u can directly select using following query
Select temp from <DB_table>
into <variable> where
from <= <input_variable_value> and to >= <input_variable_value>.
and if u have selected all the values in some internal table than
Loop at <internal Table> where from <= <input_variable_value> and to >= <input_variable_value>.
<variable> = <work area>-temp.
exit.
endloop.
‎2009 Jan 19 3:27 AM
1. loop your internal table.
2. Check whether your input is less than To in internal table using conditional statements.
3. If yes pick the temp value and exit the loop..
4. Else repeat the process.
Giving exact code will be spoonfeeding
‎2009 Jan 19 3:29 AM
Hi Hema.
As your table layout you can select as follow sql query
table is named ur_table
From To Temp
101 200 1111
201 300 2222
301 400 3333
401 500 4444
501 600 5555
SELECT temp INTO lv_temp
FROM ur_table
WHERE from >= v_input_value
AND to <= v_input_value.
Hope it helps.
Sayan
Edited by: Sayan Churatao on Jan 19, 2009 4:30 AM
Edited by: Sayan Churatao on Jan 19, 2009 4:31 AM
‎2009 Jan 19 3:41 AM
Hi,
use this for your SELECT statement
SELECT from to temp
FROM <table>
INTO TABLE i_tab
WHERE from <= value
AND to >= value.
regards,
Peter
‎2009 Jan 19 3:44 AM
Hi,
If it is ur R/3 database table than u can directly select using following query
Select temp from <DB_table>
into <variable> where
from <= <input_variable_value> and to >= <input_variable_value>.
and if u have selected all the values in some internal table than
Loop at <internal Table> where from <= <input_variable_value> and to >= <input_variable_value>.
<variable> = <work area>-temp.
exit.
endloop.
‎2009 Jan 19 3:51 AM
Hi,
Suppose yu enter a value in a parameter say p_temp and you need the value of temp for which p_temp lies between from and to value, you may use
select * from ztable into table itab.
loop at itab.
if p_temp >= itab-from and p_temp <= itab-to.
write itab-temp.
exit.
else.
continue.
endif.
Hope this helps.
Thanks and regards,
Sachin
‎2009 Jan 19 4:19 AM
Hi
Data: itab type table of tbl with header line.
select * from tbl into table itab.
if sy-subrc eq 4.
Message E000(YJK).
else.
loop at itab.
if v_temp between itab-from and itab-to.
write itab-temp.
exit.
else.
continue.
endif.
endloop.
endif.
You can use the above code.
It is not possible to use select stmt with your i/p variable in the where clause as that field is not present in table.
hope this helps
Regards,
Jayanthi.K