merge file with dfsort



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

merge file with dfsort

Postby cpzbn » Thu Oct 15, 2009 10:10 pm

question 1: I have two files(file A, file B), the record length of file A is 100, and file B is 200, can merge the above two files into one output file with record length 300 in one step?
quesion 2:I have one file with several records below:
123A001XXXXXXXXXX
3424A002sjkXXXXXXX
14A003sjkXXXXXXXXX
15645A004XXXXXXXXX
..........................

i only want to select the string start with A(noted: The position of A in each record is different) for 4 bytes for each record and output into file, so the result of above file after sort should be:
A001
A002
A003
A004
.....
cpzbn
 
Posts: 4
Joined: Thu Oct 15, 2009 9:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: merge file with dfsort

Postby Frank Yaeger » Fri Oct 16, 2009 1:07 am

1. Do the files have RECFM=FB or RECFM=VB? If the files have RECFM=FB then you cannot "merge" (or "copy") them in one pass, but you can do it in one step with DFSORT's ICETOOL. If the files have RECFM=VB, you can "merge" (or "copy") them in one pass.

However, it's not clear if you really want to "merge" which would involve a key on which both files were previously sorted, or just copy them one after the other. Tell me which it is and the RECFM and I'll show you how to do it with ICETOOL (if you really want to merge, also tell me the starting position, length and format of the key).

2. You can use a DFSORT job like the following for that:

//S1    EXEC  PGM=SORT                             
//SYSOUT    DD  SYSOUT=*                           
//SORTIN DD *                                       
123A001XXXXXXXXXX                                   
3424A002sjkXXXXXXX                                 
14A003sjkXXXXXXXXX                                 
15645A004XXXXXXXXX                                 
//SORTOUT DD SYSOUT=*                               
//SYSIN    DD    *                                 
  OPTION COPY                                       
  INREC PARSE=(%01=(STARTAT=C'A',FIXLEN=4)),       
    BUILD=(%01)                                     
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: merge file with dfsort

Postby cpzbn » Fri Oct 16, 2009 9:09 pm

Frank,

Really thanks for your detail answer and suggestion.

For question 1, both the input files are FB. The position of key of file A or file B are not fixed,and the length of key are also not fixed, but the key(both file A and file B) started with '#' and end with '%',the key with longest length is 20.i just want to copy the keys of both files one after another.

File A(record length = 100):
9898r5439dfdsj#898%898...
9898r5439d#89%s898fd99...
sdfd8r5fdf439d#8922568%s...
......

File B(record length = 200)
84395843958#88832%898jkjdkfsjfd...
84395843958#8983498548832%898jktrutefsjfd...
98989898fd98sdff#898349832%898jkjdkfsjffd...
.......

Output file(record length =20)- if the key is less than 20, fill in spaces after the key.
12345678901234567890
---------------------------
898SSSSSSSSSSSSSSSS
89SSSSSSSSSSSSSSSSS
8922568SSSSSSSSSSSS
88832SSSSSSSSSSSSSS
8983498548832SSSSSS
898349832SSSSSSSSSS
('S' means space)
cpzbn
 
Posts: 4
Joined: Thu Oct 15, 2009 9:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: merge file with dfsort

Postby skolusu » Fri Oct 16, 2009 9:43 pm

cpzbn,

use the following DFSORT/ICETOOL JCL

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1      DD DSN=Your file1,DISP=SHR
//IN2      DD DSN=Your File2,DISP=SHR
//OUT      DD DSN=Your extract key file,
//            DISP=(MOD,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)       
//TOOLIN   DD *                                             
  COPY FROM(IN1) USING(CTL1)                               
  COPY FROM(IN2) USING(CTL1)                               
//CTL1CNTL DD *                                             
  INREC PARSE=(%01=(STARTAFT=C'#',ENDBEFR=C'%',FIXLEN=20)),
        BUILD=(%01)                                         
  OUTFIL FNAMES=OUT   
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post