Determine max / min value of internal table column with REDUCE

It comes handy, when you need to allocate the next item number of a document. The task is always to get the highest number first.

DATA:
  po_items	TYPE STANDARD TABLE of ekpo.
	  
DATA(max_num) = REDUCE numc5( INIT res = '00000'  FOR line IN po_items
	NEXT res = COND #( WHEN line-ebelp > res THEN line-ebelp ELSE res ) 
).

You can also get the lowest number, the complexity of comparison is up top You to do something different with a particular column. Here the focus is on the new REDUCE statement.

Applicable in NW 7.5 and onwards.

SAPDEV.EU
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.