MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to count the number of lines in a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
DeX
Beginner


Joined: 09 Apr 2007
Posts: 7
Topics: 2
Location: Waterloo, Ontario, Canada

PostPosted: Wed Jul 25, 2007 8:46 am    Post subject: How to count the number of lines in a file Reply with quote

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


any help...IDCAMS, IEBGENER, JCL, etc.

Thanks!!!!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 25, 2007 8:51 am    Post subject: Reply with quote

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?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DeX
Beginner


Joined: 09 Apr 2007
Posts: 7
Topics: 2
Location: Waterloo, Ontario, Canada

PostPosted: Wed Jul 25, 2007 9:25 am    Post subject: Reply with quote

INPUT FILE:
RECFM=FB
LRECL=80

The header is always 11 lines and always starts with a '*' the data to be read in by the application starts at line 12 col 1
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 25, 2007 9:39 am    Post subject: Reply with quote

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

DFSORT Solution:

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD  SYSOUT=*                         
//SORTIN   DD  DSN=INPUT FILE,
//             DISP=SHR
//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)
/*                                               



SYNCSORT Solution:

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD  SYSOUT=*                         
//SORTIN   DD  DSN=INPUT FILE,
//             DISP=SHR
//SORTOUT  DD  SYSOUT=*                         
//SYSIN    DD  *
  OPTION NULLOUT=RC4                           
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,1,SEQNUM,8,ZD)
  OUTFIL INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)
/*

_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Wed Jul 25, 2007 1:19 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DeX
Beginner


Joined: 09 Apr 2007
Posts: 7
Topics: 2
Location: Waterloo, Ontario, Canada

PostPosted: Wed Jul 25, 2007 1:16 pm    Post subject: Reply with quote

in the SYNCSORT solution, you have:

OUTFIL INCLUDE=INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)

is the first include= a typo or should it be there?

also what are the main differences between the statements?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 25, 2007 1:21 pm    Post subject: Reply with quote

Quote:

in the SYNCSORT solution, you have:

OUTFIL INCLUDE=INCLUDE=(1,1,CH,EQ,C'*',AND,2,8,ZD,GT,11)

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.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DeX
Beginner


Joined: 09 Apr 2007
Posts: 7
Topics: 2
Location: Waterloo, Ontario, Canada

PostPosted: Wed Jul 25, 2007 1:37 pm    Post subject: Reply with quote

Thank you very much. We'll be testing and implementing for next week. I'll let you know how it turns out!

Mr. Green
Back to top
View user's profile Send private message
DeX
Beginner


Joined: 09 Apr 2007
Posts: 7
Topics: 2
Location: Waterloo, Ontario, Canada

PostPosted: Thu Jul 26, 2007 3:37 pm    Post subject: Reply with quote

Kolusu,

I'm trying the DFSORT solution but no matter how many lines the input file is, it still finishes with a RC 0
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 26, 2007 4:22 pm    Post subject: Reply with quote

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)
/*


I get:

Code:

STEPNAME PROGRAM     RC
S1       ICEMAN    0004
S2       ICEMAN    0004
S3       ICEMAN    0000

_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group