On 26-Dec-2014 01:27 -0600, Gary Kuznitz wrote:
I have a CLP that converts an IFS file to a DB file.
I would like to do an OVRDBF for number of records on the output file
to make sure it doesn't exceed it's limits.
There is no such capability. The SIZE() is what controls the limits
on the number of records for the database file member.
There are millions of records in the files.
If this inquiry is related to the use of the Copy From Import File
(CPYFRMIMPF), then just use the Copy From Record Number (FROMRCD)
parameter of the command, and specify the appropriate values for the
Copy From Record Number and Number Of Records To Copy elements of that
command parameter.
I have tried this but I think it only works on System i files.
(Not IFS)
Unfortunately there is no way to override a Database [Flat] File to a
Stream File (STMF) :-( The Copy From Stream File (CPYFRMSTMF) will copy
the stream _records_ to database file rows\records. The Copy From
Import File (CPYFRMIMPF) will copy the effective records from the stream
[not necessarily the stream-file records] into the database file as
database rows\records.
DCLF FILE(QAFDMBR)
DSPFD FILE(&INPUTFILE) TYPE(*MBR) OUTPUT(*OUTFILE) +
FILEATR(*ALL) OUTFILE(QTEMP/QAFDMBR)
OVRDBF FILE(QAFDMBR) TOFILE(QTEMP/QAFDMBR) POSITION(*START)
RCVF
/* The number of records are in &MBNRCD */
OVRDBF FILE(&OUTPUTFILE) SEQONLY(*YES &MBNRCD)
Inserting the CPYFRMSTMF to copy the stream records into a database
file [flat file or /source/ file] named by &INPUTFILE would allow the
above CLP to function. Although making and managing a temporary /copy/
of the file data is required, the stream file utilities will do so as
well; just that /managing/ the temporaries is deferred to those
utilities rather than the CLP itself. A one-byte record length of a
flat file however, does minimize the size of the temporary used solely
for counting; not sure what is the optimization for storage used by any
of the STMF utilities.
I have tried this <ed: the following QShell invocation> but I don't
understand where the number of records ends up.
QSH CMD('cat /home/Payroll/ATU_PAYROLL_DATA_FY14_372_398.txt | wc -l')
I have never used QSH before.
Use the datarea utility to place the results into a data area that
can be read by the CL [using Retrieve Data Area (RTVDTAARA)]. For
shorter lines, the following CLP assumes MYLIB is in the *LIBL
[positioned before any *LIB with the same-named DtaAra object] and
theFile is in the current directory:
DCL &NBRRCDS *DEC (11 00)
CRTDTAARA myLib/myDecDta *DEC TYPE(*DEC) LEN(11) VALUE(-1)
QSH CMD('cat theFile | wc -l | datarea -w -l myDecDta.dtaara')
RTVDTAARA DTAARA(myDecDta *ALL) RTNVAR(&NBRRCDS)
DLTDTAARA myLib/myDecDta
CHGPF &OUTPUTFILE SIZE(&NBRRCDS 0 0)
Note: Embedded record-delimiters, delimited by field separators and
possibly also string delimiters, may cause the "number of records" in
the stream to differ from what is the expected "number of records" in
the database file; i.e. records<>rows
As an Amazon Associate we earn from qualifying purchases.