merge the records from 3 input files into 1 output file alte



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

merge the records from 3 input files into 1 output file alte

Postby MFUSERVDC » Sun Jan 24, 2016 10:45 am

I want to merge the records from 3 input files into 1 output file alternately using sort in JCL. Below are the details
Input File1 :--
  Rec1 ABBBB
       BCCCC
       DEEEE
  Rec2 BDDDD
       DFFFF
       RTTTT

Input File2 :--
  Rec1 SGGHH
       YTTTT
       DWWWW
  Rec2 QEEEE
       DRRRR
       RYYYY

Input File3 :--
  Rec1 URTRT
       ATTTT
       DSSSS
  Rec2 REEEY
       DIYUU
       REDER


Output File :--
  Rec1 ABBBB
       BCCCC
       DEEEE
  Rec1 SGGHH
       YTTTT
       DWWWW
  Rec1 URTRT
       ATTTT
       DSSSS
  Rec2 BDDDD
       DFFFF
       RTTTT
  Rec2 QEEEE
       DRRRR
       RYYYY
  Rec2 REEEY
       DIYUU
       REDER


I tried the some sort cards for merge alternately but its merging record after record. However I want to merge 1st few records from 1st files and then from 2nd and then from 3rd (as explained above example).
Please help me in this (asap).

Thanks,
MFUSERVDC

Code'd
MFUSERVDC
 
Posts: 4
Joined: Sun Jan 24, 2016 9:05 am
Has thanked: 0 time
Been thanked: 0 time

Re: merge the records from 3 input files into 1 output file alte

 

Re: merge the records from 3 input files into 1 output file

Postby Aki88 » Sun Jan 24, 2016 4:03 pm

Hello,

One way of doing it can be (and this is assuming, the 3 files have same LRECL, and are FB and when you say REC1 or REC2 of any file you mean record 1 or 2- and the three lines of data actually appear in 1 line), using ICETOOL, copy data from each file into a TEMP file - during this process temporarily extend the record using INREC and add SEQNUM to the end of the record; following on, after the copy of data to TEMP file with SEQNUM added, have a SORT FIELDS step which sorts the data on the SEQNUM; while writing the record to output file, BUILD the record excluding SEQNUM.
That should do the trick, as all the three files will have records arranged in sequence, so when the final SORT FIELDS will actually run, it'll group the data according to the individual sequence numbers.

Hth.
Aki88
 
Posts: 338
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 32 times
Been thanked: 31 times

Re: merge the records from 3 input files into 1 output file

Postby NicC » Sun Jan 24, 2016 7:30 pm

See my post in response to the same query under Syncsort.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2602
Joined: Sun Jul 04, 2010 12:13 am
Location: Not where I would like to be
Has thanked: 4 times
Been thanked: 92 times

Re: merge the records from 3 input files into 1 output file

Postby MFUSERVDC » Sun Jan 24, 2016 10:14 pm

Hi Aki88,
Thanks for quick reply.
I guess, the logic you explained in above post is perfect when 3 lines of data appearing in 1 record. But I want to merge group (some lines ) of data from 1st file and then some lines from 2nd and similarly from 3rd input file into one output file. This is not happening with above logic.

Thanks,
MFUSERVDC
MFUSERVDC
 
Posts: 4
Joined: Sun Jan 24, 2016 9:05 am
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post