There isn't any command I'm aware of to return the number of records in a file but you could easily create one with these steps.
CHKF (Check file command) to create:
CHKF FILE(MYLIB/MYFILE) NBRRCDS(&NBR)
The second parm in this command definition is a return variable type to return the record number to the caller. Running interactively, this should take about one or two seconds to complete at most on an iSeries.
In the CL program for your command:
1. DSPFD FILE(&FILENAME) TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(QTEMP/FD)
2. In a CALLED CL PGM, open the file QTEMP/FD.
3. Do RCVF cmd on QTEMP/FD. This reads in the first record for the first member in the file. It has a record format (QWHFDML) and 2 fields: MLFILE (filename) and MLNRCD (number of records). You now have the record count of the first member.
4. CHGVAR to set the return CL PGM VAR (&NBRRCDS) from the MLNRCD variable you accessed.
================================== MORE INFORMATION ON THIS TOPIC ==================================
Check out these Best Web Links on Web development.
Ask the Experts yourself: Our Web development gurus are waiting to answer your questions.
Ask your Web development & WebSphere questions -- or help out your peers by answering them--in our .fMFNafNPDOX.2@.ee84637!viewtype=&skip=&expand=>WebSphere & Web Development Forum.
This was first published in January 2004