Wednesday, June 13, 2007

RPGLE FREE - SETLL use without indicators

RPGIV and with /FREE has some good support for SETLL with its indicator replacements, %FOUND and %EQUAL.

Use it like this.

SETLL (KeyField1: KeyField2) myFileFormat;
If %Equal;
Dsply "Hey I found a match!";
EndIf;

The above IF/EndIf only executes if SETLL finds an exact matching record. This can be used to avoid entering a DO/READ loop if no match is found. This flag can be on in addition to %Found;

SETLL (KeyField1: KeyField2) myFileFormat;
If %Found;
Dsply "Hey, at least 1 record.";
EndIf;

In this case %Found will be on if there is at least one record to read. %Found will always be on if %Equal is on.

I recommend the use of SETLL if you want to check for the presence of a specific record with a key. There is less overhead if %Equal is true because no record is read in.

Enjoy,
Tojo


No comments: