View previous topic :: View next topic
|
Author |
Message |
bshkris
New User
Joined: 21 Mar 2005 Posts: 41 Location: pune
|
|
|
|
Hi,
I have a requirement about files merging and sorting in desired way. i was thinking which will be better like using COBOL/JCL SORT. Your inputs on this appreciated.
Requirement:
All 4 files have 200 bytes FB.
Code: |
File1:
11ABCD 2020-10-11 L
12EFGH 2020-10-12 L
14MNOP 2020-10-14 L
File2:
11ABCD 2020-10-09 SENT
12EFGH 2020-10-12 SENT
13IJKL 2020-10-13 SENT
File3:
11ABCD 2020-10-10 C
12EFGH 2020-10-12 C
13IJKL 2020-10-13 C
File4:
11ABCD 2020-10-12 E
12EFGH 2020-10-13 E
13IJKL 2020-10-14 E |
OUTPUT file:
Code: |
14MNOP 2020-10-14 L ----- ALWAYS latest Date should be on top, also it should have 'L' type rec
11ABCD 2020-10-11 L
11ABCD 2020-10-09 SENT
11ABCD 2020-10-11 C
11ABCD 2020-10-12 E
12EFGH 2020-10-12 L
12EFGH 2020-10-12 SENT
12EFGH 2020-10-12 C
12EFGH 2020-10-13 E
13IJKL 2020-10-13 SENT
13IJKL 2020-10-13 C
13IJKL 2020-10-14 E |
Basically it needs searching all 4 files for matching key(1-21 chars), and we need group the matched records into output file, and we need to bring all records from 4 files into single file.
Is this possible with SORT, or we should go thru COBOL.
Thanks.
Coded for you |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2156 Location: USA
|
|
|
|
1) it is possible to do this in any manner: SORT, COBOL, PL/I, REXX, ...etc, etc, etc, Assembler, ...
2) it is recommended you to start training yourself step by step, not the whole bunch of operations at once:
- learn (RTFM and try) joining records by key(s)
- learn (RTFM and try) grouping records by key(s)
- learn (RTFM and try) use of JCL to initiate the processing in the way you’ve chosen
- learn (RTFM and try) combining all operations learned above into a more complex processing
- learn (RTFM and try) to diagnose and fix possible errors and troubleshoots in the processes above
After you have finished the stages above, most likely you will not need seeking for such answers at the experts forum.
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1348 Location: Bamberg, Germany
|
|
|
|
- Find the highest DATE record with an 'L'
- Use that record(s) as key for a later JOINKEYS operation
- Sort REFORMATed records by '?' indicator, name, 'L/SENT/C/E'
- Use finally OUTFIL w/ SECTIONS to produce the report
Output from my test:
Code: |
****** **************************** Datenanfang *******************************
000001 14MNOP 2020-10-14 L
000002
000003 11ABCD 2020-10-11 L
000004 11ABCD 2020-10-09 SENT
000005 11ABCD 2020-10-10 C
000006 11ABCD 2020-10-12 E
000007
000008 12EFGH 2020-10-12 L
000009 12EFGH 2020-10-12 SENT
000010 12EFGH 2020-10-12 C
000011 12EFGH 2020-10-13 E
000012
000013 13IJKL 2020-10-13 SENT
000014 13IJKL 2020-10-13 C
000015 13IJKL 2020-10-14 E
****** **************************** Datenende ********************************* |
So yes, DFSORT can do the task. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3077 Location: NYC,USA
|
|
|
|
bshkris wrote: |
Basically it needs searching all 4 files for matching key(1-21 chars), and we need group the matched records into output file, and we need to bring all records from 4 files into single file.
Is this possible with SORT, or we should go thru COBOL.
|
What is 1-21? shouldn't it be 1-2? Also you would need to tell what should happen if there are underlying records in the other file which belongs to 14 or confirm if it is just one record for max date and rec type L.
Make a use of Code tags next time when showing us the data.
Multi step easy solution to get what you need( Should not be a problem for small amount of data)-
1. Split the Data set 1 into two , keep the max date and rec type L in one DS1 and rest in other DS2 using ICTOOL SELECT
2.Take remaining 3 Dataset and DS2 , concatenate them and SORT by 1-2 , so they will be grouped as need in the final output
3.Concate DS1 and step 2 DS to get final results. ( I don't think you need blank record after each group)
Once you know DFSORT then get into more complex stuff of squeezing it into smaller step/s. |
|
Back to top |
|
|
|