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 - 4109 days ago
Last viewed on: 24 Apr 2024 (8469 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)

Appreciate yours suggestion. Thanks.

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: 12 years 4 months 20 days 19 hours 55 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: 12 years 4 months 20 days 19 hours 30 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: 12 years 4 months 20 days 18 hours 9 minutes ago
Edited: Mon, 05 Dec, 2011 at 10:39:08 (4524 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: 12 years 4 months 20 days 17 hours 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: 12 years 4 months 20 days 16 hours 28 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.