Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if Logical File contains records

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
What's the best/easiest way to test a logical file to see if contains records. I have two files. One contains customer charges/credits VRFADJ and the other contains No Good Credits VRFNGC. Each file may or may not contain data.

In my procedure(s) I READ each record. On the first read attempt if the file has no records I want to LEAVESR. I see where you can use indicators within the read operation but 1. I don't want to use indicators if I don't have to 2. Not sure if a file with no records will turn on an error indicator.

Thanks in advance for any and all help.

Robert
 
READ VRFADJ
If %EOF(VRFADJ)
LeaveSR
EndIf

-or-
*LOVAL SETLL VRFADJ
If %EOF(VRFADJ)
LeaveSR
EndIf

Note: If you use the SETLL, you must specify the file name, do not use the generic %EOF

 
If you are going to use SETLL to check for records you shouldn't use %EOF, after all you are not doing a read so you won't ever be at End Of File. Try
Code:
*LOVAL   SETLL VRFADJ
         If   %Equal
         LeaveSR
         EndIf
The %Equal BIF also works when using key lists and/or partial keys to access records in the file.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
%EOF does work with SETLL, provided a file name is specified. I like to use it instead of READ/READE if I'm just checking existence exactly because it does not actually "read" a record. I will admit though, I haven't used it to test an empty file - I usually have a partial key.
 
Well -- I tested it with SETLL and Pete's correct. If doesn't flag %EOF if there are no records found. Stick to the READ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top