Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8995

Re: Sample code to pick up a MAX value from an internal table column?

$
0
0

There is way to get the line which has the maximum value of field with at least 2 times less CPU time.
Instead of using
SORT BY DESCENDING.
  READ INTO INDEX 1.
rather use
READ TABLE INTO < lineB> INDEX 1. (we get the first line)
LOOP AT into .
  IF lineB-x < lineA-x. (we compare if there is line with bigger value than the first line and if yes, assign).
    lineB = lineA.
  ENDIF.

 

;In this way, in case the table is not used sorted further, we make only 1 loop of comparison, and you can imagine to sort the entire table it makes a lot of more loops for comparison.


Viewing all articles
Browse latest Browse all 8995

Trending Articles