Comparing 2 files on the basis of Date

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Comparing 2 files on the basis of Date

Post by rajat_kharbanda » Mon Feb 27, 2012 7:47 pm

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Feb 28, 2012 12:48 am

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)
/*
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

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Tue Feb 28, 2012 3:06 pm

Brilliant. I knew I could do it with SYMNAMES but just missed on how to go about it. Thanks Frank. :)

tamilselvan.sampath
Member
Posts: 26
Joined: Mon Jan 23, 2012 11:17 pm

Post by tamilselvan.sampath » Tue Feb 28, 2012 10:18 pm

frank why you gave that 80:x in jcl. if i didnt gave that its not working...

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Feb 28, 2012 11:41 pm

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.
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

tamilselvan.sampath
Member
Posts: 26
Joined: Mon Jan 23, 2012 11:17 pm

Post by tamilselvan.sampath » Wed Feb 29, 2012 8:18 pm

but while creating the dataset i gave lrecl=80,then is that necessary we need to give 80:x

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Feb 29, 2012 11:23 pm

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?
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

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others