Midrange News for the IBM i Community


Posted by: anambd
How to get maximum value using rpg built in functions from a file of a decimal field
has no ratings.
Published: 04 Dec 2011
Revised: 23 Jan 2013 - 1703 days ago
Last viewed on: 21 Sep 2017 (4878 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

How to get maximum value using rpg built in functions from a file of a decimal field Published by: anambd on 04 Dec 2011 view comments(5)

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: dougcmh
Premium member *
Columbus, OH
Comment on: How to get maximum value using rpg built in functions from a file of a decimal field
Posted: 5 years 9 months 18 days 23 hours 15 minutes ago

*hival ?

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: How to get maximum value using rpg built in functions from a file of a decimal field
Posted: 5 years 9 months 18 days 22 hours 50 minutes ago

If the file is keyed (ascending) by the value in question, setgt/readp will get you the highest value.  If not you can read the entire file.  Then again if you have sql then things become easy - select max(Value) from file.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: How to get maximum value using rpg built in functions from a file of a decimal field
Posted: 5 years 9 months 18 days 21 hours 29 minutes ago
Edited: Mon, 05 Dec, 2011 at 10:39:08 (2118 days ago)

A lot of RPG programmers missed the *START and *END values for SETLL that were introduced more than a decade ago. Instead of *HIVAL or *LOVAL use *START and *END respectively to go to the beginning and end of the file.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: How to get maximum value using rpg built in functions from a file of a decimal field
Posted: 5 years 9 months 18 days 20 hours 20 minutes ago

I may be strange, but I tend to go with *START and *END, when I'm processing by RRN, and *HIVAL/*LOVAL when I am using a key field value.  Then again, trying to recall when I last wrote a program that processes the entire file using native I/O.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: How to get maximum value using rpg built in functions from a file of a decimal field
Posted: 5 years 9 months 18 days 19 hours 48 minutes ago

The difference is that *START will take you to the first record or first key value regardless of the ASCEND/DESCEND keywords (key field sort order). Whereas *LOVAL looks for zeros or negative 9999 or blanks or whatever... instead of the first key value in the file.