Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : When you specified V for RECFM parameter, LRECL value is largest record in the file plus 4 bytes. These four bytes contain the actual length of each variable length record in the file

Google
 
Web mainframegurukul.com

Count the records and print at end.

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities
  View previous topic :: View next topic  
Author Message
anilanju
Member


Joined: 10 Nov 2008
Posts: 47

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 17, 2009 3:27 pm    Post subject: Count the records and print at end. Reply with quote

Hi

i need to count the number of recors in a fil and write them in the end
of the file.

example:

HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER

HERE in trailer i want the number of records to be printed.example here total is 5.

rec lenght: 38
rec format: FB

Regards
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

Alissa Margulies
Member


Joined: 28 Apr 2009
Posts: 25
Location: USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 17, 2009 7:38 pm    Post subject: Reply with quote

Are the HEADER and TRAILER records already part of the data set? If so, here is a SyncSort for z/OS job that will produce the record count:
Code:
//SORT1 EXEC PGM=SORT                       
//SORTOUT DD SYSOUT=*                       
//SYSOUT  DD SYSOUT=*                       
//SORTIN  DD *                             
HTEST                                       
123968711BM                                 
234968711CM                                 
234968896BM                                 
567968858DM                                 
567968889AM                                 
TRILER                                     
//SYSIN   DD *                             
   OMIT COND=(1,6,CH,EQ,C'TRILER')         
   SORT FIELDS=COPY                         
   OUTFIL FILES=OUT,                       
    TRAILER1=(1:C'TOTAL RECORD COUNT IS',1X,
    COUNT-1=(EDIT=(IIIT))),REMOVECC         
/*                                         

This is the output produced from the above job:
Code:
HTEST                     
123968711BM               
234968711CM               
234968896BM               
567968858DM               
567968889AM               
TOTAL RECORD COUNT IS    5

_________________
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
anilanju
Member


Joined: 10 Nov 2008
Posts: 47

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 17, 2009 8:46 pm    Post subject: Reply with quote

Hi Alissa

Thank you very much. Very Happy

Regards
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
skolusu
Member


Joined: 26 Jul 2008
Posts: 43

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 17, 2009 9:00 pm    Post subject: Reply with quote

anilanju,

If you want to update the existing trailer record without creating a new one, then use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
HTEST                                                           
123968711BM                                                     
234968711CM                                                     
234968896BM                                                     
567968858DM                                                     
567968889AM                                                     
TRILER                                                         
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=38,IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),
  IFTHEN=(WHEN=(1,6,CH,EQ,C'TRILER'),                           
  OVERLAY=(10:39,5,ZD,SUB,+2,M10,LENGTH=5))                     
/*


The output from this job is

Code:

HTEST         
123968711BM   
234968711CM   
234968896BM   
567968858DM   
567968889AM   
TRILER       5

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
anilanju
Member


Joined: 10 Nov 2008
Posts: 47

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jun 18, 2009 4:55 pm    Post subject: Reply with quote

Hi

The code is working fine.

but i just have small query.
OMIT COND=(1,1,CH,EQ,C'T')
SORT FIELDS=COPY
OUTFIL FILES=OUT,
TRAILER1=(1:C'T',1X,
COUNT-1=(EDIT=(IIIIIIT))),REMOVECC
END

from this the trailer record i am getting is
T 103235

i want these spaces to be removed, as the number of records is not fixed.

i want the output as
T103235, so whenever the count changes, it moves
for example:if count is 1000025 then it should be
T1000025.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Alissa Margulies
Member


Joined: 28 Apr 2009
Posts: 25
Location: USA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jun 18, 2009 8:15 pm    Post subject: Reply with quote

One alternative is to print the leading zeros:
Code:
//SYSIN DD *                         
  OMIT COND=(1,1,CH,EQ,C'T')         
  SORT FIELDS=COPY                   
  OUTFIL FILES=OUT,                   
    TRAILER1=(1:C'T',                   
    COUNT-1=(EDIT=(TTTTTTT))),REMOVECC                               
/*                                   

Producing these results:
Code:
HTEST     
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
T0000005   


Another alternative is to modify Kolusu's job as follows:
Code:
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=38,
    IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),
    IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),                               
    OVERLAY=(2:39,5,ZD,SUB,+2,M10,LENGTH=5),HIT=NEXT),           
    IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),                               
    BUILD=(1,1,2,5,JFY=(SHIFT=LEFT)))                             
/*                             

Which produces these results:
Code:
HTEST     
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
T5         

_________________
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
skolusu
Member


Joined: 26 Jul 2008
Posts: 43

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jun 18, 2009 8:59 pm    Post subject: Reply with quote

Alissa Margulies,

You really don't need the extra IFTHEN. you can do it in the same pass.

Code:

//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFOUTLEN=38,IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),   
  IFTHEN=(WHEN=(1,6,CH,EQ,C'T'),                                   
  OVERLAY=(39:39,5,ZD,SUB,+2,M10,LENGTH=5,2:39,5,JFY=(SHIFT=LEFT)))
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Jan 25, 2016 10:31 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & 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


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-4216.html