‎2006 Nov 20 6:26 AM
Hi,
I have one query.
Suppose in my internal table itab having field f1 having multiple record. Now i wanted to get the highest value for this field.
Then i will process other logic based on this highest entry(f1). Could anybody tell me how to do this.
Sample logic.
to count no of entries.
describe table itab lines sy-tfill.
now i have to select the highest value in field f1.
how to write the logic here??
‎2006 Nov 20 6:28 AM
sort the table in decending order.
after that just read the itab 1st row(index1)
‎2006 Nov 20 6:28 AM
HI,
Sort the internal table decsending on field f1 and read the first record.
<b>SORT ITAB DESCENDING BY F1.
READ TABLE itab index 1.</b>
Regards,
‎2006 Nov 20 6:29 AM
‎2006 Nov 20 6:30 AM
Hi salil,
1. In internal table suppose u have two fields
f1
xyz
2. There are multiple records of f1.
3.
a) First sort using SORT ITAB by F1 xyz DESCENDING.
b) loop at itab.
ON CHANGE OF F1.
*--- ur code here,
endloop.
4. In this way u will get the HIGHEST entry, for each F1.
regards,
amit m.
‎2006 Nov 20 8:24 AM
hi,
f1 has multiple records and you want the highest value of the record then sort the table in descending order and read the first value.
field1 has multiple values for field2.
sort tab by field1 field2 descending.
loop at itab.
v_tabix = sy-tabix.
at new field1.
read table itab index v_tabix.
" this will be the value highest value of field2 for field1
endat.
endloop.Hope this helps
Regards,
Richa
‎2006 Nov 20 8:39 AM
Hi Salil,
To find out highest value of any field in an internal table, first sort that internal table by that field(say f1 in ur case) by DESCENDING.
Then the first record will be your required highest value.
Logic will be,
<b>sort itab by f1 descending.</b> " sorting the itab entries in descending order
<b>read table itab index 1.</b> " first record is the your required highest value record
Hope this will clear your query.
Best Regards,
Ramesh.