IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
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
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 Developer


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

PostPosted: Mon Sep 25, 2006 10:41 pm
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
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 Developer


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

PostPosted: Tue Sep 26, 2006 3:06 am
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
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
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 Developer


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

PostPosted: Tue Sep 26, 2006 10:10 pm
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:

Use [URL] BBCode for External Links
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
Reply with quote

Hi,

Thanks a lot Frank !

Cheers.
Back to top
View user's profile Send private message
nupurbhui

New User


Joined: 25 May 2023
Posts: 18
Location: India

PostPosted: Mon May 29, 2023 5:19 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Mon May 29, 2023 5:48 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top