|
|
| Author |
Message |
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 139 Location: Mumbai
|
|
|
|
Hi All,
I have a requirement to eliminate duplicate records from a flat file, I know it can be done by giving SUM FIELDS = NONE in a sort job, but in my case I have a header record and a trailer record in my input file, and the trailer record consists of the number of records present in the file , pls find the sample file below
004102007 PGM1
1record1
1record2
1record3
904102007 03
The above would be my data inside my file and the trailer record as specified contains the number of records in the file, I have to remove the duplicate in my file but also modify the number of records in my trailer record accordingly, I don;t want to use a COBOL pgm for the sam e , can it be done by SORT, If so please share the sort card. Thanks in advance
Thamilzan. |
|
| Back to top |
|
 |
References
|
Posted: Thu Oct 04, 2007 11:30 am Post subject: Re: Editing trailer record in my input file |
 |
|
|
 |
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1482 Location: Bangalore,India
|
|
|
|
Thamilzan,
How do you recognize Header & Trailer records? Are they going to be constant across runs (leaving record count). |
|
| Back to top |
|
 |
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1482 Location: Bangalore,India
|
|
|
|
| Also, post your file attribs along with sort key details. |
|
| Back to top |
|
 |
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 139 Location: Mumbai
|
|
|
|
Hi Murali,
The header record would be identified by '0' in the first byte and the data record would be havin '1' in the 1st byte and the trailer record would be havin '9' in the 1 st byte, the DCB parameters are 80 lrecl and 800 blk and FB format, the header record and trailer record remains constant
Thamilzan. |
|
| Back to top |
|
 |
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1482 Location: Bangalore,India
|
|
|
|
Prav,
| Code: |
//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
004102007 PGM1
1RECORD1
1RECORD3
1RECORD1
1RECORD2
1RECORD3
1RECORD2
1RECORD4
904102007 07
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INCLUDE COND=(1,1,CH,EQ,C'1')
SORT FIELDS=(2,7,CH,A)
SUM FIELDS=NONE
OUTFIL REMOVECC,
HEADER1=(C'004102007 PGM1'),
TRAILER1=(C'904102007 ',COUNT=(EDIT=(TT)))
/* |
OP:
| Code: |
004102007 PGM1
1RECORD1
1RECORD2
1RECORD3
1RECORD4
904102007 04 |
I had assume key is between 2 to 8 columns (lenght 7). Change according to your key positions. Also, as per your quote -
| Quote: |
| the header record and trailer record remains constant |
|
|
| Back to top |
|
 |
krisprems
Senior Member
Joined: 27 Nov 2006 Posts: 627 Location: India
|
|
|
|
prav_06
In the trailer record, the data following the trailer indicator looks like date, is that the run date?
| Quote: |
| I have a requirement to eliminate duplicate records from a flat file |
Eliminate based on what key position? is that based on entire record ? |
|
| Back to top |
|
 |
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1482 Location: Bangalore,India
|
|
|
|
KirsPrems,
| Quote: |
| In the trailer record, the data following the trailer indicator looks like date, is that the run date? |
Even the header has the same value. Since Parv said the HEADER and TRAILER remains constant...... |
|
| Back to top |
|
 |
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 139 Location: Mumbai
|
|
|
|
Hi Murali,
Thanks a lot for the solution.
Thamilzan. |
|
| Back to top |
|
 |
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 139 Location: Mumbai
|
|
|
|
Hi,
Say if the header record is not constand and would vary for each run how the above JCL can be modified. Thanks in Advance.
Thamilzan. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4234 Location: San Jose, CA
|
|
|
|
Thamilzan,
Here's a DFSORT job that will handle varying header and trailer records. It creates DFSORT Symbols for the header and trailer information and then uses those Symbols in HEADER1 and TRAILER1.
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OMIT COND=(1,1,CH,EQ,C'1')
INREC IFOUTLEN=80,
IFTHEN=(WHEN=(1,1,CH,EQ,C'0'),
BUILD=(C'Hdr,''',1,20,C'''',80:X)),
IFTHEN=(WHEN=NONE,
BUILD=(C'Trl,''',1,10,C'''',80:X))
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
INCLUDE COND=(1,1,CH,EQ,C'1')
SORT FIELDS=(2,7,CH,A)
SUM FIELDS=NONE
OUTFIL REMOVECC,
HEADER1=(Hdr),
TRAILER1=(Trl,COUNT=(EDIT=(TT)))
/*
|
|
|
| Back to top |
|
 |
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 139 Location: Mumbai
|
|
|
|
Hi Frank,
I got the JCL but as per my requirements (Which changes Often!!!!!), I need to add 2 to my record count at my trailer record, say if there are 5 data records , the downstream PGM expects the record count as 7 (5 data recs and 1 header and 1 trailer record), could you please suggest how this can be done. Thanks in advance.
Thamilzan. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4234 Location: San Jose, CA
|
|
|
|
Just change the last line to:
| Code: |
TRAILER1=(Trl,COUNT+2=(EDIT=(TT)))
|
COUNT+2 will add +2 to the count of data records. |
|
| Back to top |
|
 |
Moved: Tue Oct 09, 2007 8:46 pm by superk From DFSORT/ICETOOL to JCL |
ajay_diaz Warnings : 1 New User
Joined: 12 Sep 2005 Posts: 22
|
|
|
|
I am able to calculate the record count and sum of the input fields.
But is it possible to place the record count and sum total in a particular place in the trailer record?
e.g.
I need to add the trailer record at the end of the file. My input file is 751 byte file but i am dealing with only following few fields for the trailer record creation:
2nd byte in input contains S9(9) COMP-3
7th byte in input contains S9(3) COMP-3
I want to create a trailer record in output file such that
2nd byte contains 999999999
7th byte contains 999
10th byte contains record count in the file
14th byte contains sum of values in 2nd byte in input file
22nd byte contains sum of values in 7th byte in input.
all the above fields are packed decimal fields.
Thanks! |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4234 Location: San Jose, CA
|
|
|
|
You can use c: in TRAILER1 to indicate the column in which an item should start, e.g.
| Code: |
TRAILER1=(2:'99999999',10:COUNT=...,14:TOT=...,22:TOT=...)
|
Note that your description of what you want in which field contains overlapping values - 999999999 starting in position 2 would be in positions 2-10, but you say you want position 7 to contain 999 and position 10 to contain record count. You need to correct this. |
|
| Back to top |
|
 |
Moved: Wed Mar 26, 2008 9:06 pm by Frank Yaeger From JCL to DFSORT/ICETOOL |
|
|
|