Wednesday, August 01, 2007

ILE RPG SETLL without keys

RPG has long supported the use of SETLL without keys. However many programmers will shy away from it's use in favor of other manipulations.

The normal use of SETLL is with a full or partial key, or a relative record number. SETLL can also be used with the figurative constants, *LOVAL and *HIVAL.

SETLL *LOVAL {file}
Using SETLL with *LOVAL positions the file so that the first read retrieves the record with the lowest key.

SETLL *HIVAL {file}
*HIVAL positions the file so that a READP retrieves the last record in the file, or a READ receives an end-of-file indication.

*LOVAL is most commonly used to reset reading at the beginning of a keyed file.

*HIVAL is really most useful when the desire is to use the last record in a file.

The most important thing to keep in mind about SETLL, even with using *LOVAL and *HIVAL is that no data read is done from the file.

Thanks for reading and please do post comments and questions or email me suggestions at tojosan - at - gmail.com.

No comments: