|
View previous topic :: View next topic
|
| Author |
Message |
Nicole Mathias
New User
Joined: 22 Mar 2012 Posts: 2 Location: South Africa
|
|
|
|
Hi There,
I have 10 input files with attributes (RECFM=FB, LRECL=750). Each file contains detail records and a trailer record identified by ‘TRL’ in the 6th column:
FILE 1
.00..ZAP00000000000000002407978
.00..ZAP00000000000000002407978
.00..TRL00000000000000000000000....|20120401|16:00:00|000000003|000000003|000000002|000000003|000100000
.
.
.
FILE 10
.00. ZAP00000000000000000004758
.00..ZAP00000000000000000007978
.00..ZAP00000000000000001234566
.00..TRL00000000000000000000000....|20120401|16:00:00|000000003|000000003|000000003|000000002|000100000
I need the detail records from all 10 files to be merged into 1 output file and sorted by the first 32 bytes. I also need all 10 trailer records to be combined into 1 trailer record with the sum total of Field-1 and Field-2.
Field 1 in trailer starts in column 75 and is 9 numerics long
Field 2 in trailer starts in column 85 and is 9 numerics long
The trailer record in 115 bytes in length
OUTPUT
.00. ZAP00000000000000000004758
.00..ZAP00000000000000000007978
.00..ZAP00000000000000001234566
.00..ZAP00000000000000002407978
.00..ZAP00000000000000002407978
.00..TRL00000000000000000000000....|20120401|16:00:00|000000003|000000003|000000005|000000005|000100000
Anyones help would be greatly appreciated. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
More than one way to skin an egg.
Do you programs regularly check the trailer totals against the detail amounts? Maybe you can get away without checking that, (I'm picky).
Concatenate them to SORTIN. OMIT the TRL appropriately. Search the forum for TRAILER processing, as the trailer can be easily generated.
EDIT: Have a look at this for instance. |
|
| Back to top |
|
 |
Nicole Mathias
New User
Joined: 22 Mar 2012 Posts: 2 Location: South Africa
|
|
|
|
Thank you i will try it.
The second total cannot be derived from the detail records which is why i need to add every trailers totals together. The totals are not compared to detail amounts in later programs but is used to split processing.
I will try seperating the sorts as suggested and will let you know.
Thanks  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I didn't suggest any seperation :-)
Funny trailers you have. Not really a trailer, just a different data record which happens to be the last.
You realise that if your total-which-can't-be-calculated-from-elsewhere goes "pants" and no-one notices for a while, you'll have some fun catching-up to do?
Back to the task.
Since you need to sort the data anyway, take your concatenated 10 files, do the sort, do a SUM (either actual or logical) which produces a single trailer with the relevant fields summed.
There are some examples here. Just popped in, no time to search myself at the moment. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Use the following DFSORT JCL which will give you the desired results. I assumed that you don't have any duplicates on the data records on the first 32 bytes. If you do have duplicates then they would be eliminated. Let me know if you want to keep the duplicates on the data records.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your Input FB LRECL 750 byte file01,DISP=SHR
// DD DSN=Your Input FB LRECL 750 byte file02,DISP=SHR
// DD DSN=Your Input FB LRECL 750 byte file03,DISP=SHR
// DD DSN=Your Input FB LRECL 750 byte file04,DISP=SHR
...
// DD DSN=Your Input FB LRECL 750 byte file10,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(751:1,32,18C'0')),
IFTHEN=(WHEN=(6,3,CH,EQ,C'TRL'),OVERLAY=(751:32C'9',75,9,85,9))
SORT FIELDS=(751,32,CH,A),EQUALS
SUM FIELDS=(783,9,792,9),FORMAT=ZD
OUTREC IFOUTLEN=750,
IFTHEN=(WHEN=(6,3,CH,EQ,C'TRL'),OVERLAY=(75:783,9,85:792,9))
//* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|