Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Combining more 4 files with sorted order using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Combining more 4 files with sorted order using SORT
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

Active Member


Joined: 29 Apr 2008
Posts: 865
Location: Maryland

PostPosted: Thu Oct 08, 2020 5:30 pm    Post subject:
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 User


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

PostPosted: Thu Oct 08, 2020 11:06 pm    Post subject:
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: 2492
Location: NY,USA

PostPosted: Fri Oct 09, 2020 9:21 pm    Post subject: Re: Combining more 4 files with sorted order using SORT
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Group comparison/update between two f... premnath DFSORT/ICETOOL 8 Thu Oct 22, 2020 4:27 am
No new posts Need assistance formatting when joini... chillmo SYNCSORT 8 Wed Oct 21, 2020 10:56 am
No new posts Copying data from prev record using SORT bshkris SYNCSORT 19 Thu Oct 15, 2020 3:29 pm
No new posts SEPARATE UNIQUE and NON-UNIQUE in SEP... mohitsethi SYNCSORT 6 Thu Oct 01, 2020 9:47 pm
No new posts Undesired result while joining files. Khupe SYNCSORT 3 Tue Sep 22, 2020 8:05 pm

Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us