Another daunting task

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

Another daunting task

Post by bernix » Thu Mar 31, 2011 2:32 pm

I've got 2 Files with a common key. One file additionally has a date

Example

File 1
AAA
DDD
EEE

File 2
2011-03-01AAA
2011-02-01AAA
2011-01-01AAA
2010-12-01AAA
2011-01-01BBB
2011-03-01BBB
2011-02-01CCC
2011-01-01CCC
2010-12-01CCC
2010-03-01EEE

My task is to create a file with records of File2 that
- either the key occurs in file1
- or are younger than 2010-02-28 (regardless of the key)

My desired result would be

File 2
2011-03-01AAA
2011-02-01AAA
2011-01-01AAA
2010-12-01AAA
2011-03-01BBB
2010-03-01EEE

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

Post by Frank Yaeger » Thu Mar 31, 2011 11:24 pm

I don't know why you included

2011-03-01BBB

in your expected output file. It doesn't seem to meet either of your criteria.

However, here's a DFSORT job that does what you described:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=... input file1
//IN2 DD DSN=... input file2
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,3,A)
  JOINKEYS F2=IN2,FIELDS=(11,3,A)
  JOIN UNPAIRED,F2
  REFORMAT FIELDS=(F2:1,13,?)
  OPTION COPY
  OUTFIL INCLUDE=(14,1,CH,EQ,C'B',OR,
    1,10,CH,LT,C'2010-02-28'),BUILD=(1,13)
/*
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

bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

Post by bernix » Fri Apr 01, 2011 1:33 pm

I included the record you mentioned because it is younger than 2011-02-28 but still i got the idea and i amended your DFSORT to

Code: Select all

   JOINKEYS F1=IN1,FIELDS=(1,3,A)                                    
   JOINKEYS F2=IN2,FIELDS=(11,3,A)                                   
   JOIN UNPAIRED,F2                                                  
   REFORMAT FIELDS=(F2:1,13,F1:1,3)                                  
   OPTION COPY                                                       
   OUTFIL INCLUDE=((14,1,CH,EQ,C' ',AND,1,10,CH,GT,C'2011-02-28'),OR,
    14,1,CH,NE,C' '),BUILD=(1,13)                                    
   END                                                               
and BINGO !!

Thank you, thak you, thank you
Great help !!!

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

Post by Frank Yaeger » Fri Apr 01, 2011 9:53 pm

From your first post
or are younger than 2010-02-28 (regardless of the key)
From your latest post
because it is younger than 2011-02-28
Oh, I see - you said 2010-02-28, but you actually meant to say 2011-02-28.

Anyway, glad I could help.
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