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.
Appreciate yours suggestion. Thanks.
*hival ?
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.
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.
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.
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.