Combing two files of same RLENGTH



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Combing two files of same RLENGTH

Postby pahi » Wed Nov 11, 2009 3:36 pm

Hi,

I have a file1 has:

00123456 optonal test 123
00123478 optonal test 234
00123490 optonal test 567

and file2 has:

0500344
0500345
0500347

I have used the below sort jcl to get the o/p file has:

00123456 optonal test 123
0500344
00123478 optonal test 234
0500345
00123490 optonal test 567
0500347
but in my o/p file the file1 is appending to the file2 data, so could any please help me where i have gone wrong:

//SORTTS1  EXEC PGM=SORT,COND=(0,LT)                   
//SORTLIB  DD DSN=SYS1.SORTLIB,DISP=SHR                 
//SORTIN   DD DSN=i/p.file1,DISP=SHR
//SORTOUT  DD DSN=o/p.file1,DISP=OLD         
//SRTMSGE  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                         
    SORT FIELDS=(1,2,CH,A)                             
    INCLUDE COND=(1,2,CH,EQ,C'00',OR,1,2,CH,EQ,C'05') 
/*
//SORT0Q   EXEC PGM=SORT,COND=(0,LT)                     
//SORTLIB  DD DSN=SYS1.SORTLIB,DISP=SHR                   
//SORTIN   DD  DSN=i/p.file2,DISP=SHR 
//SORTOUT  DD  DSN=o/p.file2,DISP=SHR         
//SRTMSGE  DD SYSOUT=*                                   
//SYSOUT   DD  SYSOUT=*                                   
//SYSIN    DD  *                                         
 SORT FIELDS=(1,10,CH,A)                                 
 INCLUDE COND(1,2,CH,EQ,C'05')                           
/*                 
//MERGE1   EXEC PGM=SORT,COND=(0,LT)                 
//SORTLIB  DD DSN=SYS1.SORTLIB,DISP=SHR             
//SRTMSGE  DD SYSOUT=*                               
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD DSN=o/p.file1,DISP=SHR     
//              DD DSN=o/p.file2,DISP=SHR     
//SORTOUT  DD DSN=o/p.file,DISP=OLD
//SYSIN    DD  *                                     
  SORT FIELDS=(1,2,CH,A,1,10,CH,A)                   
/*                                                   
 
pahi
 
Posts: 27
Joined: Wed Apr 01, 2009 3:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combing two files of same RLENGTH

Postby Bill Dennis » Wed Nov 11, 2009 10:32 pm

By sorting on columns 1 - 2 you will always get the '05' records at the end of the '00' records, not intermixed as in your example. Explain further about your desired o/p sequence.
Regards,

Bill Dennis

Disclaimer: My comments on this forum are my own and do not represent the opinions or suggestions of any other person or business entity.
Bill Dennis
 
Posts: 278
Joined: Thu May 15, 2008 9:45 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combing two files of same RLENGTH

Postby Frank Yaeger » Wed Nov 11, 2009 11:05 pm

Pahi,

Do you just want the records in the following output sequence:

input file1 record 1
input file2 record 1
input file1 record 2
input file2 record 2
....

or do you want something else? If something else, explain clearly what you want to do.

What is the RECFM and LRECL of each input file?
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: Combing two files of same RLENGTH

Postby pahi » Thu Nov 12, 2009 9:01 am

Hi Frank,

Yes i would like to have the output has:

input file1 record 1
input file2 record 1
input file1 record 2
input file2 record 2
....

The RECFM is FB and LRECL is 60 of boththe input file.

Regards,
Pahi
pahi
 
Posts: 27
Joined: Wed Apr 01, 2009 3:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combing two files of same RLENGTH

Postby Frank Yaeger » Thu Nov 12, 2009 10:27 pm

Assuming that the records in input file1 start with C'00' and the records in input file2 don't, you can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file1 (FB/60)
//       DD DSN=... input file2 (FB/60)
//SORTOUT DD DSN=...  output file (FB/60)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'00'),
      OVERLAY=(61:SEQNUM,8,ZD,START=1,INCR=2)),
    IFTHEN=(WHEN=NONE,
      OVERLAY=(61:SEQNUM,8,ZD,START=2,INCR=2))
  SORT FIELDS=(61,8,ZD,A)
  OUTREC BUILD=(1,60)
/*
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


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post