IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Date Range File comparison


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Wed Feb 02, 2011 2:39 pm
Reply with quote

Hi
How to perform the following in DFSORT?
Can this be performed using JOINKEYS

Input File-1 (will have only one record)
1,10 and 11,10 are two dates
Code:
----+----1----+----2
2011-01-012011-12-31


Input File-2 (will have n records)
4,10 is a date field
Code:
----+----1---
OPQ2010-01-01
ABC2011-01-01
CDE2011-02-10
EFG2011-03-20
GHI2011-04-30
IJK2011-05-01
LMN2012-01-01


Output File(should contain records from Input File-2. Comparison is 4,10 of file 2 which are greater than 1,10 and lesser than 2,10 of file 1)

Code:
----+----1---
ABC2011-01-01
CDE2011-02-10
EFG2011-03-20
GHI2011-04-30
IJK2011-05-01
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 02, 2011 10:26 pm
Reply with quote

HameedAli,

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//INA      DD *                                         
OPQ2010-01-01                                           
ABC2011-01-01                                           
CDE2011-02-10                                           
EFG2011-03-20                                           
GHI2011-04-30                                           
IJK2011-05-01                                           
LMN2012-01-01                                           
//INB      DD *                                         
2011-01-012011-12-31                                     
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK         
  JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK         
  REFORMAT FIELDS=(F1:1,80,F2:1,20)                     
  OUTFIL BUILD=(1,80),                                   
  INCLUDE=(4,10,CH,GE,81,10,CH,AND,4,10,CH,LE,91,10,CH) 
//JNF1CNTL DD *                                         
  INREC OVERLAY=(81:C'1')                               
//JNF2CNTL DD *                                         
  INREC OVERLAY=(81:C'1')                               
//*
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Feb 03, 2011 3:03 pm
Reply with quote

Skolusu, it was of great help and very precise.

I don't understand the significance of the CNTL cards.
how 4,10 refers to INB not INA
and the (81,1,A)SORTED,NOSEQCK

Quote:
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80,F2:1,20)
OUTFIL BUILD=(1,80),
INCLUDE=(4,10,CH,GE,81,10,CH,AND,4,10,CH,LE,91,10,CH)
//JNF1CNTL DD *
INREC OVERLAY=(81:C'1')
//JNF2CNTL DD *
INREC OVERLAY=(81:C'1')

//*
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Feb 03, 2011 5:19 pm
Reply with quote

Is it possible to SORT while using JOINKEYS, I tried SORT FIELDS(1,3,CH,A). The step went fine, but the output wasn't sorted.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 03, 2011 10:53 pm
Reply with quote

HameedAli wrote:
I don't understand the significance of the CNTL cards.
how 4,10 refers to INB not INA and the (81,1,A)SORTED,NOSEQCK


HameedAli,

Since your files did not have a key to match from both files, we pad an arbitrary value of '1' in both files at the end of the record and use that as a matching key. Since we are padding the extra byte and we know it is sorted, so there is no need for sorting during match. SORTED,NOSEQCK tells DFSORT not to check the order of the records which can improve performance.

HameedAli wrote:
Is it possible to SORT while using JOINKEYS, I tried SORT FIELDS(1,3,CH,A). The step went fine, but the output wasn't sorted.


Yes it is possible. Replace the OPTION COPY statement with SORT FIELDS=(1,3,CH,A).

I am assuming that you did not remove the OPTION COPY statement and just added SORT statement which DFSORT ignored as OPTION COPY was used.
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Fri Feb 04, 2011 5:35 pm
Reply with quote

Thanks for the detailed response Skolusu.

Performance wise which is better?
1) Sorting step separately and then perform JOIN step separately.
2) SORT and JOIN in same step?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Feb 04, 2011 8:32 pm
Reply with quote

Hello,

Quote:
Performance wise which is better?
Your mileage may vary. . .

Suggest you try both with the "real" data (not some subset) and determine which is better for you.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top