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

Re: Is there a clever way to exclude initial values from nmin function?

$
0
0

Hello Bernd,

 

following the lines of Horst (or his "master in the background" )

 

 data(min)  = reduce ty_struc( init r = value ty_struc( col1 = nmax col2 = '' )                               for m in itab                               next r = cond ty_struc(                                 when r-col1 < m-col1 then r else m ) ).

The output class will then print the row with 5 and 'C'

 

cl_demo_output=>display( min ).

supposed we preceded the code with the usual declaratory bla-bla:


constants: nmax type i value cl_abap_math=>MAX_INT4.
types: begin of ty_struc,   col1 type i,   col2 type c,   end of ty_struc,   ty_struc_tab type table of ty_struc with empty key.
data(itab) = value ty_struc_tab(                ( col1 = 10 col2  = 'A' )                ( col1 = 12 col2  = 'B' )                ( col1 =  5 col2  = 'C' )                ( col1 = 16 col2  = 'D' ) ).

I don't know whether there is a shorter expression for it than the above REDUCE term.


Viewing all articles
Browse latest Browse all 8944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>