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

Sort 10 files & combing all trailer recs with 2 totals t


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nicole Mathias

New User


Joined: 22 Mar 2012
Posts: 2
Location: South Africa

PostPosted: Fri Mar 23, 2012 1:32 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 23, 2012 2:08 pm
Reply with quote

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

New User


Joined: 22 Mar 2012
Posts: 2
Location: South Africa

PostPosted: Fri Mar 23, 2012 3:16 pm
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 23, 2012 3:23 pm
Reply with quote

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

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 23, 2012 10:16 pm
Reply with quote

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
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Joining files with intermittent heade... SYNCSORT 1
No new posts Alternative of JoinKeys in SORT DFSORT/ICETOOL 2
No new posts INPFIL FILES, FNAMES examples SYNCSORT 7
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Sort SMF records? SYNCSORT 6
Search our Forums:


Back to Top