Find Maximum Value or Is Empty
Internal Table
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.
sort internaltable by secondcolumn descending.
Though we sort internal table on second column ,it sorts,
first ,based on the first column and then it sorts on second column.So
we may not get the maximum value on top of second column.
Ravi
If the two columns are A and B then SORT ITAB BY B DESCENDING.
works very fine. Saint.
You have internal table with three rows in it. Ok...now when you add the rows into the internal tables, generally you writes, APPEND IT..........instead of that you write like this
:
now write : READ TABLE IT index 2. you will get the second max. value in the internal table. for example, copy the following code and test it. You'll get the result. REPORT ZAPPEND. data: begin of it occurs 3,
it-sales = 100.
append it sorted by sales. it-sales = 50.
append it sorted by sales. it-sales = 150.
append it sorted by sales. it-sales = 75.
append it sorted by sales. it-sales = 200.
append it sorted by sales. it-sales = 100.
append it sorted by sales. loop at it.
read table it index 2. write : / 'Second maximun row is'.
Ulhas How To Know Whether Internal Tables Is Empty * Check Whether Table is Empty
* Assuming that the data have been
uploaded into internal table ITAB. You then can ignore the first line of
the internal table
* To know the last record insert
in a table
More Function Module
Tables
ABAP Books List
Smart Forms
ABAP Menu:
Return to Index:-
(c) www.gotothings.com All material on this site is Copyright.
|