Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Insert a Header record with Total no. of records in a File.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Sep 25, 2006 9:15 pm    Post subject: Insert a Header record with Total no. of records in a File.
Reply with quote

Is there a way to insert a Header record with count of total number of records in a file preferably with a single sort step.

For example i have a flat file (PS) which is FB 80 bytes and has around 50 records. File does not have header. Is it possible to run this file through a sort step sum the total number of records and write whole file back out but now with a additional Header record with total record count.

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

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 25, 2006 10:41 pm    Post subject:
Reply with quote

To insert the count in a header record takes two passes. Since the header record is the first record, we don't know the count when we read/write it. You could insert a trailer record with the count in one pass, but not a header record.

I could show you how to do what you want in two passes, but first I need you to show me an example of your input records and what you expect for output. What should the header record look like? Should the count include the header record, or just the data records? Is there a trailer record - if so, should it be included in the count?
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Sep 25, 2006 10:59 pm    Post subject: Re: Insert a Header record with Total no. of records in a Fi
Reply with quote

Two passes will do. There is no Trailer record and Trailer is not required in output file. Count should be of data records only.

Here is sample Input data. File is FB, LRECL =80

Code:

133491231700010013473783862903668930483000000500                120061001100107
430211231700010013473783862903668930483000000500                120061001100107
648628890100010013473783862903668930483000000500                120061001100107
068928890100010013473783862903668930483000000500                120061001100107
968228890100010013473783862903668930483000000500                120061001100107
188328890100010013473783862903668930483000000500                120061001100107
368938890100010013473783862903668930483000000500                120061001100107
278228890100010013473783862903668930483000000500                120061001100107
414893890100010013473783862903668930483000000500                120061001100107


Here is how output data should look like. File is FB, LRECL =80

Code:

HEADER RECORD COUNT:  000000009
133491231700010013473783862903668930483000000500                120061001100107
430211231700010013473783862903668930483000000500                120061001100107
648628890100010013473783862903668930483000000500                120061001100107
068928890100010013473783862903668930483000000500                120061001100107
968228890100010013473783862903668930483000000500                120061001100107
188328890100010013473783862903668930483000000500                120061001100107
368938890100010013473783862903668930483000000500                120061001100107
278228890100010013473783862903668930483000000500                120061001100107
414893890100010013473783862903668930483000000500                120061001100107


Thanks for your time!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Sep 26, 2006 3:06 am    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=('MYCT,''',COUNT=(M11,LENGTH=9),'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=... outut file
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=('HEADER RECORD COUNT:',23:MYCT)
/*
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Tue Sep 26, 2006 3:26 am    Post subject: Re: Insert a Header record with Total no. of records in a Fi
Reply with quote

Thanks, worked just fine.
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Tue Sep 26, 2006 2:51 pm    Post subject:
Reply with quote

Hi Frank,

Can you please explain the jcl given by you, as I am not familiar with DFSORT and its syntax !

Many thanks,
Murali.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Sep 26, 2006 10:10 pm    Post subject:
Reply with quote

Murali,

The first step uses TRAILER1 to create a DFSORT symbol for the input record count as:

MYCT,'nnnnnnnnn'

The second step uses HEADER1 with MYCT to create the header.

REMOVECC suppresses the ANSI carriage control character.
NODETAIL suppresses the data records.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Sep 27, 2006 8:43 am    Post subject: Re: Insert a Header record with Total no. of records in a Fi
Reply with quote

Hi,

Thanks a lot Frank !

Cheers.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us