09-25-2006 10:23 AM
Hi
Suppose, I have say following values in my internal table:-
1
8
90
60
40
50
70
And I want to pick the largest of the given numbers in only one command.
How can I do that?
Thank You
09-25-2006 10:24 AM
U can do that using two statement.
SORT itab by F1 DESCENDING.
READ TABLE itab index 1.
The value of itab-F1 will give you the max value.
09-25-2006 10:25 AM
Hi
var is the highest number.
Sort the internal table,
describe int table lines Fill.
read itab index fill.
if sy-subrc = 0.
var = itab-field.
endif.
Regards
Gopi
09-25-2006 10:28 AM
Hi,
use below logic
sort itab by val descending.
read table itab index 1.
Regards
amole
09-25-2006 10:35 AM
hi,
chk this.
SORT ITAB BY VAL DESCENDING.
READ TABLE ITAB INDEX 1.
WRITE ITAB-VAL.
rgds
anver
pls mark all hlpful answers
09-25-2006 10:38 AM
Thank you
but can I achieve the same result by writting a single command only instead of sorting and then selectiong?
Thank You
09-25-2006 10:41 AM
Hi
U can use
select max(fieldname) from itab
where fieldname = your coulmn name
Regards
Pulkit Agrawal
09-25-2006 10:40 AM
Hi,
Well if you have data in internal table and then want to get the max. value then its not possible in single line.
If you are selecting data from a table, then its possible :
Select max ( amount )
from ZTABLE
into l_amount.
Best regards,
Prashant