In the trailer record, position 26-30 is the count of ABC01 records, 31-35 is the count of ABC02, 36-40 is the count of ABC03 and 41-46 is the total count (ABC01 + ABC02 + ABC03)
I want to split this file into 2 different files (F1, F2). F1 having record types ABC01, ABC02 (position 1-5) and F2 having record type ABC03.
Now F1, F2 should again be split into 3 different files each based on values at position 6-8 (DEF, XYZ, MNO). So we now have F3, F4, F5 (out of F1) and F6, F7, F8 (out of F2)
Now all these 6 files (F3, F4, F5, F6, F7, F8) should have a record with record type ABC00 as the header record (copied from F1).
Now F3, F4, F5 will only contain records of ABC00, ABC01, ABC02…...I want a trailer at the end of these files having same data as test data given above from position 1-25 of last record, than count of ABC01 (5bytes), than count of ABC02 (5bytes), than total count (6bytes).
Now F6, F7, F8 will only contain records of ABC00, ABC03…...I want a trailer having same data as given above from position 1-25 of last record, than count of ABC03 (5bytes), than total count (this would be same as that of ABC03 but defined as 6bytes).
After this I want to sort the files (F3, F4, F5) based on a key field which is present at position 19-28 for record type ABC01 and 29-38 for record type ABC02…..this will be followed by sorting on the record type present at location 1-5.
You call it a challenge and you haven't given us LRECL and RECFM.
Although You have given us enough requirements,it would be helpful if you can also post sample output.
Also do you need files F1 and F2 for future processing? Can we jump to files 03 through 06?
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
ppandey07 wrote:
it's a challenge dude. let's c how quickly you do it :-))
Dare I ask if this is just a challenge in that the results have no real value and you may be wasting everybodys time,
or is it merely a psychological ploy in an attempt to get your work done faster ?
For the final sort on 2 different keys, do you want just sort on just detail records (keep header and trailer as is.)? If you do want to sort detail records only change IFTHEN to group condition and use PUSH instead of OVERLAY.
But since you haven't told us, I am not coding for that assumption. Also what about files 06 through 08?
Try this untested. I really didn't get time to finetune this since I need to run for the work, If I get some more time during the day I will work on tunning if required.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Wow SQCLODE1. Please do NOT post solutions using 19 passes of data when the whole exercise can be completed in just 1 pass. Please refrain from posting inefficient solutions. you are making DFSORT look bad by posting such solutions. Just because OP defined the steps to get the data , you don't have to follow the same. Get the gist of the requirement and try to code the program/solution accordingly.
ppandey07,
Use the following DFSORT JCL which will give you the desired results all in a single pass of data.
Kolusu,
Agreed that my solution was not efficient and that's why I had written that I didn't get time to finetune!!! And I do agree that even if I would have had time I couldn't have reached your solution.
Also I am curious to know (not that I disagree with you), how is it that my solution has 19 passes? Would getting HEADER and TRAILER records from input be considered a single pass? As far as I know, DFSort simply strips first and last record of the file when we use SUBSET ..WITH HEADER TRAILER. Does reading an Input file, accounts for a single pass?
Ofcourse there is no doubt that your solution would be more efficient.
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Quote:
you are making DFSORT look bad by posting such solutions
non-DFSORT comment
There is not yet (nor probably ever will be) a language/utility/tool that is not able to completely drain even the largest system - when the worst possible "solutions" are permitted to be implemented.
/non-DFSORT comment
@sqlcode1 - this is not directed towards you personally, but rather to the increasing number of implementations that use exponentially more resources than necessary to meet a requirement.
One of my personal favorites is the approach that opens/reads/closes "file2" millions of times in order to match every record of file1 against file2. . .
Joined: 27 Nov 2008 Posts: 51 Location: Delhi, India
Skolusu,
If i want to sort files F03DEF, F03MNO, F03XYZ (as per your sortcard) on the basis of a key present from 9-19 in the ascending order except header record and trailer record, what changes would i need to make in your sortcard?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
ppandey07 wrote:
Skolusu,
If i want to sort files F03DEF, F03MNO, F03XYZ (as per your sortcard) on the basis of a key present from 9-19 in the ascending order except header record and trailer record, what changes would i need to make in your sortcard?