View previous topic :: View next topic
|
Author |
Message |
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
Thanks, worked just fine. |
|
Back to top |
|
 |
murali922
New User

Joined: 25 Jul 2005 Posts: 92 Location: India
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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:
Use [URL] BBCode for External Links |
|
Back to top |
|
 |
murali922
New User

Joined: 25 Jul 2005 Posts: 92 Location: India
|
|
|
|
Hi,
Thanks a lot Frank !
Cheers. |
|
Back to top |
|
 |
nupurbhui
New User
Joined: 25 May 2023 Posts: 22 Location: India
|
|
|
|
i have used the code snippet with 2 steps to insert record count in the header but it gives ABENDU0016.
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=i/p file,DISP=SHR
//SORTOUT DD DSN=&&S1,
// UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('MYCT,''',COUNT=(M11,LENGTH=5),'''',80:X)
/*
//STEP02 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=i/p file,DISP=SHR
//SORTOUT DD DSN=o/p file,DISP=SHR
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(58:MYCT)
/*
ERROR LINE:
DATA DICTIONARY SYMBOLS SUBSTITUTED :
OPTION COPY
OUTFIL REMOVECC,HEADER1=(58:MYCT)
*
WER813I INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED
WER268A OUTFIL STATEMENT : SYNTAX ERROR
Could anyone help? |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
nupurbhui wrote: |
i have used the code snippet with 2 steps to insert record count in the header but it gives ABENDU0016.
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=i/p file,DISP=SHR
//SORTOUT DD DSN=&&S1,
// UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('MYCT,''',COUNT=(M11,LENGTH=5),'''',80:X)
/*
//STEP02 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=i/p file,DISP=SHR
//SORTOUT DD DSN=o/p file,DISP=SHR
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(58:MYCT)
/*
ERROR LINE:
DATA DICTIONARY SYMBOLS SUBSTITUTED :
OPTION COPY
OUTFIL REMOVECC,HEADER1=(58:MYCT)
*
WER813I INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED
WER268A OUTFIL STATEMENT : SYNTAX ERROR
Could anyone help? |
0. Do not tailgate previous topics for your own new questions.
1. Learn how to use the Code button when posting your samples. Otherwise >75% of users ignore your appeals.
2. Present exactly what you really get after your attempts, and how you’d like to see your results. |
|
Back to top |
|
 |
|
|