Posted: Wed Jul 25, 2007 8:46 am Post subject: How to count the number of lines in a file
I am reading in a file that has a header of 11 lines
Code:
*---------
*
*
* HEADER TEXT
*
* MORE HEADER TEXT
* RANDOM STUFF
* MORE
* INFO HERE
* ++!!
*---+----1 END OF HEADER
If the header contains more than 11 lines the file has to be read in and the rest of the program has to process/complete but if there are only 11 lines (just the default header) no further processing has to be completed and the job has to end normally.
Code:
*---------START OF HEADER
* NONE OF THIS
* GETS PROCESSED
*
*
* MORE HEADER TEXT
* RANDOM STUFF
* MORE
* INFO HERE
* ++!!
*---+----1 END OF HEADER
THIS LINE WOULD GET PROCESSED
SO WOULD THIS LINE
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jul 25, 2007 8:51 am Post subject:
Quote:
If the header contains more than 11 lines the file has to be read in and the rest of the program has to process/complete but if there are only 11 lines (just the default header) no further processing has to be completed and the job has to end normally
How do you identify the beginning and ending of the header? Also what is the LRECL and RECFM of the dataset?
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jul 25, 2007 9:39 am Post subject:
DeX,
Try this job. This job sets a return code of 0 when there are more than 11 as header and a return code of 4 when there are less than or equal to 11 header lines. You can check the return code and bypass/process the next steps
is the first include= a typo or should it be there?
It is a typo. I corrected it. You just need 1 include parm.
Quote:
also what are the main differences between the statements?
Syncsort treats a SORTOUT DD connected to an OUTFIL statement as a SORTOUT data set, so NULLOUT applies to it. FNAMES=SORTOUT is treated differently than FNAMES=OUT1.
DFSORT treats a SORTOUT DD connected to an OUTFIL statement as an OUTFIL data set, so NULLOFL applies to it rather than NULLOUT. FNAMES=SORTOUT is treated the same as FNAMES=OUT1 which we feel is the more consistent approach.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Jul 26, 2007 4:22 pm Post subject:
Quote:
I'm trying the DFSORT solution but no matter how many lines the input file is, it still finishes with a RC 0
You must be doing something wrong. Remember that we're only including lines with * in cc1. Could you be using Syncsort (WER messages) rather than DFSORT (ICE messages)? When I run this z/OS DFSORT V1R5 job:
Code:
//S11 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
*---------
*
*
* HEADER TEXT
*
* MORE HEADER TEXT
* RANDOM STUFF
* MORE
* INFO HERE
* ++!!
*---+----1 END OF HEADER
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,1,SEQNUM,8,ZD)
OUTFIL NULLOFL=RC4,INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)
/*
//S10 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
*---------
*
*
* HEADER TEXT
*
* MORE HEADER TEXT
* RANDOM STUFF
* MORE
* INFO HERE
*---+----1 END OF HEADER
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,1,SEQNUM,8,ZD)
OUTFIL NULLOFL=RC4,INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)
/*
//S12 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
*---------
*
*
* HEADER TEXT
* HEADER TEXT
* HEADER TEXT
*
* MORE HEADER TEXT
* RANDOM STUFF
* MORE
* INFO HERE
*---+----1 END OF HEADER
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,1,SEQNUM,8,ZD)
OUTFIL NULLOFL=RC4,INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum