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

Comparing 2 files


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

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Fri Apr 01, 2011 5:23 pm
Reply with quote

Hi,

I have 2 FB files of length 80 bytes. The key values are 2 fields of 6 bytes (1-6) and 4 bytes (7-10) and there can be duplicates for this in the first file. The second file will be a lookup key value file and will not have duplicates.

File1 (Bytes 16-80 are fillers)
AAAAAAYYYYTEST1
AAAAAAYYYYTEST2
AAAAAAZZZZTEST1
AAAAAAZZZZTEST2
AAAAAAZZZZTEST3
BBBBBBYYYYTEST5

File2 (Bytes 11-80 are fillers)
AAAAAAXXXX
AAAAAAYYYY

I need to create an output file that has records in file1 that are not in file2 based on key comparison of key1 and key2- but with some indicator to differentiate if key1 is present but not key2 or if key1 is not at all present in file2.

Output
AAAAAAZZZZTEST1 "Only key2"
AAAAAAZZZZTEST2 "Only key2"
AAAAAAZZZZTEST3 "Only key2"
BBBBBBYYYYTEST5 "Key1 "

This can be done by 2 separate splice/join keys comparing both keys and comparing and merging the files - can this be done in a single step/better way?

Thanks,
Aneesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Apr 02, 2011 12:45 am
Reply with quote

I think you mean in a single "pass". It could certainly be done in a single "step" using multiple ICETOOL operators.

I can't think of a way to do it in a single pass.
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Sat Apr 02, 2011 10:43 am
Reply with quote

Hi Frank,

Yes - Single pass would have been amazing.

Even a single step approach - could you please let me know if you meant the below steps when you mentioned multiple operators in a single step?

First a splice for the full key
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(01,10,CH) WITHALL WITH(01,15) -
KEEPNODUPS KEEPBASE USING(CTL3)
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OVERLAY=(51:1,9,80:X)
//CTL2CNTL DD *
OUTFIL FNAMES=T1
//CTL3CNTL DD *
OUTFIL FNAMES=T2,INCLUDE=(11,5,CH,NE,C' ')

Then repeating similar steps above for a splice using the first key (01,6) and then merging.

Thanks,
Aneesh.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Apr 05, 2011 12:59 am
Reply with quote

You could use a one step DFSORT/ICETOOL job with JOINKEYS like the following to do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
AAAAAAYYYYTEST1
AAAAAAYYYYTEST2
AAAAAAZZZZTEST1
AAAAAAZZZZTEST2
AAAAAAZZZZTEST3
BBBBBBYYYYTEST5
/*
//IN2 DD *
AAAAAAXXXX
AAAAAAYYYY
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY JKFROM TO(T1) USING(CTL1)
COPY JKFROM TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  JOINKEYS F1=IN1,FIELDS=(1,10,A),TASKID=A1
  JOINKEYS F2=IN2,FIELDS=(1,10,A),TASKID=A1
  JOIN UNPAIRED,F1,ONLY
  REFORMAT FIELDS=(F1:1,80)
  OPTION COPY
/*
//CTL2CNTL DD *
  JOINKEYS F1=T1,FIELDS=(1,6,A),TASKID=A2
  JOINKEYS F2=IN2,FIELDS=(1,6,A),TASKID=A2
  JOIN UNPAIRED,F1
  REFORMAT FIELDS=(F1:1,80,?)
  OPTION COPY
  OUTREC IFOUTLEN=80,
   IFTHEN=(WHEN=(81,1,CH,EQ,C'B'),
    OVERLAY=(17:C'"Only key2"')),
   IFTHEN=(WHEN=NONE,OVERLAY=(17:C'"Key1"'))
/*
//A2F2CNTL DD *
  SUM FIELDS=NONE
/*
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top