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

Comparison between files and to create a new file based on


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

New User


Joined: 28 Feb 2007
Posts: 8
Location: India

PostPosted: Thu Mar 01, 2007 2:35 am
Reply with quote

I have a requirement like this.
I am having 2 files FileA and FileB. I am comparing fileA with FileB.I have to create 2 files based on the comparison.If the File A is blank and file B has records all the records of File B has to be written to a insert dataset.If the FileA and FileB has records the condition should be
A)The records which are common to both fileA and fileB need to be eliminted
B)IF the key is only 12 in length starting from position one and filelength is 80,So whatever records which are differing which have the same key in fileA and fileB and which differ only from position 13-80 need to created in a seperate DSN as updated records
c) the records which differ are in fileB and which differ in key field with fileA should come as inserted records
d)the records which differ are in fileA and which differ in key field with fileB should come as Deleted records
eg
FileA
000000000001 AB
000000000002 A2
000000000003 A3
000000000004 A4
000000000005 A5
000000000011 A5
000000000012 A5
FileB
000000000001 AD
000000000002 A2
000000000003 B3
000000000004 A4
000000000009 A5
000000000006 A6
And the final o/p file should be
Updated file o/p1
000000000001 AD
000000000003 B3
o/p2(inserted records)
000000000006 A6
000000000009 A5
o/p3(deleted records)
000000000011 A5
000000000012 A5
000000000005 A5
The records should of the following format if both files have records

If the fileA is blank and fileb has records the o/p should be of folloing format
FileA
.................
.................
.................

FileB
000000000001 AD
000000000002 A2
000000000003 B3
000000000004 A4
000000000009 A5
000000000006 A6
Updated file o/p1(ie, blank)
.................
.................
.................
o/p2(inserted records)
000000000001 AD
000000000002 A2
000000000003 B3
000000000004 A4
000000000009 A5
000000000006 A6
o/p3(deleted records)(blank)
.................
.................
.................
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: Thu Mar 01, 2007 3:19 am
Reply with quote

I suspect you can use some variation of the technique shown in the "Create files with matching and non-matching records" Smart DFSORT Trick at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
Ralph_67

New User


Joined: 28 Feb 2007
Posts: 8
Location: India

PostPosted: Thu Mar 01, 2007 4:33 am
Reply with quote

I used the the following code for above requirement

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=...  input file1
//IN2 DD DSN=...  input file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS) <--- MOD
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)  <--- not MOD
//UPDATE DD DSN=...  output file1
//INSERT DD DSN=...  output file2
//DELETE DD DSN=...  output file3
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(T2) ON(1,80,CH) NODUPS
SPLICE FROM(T2) TO(UPDATE) ON(1,3,CH) -
  KEEPNODUPS WITH(1,81) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'11')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'22')
/*
//CTL3CNTL DD *
  SORT FIELDS=(1,3,CH,A,81,2,CH,A)   
  OUTFIL FNAMES=UPDATE,INCLUDE=(81,2,CH,EQ,C'21'),
    BUILD=(1,80)
  OUTFIL FNAMES=INSERT,INCLUDE=(81,2,CH,EQ,C'22'),
    BUILD=(1,80)
  OUTFIL FNAMES=DELETE,INCLUDE=(81,2,CH,EQ,C'11'),
     BUILD=(1,80)
/*


The code is working fine for both inserted updated and deleted records if both files has records.But if the file1 is blank and file2 had records lot of records getting truncated ie, If the file1 is blank and file2 has records all the records in file2 should come in inserted records rite? But instead of that lot of records are getting lost in the inserted record file
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: Thu Mar 01, 2007 9:27 pm
Reply with quote

Your job doesn't match the input record you originally showed. You seem to be using 1-3 as the key in your job, but in your first post you showed input records like this:

000000000001 AB

Please show input and output records that match your job.
Back to top
View user's profile Send private message
Ralph_67

New User


Joined: 28 Feb 2007
Posts: 8
Location: India

PostPosted: Thu Mar 01, 2007 11:16 pm
Reply with quote

FileA
001 AB
002 A2
003 A3
004 A4
005 A5
011 A5
012 A5
FileB
001 AD
002 A2
003 B3
004 A4
009 A5
006 A6
And the final o/p file should be
Updated file o/p1
001 AD
003 B3
o/p2(inserted records)
006 A6
009 A5
o/p3(deleted records)
011 A5
012 A5
005 A5
The records should of the following format if both files have records

If the fileA is blank and fileb has records the o/p should be of folloing format
FileA
.................
.................
.................

FileB
001 AD
002 A2
003 B3
004 A4
009 A5
006 A6
Updated file o/p1(ie, blank)
.................
.................
.................
o/p2(inserted records)
001 AD
002 A2
003 B3
004 A4
009 A5
006 A6
o/p3(deleted records)(blank)
.................
.................
.................


The code is working fine when both the fileA and fileb has records .But if if the fileA is blank and Fileb has records lot of records are getting truncated.When i analysed the truncation is happeneing in step SELECT FROM(T1) TO(T2) ON(1,80,CH) NODUPS .But since the fileA is blank and Fileb has records truncation shouldn't happen at that step.

Could you please help in this regard?

Hope the input and output is clear
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: Fri Mar 02, 2007 12:37 am
Reply with quote

If you had blank records in fileA, the SELECT with NODUPS would remove them. NODUPS says to keep records that don't have duplicates. Since all of the blank records would be duplicates, they would not be selected.

(I don't know what you mean by "truncated" - it normally means that bytes at the end of a record are dropped. But you seem to be using it to mean something else.)
Back to top
View user's profile Send private message
Ralph_67

New User


Joined: 28 Feb 2007
Posts: 8
Location: India

PostPosted: Fri Mar 02, 2007 1:54 am
Reply with quote

I mean the records in fileb is getting dropped.ie, If fileA is blank and fileb has 1100 after the statement SELECT FROM(T1) TO(T2) ON(1,80,CH) NODUPS more than 300 records is getting dropped. As per the scenario since the fileA is blank all the records in fileb should come in final output rite? could you please suggest me how we can avoid the dropping of recordsinorder to get all reords in my output file.ie, if FileA is blank what changes can i make in the above code to get all records in Fileb to out put file

Thnaks a lot in advance
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: Fri Mar 02, 2007 5:03 am
Reply with quote

I really don't understand your scenario with regard to blank records in FileA.

When I run with blank records in FileA, I get all of the FileB records in the INSERT file and no records in the UPDATE and DELETE files. With blank records in FileA, none of the records in FileB have a match in FileA, so why wouldn't they be considered as inserted? Why would you expect blank records in the UPDATE and DELETE files?

I suppose if that's what you really want, you could specifically tag blank records with a sequence number so NODUPS won't eliminate them. Then you could specifically INCLUDE them in the UPDATE and DELETE files.
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 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
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top