Page 1 of 1

Combing two files of same RLENGTH

PostPosted: Wed Nov 11, 2009 3:36 pm
by pahi
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)                   
/*                                                   
 

Re: Combing two files of same RLENGTH

PostPosted: Wed Nov 11, 2009 10:32 pm
by Bill Dennis
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.

Re: Combing two files of same RLENGTH

PostPosted: Wed Nov 11, 2009 11:05 pm
by Frank Yaeger
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?

Re: Combing two files of same RLENGTH

PostPosted: Thu Nov 12, 2009 9:01 am
by pahi
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

Re: Combing two files of same RLENGTH

PostPosted: Thu Nov 12, 2009 10:27 pm
by Frank Yaeger
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)
/*