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?
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,
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?
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
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.
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 -
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).