Page 2 of 2

Re: Matching files with different length

PostPosted: Tue Feb 10, 2009 2:05 am
by Frank Yaeger
Here's a DFSORT/ICETOOL job for your new requirement:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/124)
//IN2 DD DSN=...  input file2 (FB/2)
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//  DD *
  OUTFIL FNAMES=OUT2,SAVE
/*
//OUT1 DD DSN=...  output file1 (FB/124)
//OUT2 DD DSN=...  output file2 (FB/124)
//TOOLIN DD *
COPY FROM(IN2) USING(CTL1)
COPY FROM(IN1) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,
    HEADER1=(' OUTFIL FNAMES=OUT1,INCLUDE=(1,1,CH,NE,1,1,CH,OR,'),
    BUILD=(C'  17,2,CH,EQ,C''',1,2,C''',OR,',80:X),
    TRAILER1=('  1,1,CH,NE,1,1,CH)')
/*

Re: Matching files with different length

PostPosted: Tue Feb 10, 2009 2:28 pm
by pulcinella
Thank you frank for your help.

I would like to explain the following,

In your first example when you compare the position 31,1 with the position 1,1 you used:

//CTL1CNTL DD *
OUTFIL FNAMES=CTL2CNTL,REMOVECC,
HEADER1=(' INCLUDE FORMAT=CH,COND=(1,1,NE,1,1,OR,'),
BUILD=(C' 31,1,EQ,C''',1,1,C''',OR,',80:X),
TRAILER1=(' 1,1,NE,1,1)')
/*

When I want to compare the position 17,2 with position 1,2 I used

//CTL1CNTL DD *
OUTFIL FNAMES=CTL2CNTL,REMOVECC,
HEADER1=(' INCLUDE FORMAT=CH,COND=(1,2,NE,1,2,OR,'),
BUILD=(C' 17,2,EQ,C''',1,2,C''',OR,',80:X),
TRAILER1=(' 1,2,NE,1,2)')
/*

because I thought that I must change the header1 and trailer1 put 1,2 instead 1,1

In your new example you used

//CTL1CNTL DD *
OUTFIL FNAMES=CTL2CNTL,REMOVECC,
HEADER1=(' OUTFIL FNAMES=OUT1,INCLUDE=(1,1,CH,NE,1,1,CH,OR,'),
BUILD=(C' 17,2,CH,EQ,C''',1,2,C''',OR,',80:X),
TRAILER1=(' 1,1,CH,NE,1,1,CH)')
/*

then, I should not be changed the header1 and trailer1 and only changed build

Thank you very much

Re: Matching files with different length

PostPosted: Tue Feb 10, 2009 9:48 pm
by Frank Yaeger
HEADER1 and TRAILER1 are just creating "NOP" conditions to make it easier to generate the correct syntax for the INCLUDE statement:

    INCLUDE COND=(1,1,CH,NE,1,1,CH,OR,           <-  HEADER1
       condition1,                 <--- BUILD line 1
       condition2,                 <--- BUILD line 2
       ...
      1,1,CH,NE,1,1,CH)       <--- TRAILER1


BUILD creates the real conditions for comparison from the input records.

HEADER1 and TRAILER1 just create the first line and last line required for the INCLUDE syntax. That way, we don't have to identify the first line and last line in the input data set. The conditions created by HEADER1 for the first line and by TRAILER1 for the last line just have to never be true so they won't include any records. 1,1,CH,NE,1,1,CH does that. You can use 1,2,CH,NE,1,2,CH if you like but there's no reason to.

Re: Matching files with different length

PostPosted: Wed Feb 11, 2009 12:12 am
by pulcinella
Hello Frank,
I greatly appreciate your help
thank you