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

Combining more 4 files with sorted order using SORT


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

New User


Joined: 21 Mar 2005
Posts: 41
Location: pune

PostPosted: Thu Oct 08, 2020 10:57 am
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1080

PostPosted: Thu Oct 08, 2020 5:30 pm
Reply with quote

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.
358.gif 36_2_51.gif 36_8_12.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 515
Location: Bamberg, Germany

PostPosted: Thu Oct 08, 2020 11:06 pm
Reply with quote

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

Global Moderator


Joined: 21 Sep 2010
Posts: 2672
Location: NYC,USA

PostPosted: Fri Oct 09, 2020 9:21 pm
Reply with quote

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

 


Similar Topics
Topic Forum Replies
No new posts Sort to extract lines DFSORT/ICETOOL 8
No new posts Compare 2 files replace data in 1st f... DFSORT/ICETOOL 4
No new posts Merging 2 files but ignore duplicate... DFSORT/ICETOOL 1
No new posts Combining Multiple Row Values into Si... DB2 3
No new posts SORT - Multiple Conditions DFSORT/ICETOOL 4
Search our Forums:

Back to Top