Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comparing 2 files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Comparing 2 files
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 Moderator


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

PostPosted: Sat Apr 02, 2011 12:45 am    Post subject:
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    Post subject: Reply to: Comparing 2 files
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 Moderator


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

PostPosted: Tue Apr 05, 2011 12:59 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us