I have 2 input files. Each file has a Trailer record at the end, which cariies the total number of records in that file. I need to merge these files in to a single file, but the out file should carry the total number of records in the trailer. How to do it using SORT?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You need to supply more information on what you're trying to do.
Please show an example of the records in each input file and the output records you expect. What is the RECFM and LRECL of each input file? Is there anything that identifies the trailer record other then it being the last record? How are you "merging" the input file records (e.g. by a key)? Do you need information from the original trailer records in the new trailer record or can you create it from scratch?
If you want some thing like the total number of records from both
the input file to be in your final output file excluding the trailer record
in the output file. Copy by omiting the trailer records and try the below job
Let me explain my requirement in detail with the following example,
File1.
------
name1 address1 ......12345....
name2 address2 ......67474....
.......
namen addressn ......25345....
.............................. total .......>trailer record having the sum of all the amounts in each record.Only way to identify the trailer is, it will be the last record in the file.
I have 4 similar files.
Now i have to merge all thse 4 files in to a single file(no need to sort), Which will have only one trailer and one amount field which will be the sum of amounts in each of the 4 trailer records.
Can we do it using sort? If yes will it work on DFSORT and SYNC SORT?
Or i have to write a program for merging?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You still haven't supplied enough information for me to give you a complete solution.
Again, do you need information from the original trailer records in the new trailer record, or can you create the new trailer record from scratch? If you need information from the original trailer records in the new trailer record, which original trailer record and what information? Or do you just need the sum in the new trailer record without any other information?
What is the starting position, length and format of the key you're merging on? What is the starting position, length and format of the sum in the trailer record?
Give at least one record from each file and the RECFM and LRECL of the file it will be help ful.. now from what u have mentioned i have assumed u have four files and got a field sum of which u want to put into aother file
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
fixdoubts,
You've missed an essential part of the requirement, which is to remove the last (total) record from each file. There's nothing to identify this last record in each file except that it is the last record in each file.
You've created a new trailer record from scatch, but you haven't removed the old trailer records. You've also assumed that the new trailer record doesn't have to contain any information from the old trailer record, which is an assumption I'm trying to get Sreejith to verify or refute.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
fixdoubts,
Read through the posts again. It's pretty clear that each file has a trailer record as the last record. Only one trailer record is supposed to appear in the output, so the other trailer records must be removed. Anyway, it appears sjreejith has lost interest.
I've a similar requirement...Let me know if it is possible to do in one single step -
Infile -
Code:
000000000000000000header record
aaaaaa111111111111 rec1
aaaaaa222222222222 rec2
bbbbbb333333333333 rec3
ccccccccccccccccccccc rec4
999999999999999999trailer record <date1 > <date2 > <count>
In the input file, I've a header, few detail records and a trailer record. The trailer record is identified by 9s in the first 18 position. It will have other details like dates, totals and record count (Including header and trailer).
The problem here is that, in the trailer the record count is incorrect (Due to some previous sort steps). All I want to do is SORT this input file and create an output file with the same detail but with the correct record count in the trailer.
Record count will be always in position 102 (8 chars).
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Is the "correct record count" the count of the detail records, or the count of the detail + header + trailer records? That is, in your example above, is the "correct record count" 4 or 6?
Also, what is the RECFM and LRECL of the input file?
Master is my input file's DD Name and OUT is my final output file.
But the problem is the count is appearing as ' 15' whereas, I want it as '00000015' or '15 '. I used the Edit sub parameter, but received the following error -
Code:
CTL2CNTL :
OUTFIL FNAMES=TEMP2,REMOVECC,
TRAILER1=(1,110,COUNT=(M11)),NODETAIL
*
WER428I CALLER-PROVIDED IDENTIFIER IS "0002"
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
However, the WER messages indicate you're using Syncsort, not DFSORT.
I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.