|
You are trying to convert
from an IFS file
to a DB file.
Therefore the IFS file (by that I assume you mean a stream file outside of
the QSYS.LIB file system) already has it's "number of records" determined.
So you must be trying to set the number of records to the db2 file. Then,
yes, that would be a simple OVRDBF, CHGPF, or doing the CRTPF or CREATE
TABLE differently.
Let me reread this...
Ok, so on the DB2 file you do not want to use *NOMAX but you want to set
the maximum to some count of the stream file. And stream files have no
concept of 'records'. However, (after doing a bunch of research), let me
try this.
STRSQL
CREATE TABLE ROB/TEST (MYCHAR CHAR (10 ) NOT NULL WITH DEFAULT)Table TEST created in ROB.
INSERT INTO ROB/TEST VALUES('ROW 1')1 rows inserted in TEST in ROB.
INSERT INTO ROB/TEST VALUES('ROW 2')1 rows inserted in TEST in ROB.
INSERT INTO ROB/TEST VALUES('ROW 3')1 rows inserted in TEST in ROB.
CPYTOIMPF FROMFILE(ROB/TEST) TOSTMF('/rob/test.txt') STMFCCSID(*PCASCII)RCDDLM(*CRLF) STRDLM(*NONE)
DSPF '/ROB/TEST.TXT'....+....1....+....2....+....3.
************Beginning of data*
ROW 1
ROW 2
ROW 3
************End of Data*******
QSH
cat /rob/test.txtROW 1
ROW 2
ROW 3
$
cat /rob/test.txt | wc -l3
$
So now I see you are looking to retrieve that '3'.
So, when I run
qsh cmd('cat /rob/test.txt | wc -l')
in an interactive session the following displays on the screen:
3
Press ENTER to end terminal session.
When I run
qsh cmd('cat /rob/test.txt | wc -l')
in a batch session.
SBMJOB CMD(QSH CMD('cat /rob/test.txt | wc -l'))
Job 420557/ROB/QDFTJOBD submitted to job queue QBATCH
wrkJob 420557/ROB/QDFTJOBD
4. Work with spooled files
I get a spool file with one row displaying 3 in it.
I tried a few things
qsh cmd('cat /rob/test.txt | wc -l >/qsys.lib/qtemp.lib/mydtaara.dtaara'
)
Command ended normally with exit status 2.
qsh cmd('cat /rob/test.txt | wc -l > /qsys.lib/qtemp.lib/mytable.file')Command ended normally with exit status 2.
qsh cmd('cat /rob/test.txt | wc -l > /rob/RecordCount.txt')Command ended normally with exit status 0.
So directing the output to a data area or a db2 file wasn't going to
happen. Directing it to a stream file was ok though.
Which leaves you a couple of choices.
- Run in batch and use CPYSPLF.
- Direct to a stream file and read that
or do a CPYFRMSTMF on it.None. I didn't think of that. It's been many years since I needed to process many files
-Skip CPYFRMIMPF altogether and use Stream file APIs (like the Scott
Klement tutorial) to read the stream file and write it to a DB2 file. You
can either set the DB2 file to *NOMAX and stop you read loop if you read
too many records and just don't want to process the rest, or continue to
use a maximum and condition the write to say if it's full abort the read
loop.
- Continue using your existing process and error trap it.
I don't know why the phobia against nomax.
It would be understandable if you were actually taking the WC output and
saying if it's over x then don't just do an OVRDBF but instead do...
But if you are just going to set it to whatever the size of the stream
file is then why not use *NOMAX?
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From: "Gary Kuznitz " <docfxit@xxxxxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 12/26/2014 02:27 AM
Subject: How to find the number of records in an IFS file
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>
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 are millions of records in the files.
I have tried this but I think it only works on System i files. (Not IFS)
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)
I have tried this 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.
Thanks,
Gary Kuznitz
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.