Search code examples
ibm-midrangerpgle

How can I get the highest value of a field from a file in ILE RPG without using SQL?


I want to access a file (FILE2) with the key "highest date" from the other file (FILE1).

My program is not using SQL and I don't want to change the File-Typ,

How can I get the highest date from FILE2 for making the chain on FILE1?

My Code looks lide:

KYFILE2.NUMBER = FILE1.NUMBER;
KYFILE2.DATE   = HIGHEST VALUE (FILE1.DATE);
KYFILE2.TIME   = HIGHEST VALUE (FILE1.TIME);
EXSR CHAIN TO FILE2;

Solution

  • The only thing I can think of is to build a LF over the file with the field in question as the key, do a SETGT *HIVAL and then READP on the file.

    For what you are doing, I would say that SQL is your best approach.