Page 1 of 1

Comparing 2 files on the basis of Date

Posted: Mon Feb 27, 2012 7:47 pm
by rajat_kharbanda
Hi,

I've been banging my head on this. It would be great if anyone could help. Note - I have to use ICETOOL/DFSORT to get the below result.

I have 2 files -

F1 - LRECL=100,RECFM=FB with date field in the form of YYYY-MM-DD(10 bytes) starting at position 15 (15-24).
F2 - LRECL=80,RECFM=FB. This is a date file with only one record. First 10 bytes being the current batch date and the enxte 10 bytes (11-20) being the previous batch date. Format of dates - YYYY-MM-DD.

I want to retrieve the first 14 bytes from all the records in F1 where the date (15-24) is less than or equal to the previous date in F2(11-20).

It would be great if anyone could help me on an urgent basis.

Let me know if any more details are required.

Thanks
Rajat Kharbanda

Posted: Tue Feb 28, 2012 12:48 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file2 (FB/80)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INREC BUILD=(C'PREVDATE,''',11,10,C'''',80:X)
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file1 (FB/100)
//SORTOUT DD DSN=...  output file (FB/14)
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(15,10,CH,LE,PREVDATE)
  OUTREC BUILD=(1,14)
/*

Posted: Tue Feb 28, 2012 3:06 pm
by rajat_kharbanda
Brilliant. I knew I could do it with SYMNAMES but just missed on how to go about it. Thanks Frank. :)

Posted: Tue Feb 28, 2012 10:18 pm
by tamilselvan.sampath
frank why you gave that 80:x in jcl. if i didnt gave that its not working...

Posted: Tue Feb 28, 2012 11:41 pm
by Frank Yaeger
The SYMNAMES data set has to have RECFM=FB and LRECL=80. The 80:X ensures that the Symbol statement is padded with blanks on the right, and that the LRECL of the SYMNAMES data set is set to 80 automatically.

Posted: Wed Feb 29, 2012 8:18 pm
by tamilselvan.sampath
but while creating the dataset i gave lrecl=80,then is that necessary we need to give 80:x

Posted: Wed Feb 29, 2012 11:23 pm
by Frank Yaeger
Using 80:X ensures that the SYMNAMES record is padded on the right with blanks. If you don't use 80:X, you'll get binary zero padding on the right which can result in a syntax error. If you specify LRECL=80 for the SYMNAMES data set, you could probably get away with using:

Code: Select all

    INREC BUILD=(C'PREVDATE,''',11,10,C'''',X)  
so you get one blank after the SYMNAMES statement. But what's the problem with specifying 80:X?