‎2006 Feb 02 8:08 AM
How to find Maximum Value in Internal Table
There is one internal table containing 3 columns.
I want to find the maximum value of 2nd column in that internal table . If I use loop at tab, that becomes performance issue, when there are more no. of records.
‎2006 Feb 02 8:37 AM
hi,
sort the table by ascending/descending order on the respective columns.. the first row in itab will give the least/largest value.. For further info type sort and press f1 help.
Regards.
‎2006 Feb 02 8:12 AM
Hi,
sort itab by column2 descending.
read itab into wa index 1.
write wa-column2.
This will give the maximum value.Kindly reward points by clicking the star on the left of reply,if it ehlps.
‎2006 Feb 02 8:44 AM
‎2006 Feb 02 8:12 AM
Hi,
Try to sort the internal table by that column in ascending/descending format.
Then read the 1st or the last entry of the internal table depending on the sorting type ( ascending/descending ).
Best regards,
Prashant
‎2006 Feb 02 8:25 AM
Hi, chexk this sample code. you can do a similar one
tables : vbak.
parameters : p_vbeln like vbak-vbeln.
data : itab like table of vbak with header line.
select * from vbak into table itab where vbeln = p_vbeln.
*assume the second column is erdat
sort itab by erdat descending.
read table itab index 1.
write : itab-erdat.
‎2006 Feb 02 8:27 AM
sort itab by <field nedded>.
read table itab index 1.Message was edited by: Deepak K
‎2006 Feb 02 8:37 AM
hi,
sort the table by ascending/descending order on the respective columns.. the first row in itab will give the least/largest value.. For further info type sort and press f1 help.
Regards.
‎2006 Feb 02 8:41 AM
THERE IS FN MAX.
IT WORKS ON N, I, P types.
MAX(SNO) gives maximum of SNO