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

Merged file to remove duplicate so order is not affected


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
subarna roy

New User


Joined: 07 Dec 2007
Posts: 16
Location: mumbai

PostPosted: Fri Feb 08, 2008 12:44 pm
Reply with quote

Hi
I need to merge two file and I need to remove the duplicates based upon some specific field ( eg class number), but whenever i am doing so, the out put file is getting sorted in the order of the sort field.
But business need is the files should be merged , and the records in the merged file should be in order as they were in the individual file. And also the merged file shud not contain any duplicate records with same class number( the field name i had mentioned above) only.

Please help me.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Feb 08, 2008 3:10 pm
Reply with quote

subarna roy

Is your req like this?
FILE-1
Code:

A1
A1
C3
V4


FILE-2
Code:

A2
C4
V5



The o/p should be
Expected O/p
Code:

A1
C3
V4
A2
C4
V5
Back to top
View user's profile Send private message
subarna roy

New User


Joined: 07 Dec 2007
Posts: 16
Location: mumbai

PostPosted: Fri Feb 08, 2008 3:26 pm
Reply with quote

hi krisprems,

you are right.


Thanks
Subarna
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Feb 08, 2008 5:08 pm
Reply with quote

Hi subarna roy,

Let us assume files are with RECFM=F or RECFM=FB and LRECL=80.
Let us assume the class number field starts in position 7 and length 7.
Please check with the following code for your requirement.
Suppose if the class number is in both file1 and file2, the following code will keep only one class number from file1 in output.
Code:
// EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//FILE1 DD DSN=FILE1,DISP=SHR
//FILE2 DD DSN=FILE2,DISP=SHR
//T1 DD DSN=&&T1,DISP=(MOD,CATLG)
//T2 DD DSN=&&T1,DISP=(,CATLG)
//OUT DD SYSOUT=*
//TOOLIN DD *
 COPY FROM(FILE1) TO(T1) USING(CTL1)
 COPY FROM(FILE2) TO(T1) USING(CTL2)
 SELECT FROM(T1) TO(T2) ON(7,7,CH) FIRST
 SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
 INREC OVERLAY=(81:C'1',SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
 INREC OVERLAY=(81:C'2',SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
 SORT FIELDS=(81,9,CH,A)
 OUTFIL OUTREC=(1,80)
/*
//

Thanks,
Shankar
Back to top
View user's profile Send private message
subarna roy

New User


Joined: 07 Dec 2007
Posts: 16
Location: mumbai

PostPosted: Fri Feb 08, 2008 5:59 pm
Reply with quote

Hi Shankar

Will this code be appropriate if i need to merge 11 files and then want to remove the duplicates on the basis of a particuler field?

Regards
Subarna
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Sun Feb 10, 2008 2:36 pm
Reply with quote

Well i dont think that there will be any problem, you can merge as many files you want to merge by using the JCL posed by shankar.v.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Feb 11, 2008 11:11 am
Reply with quote

Hi subarna roy,

Let us assume files are with RECFM=F or RECFM=FB and LRECL=80.
Let us assume the class number field starts in position 7 and length 7.
Please check with the following code for your requirement.
Suppose if the class number is in both file1 and file2, the following code will keep only one class number from file1 in output.
Code:
// EXEC PGM=ICETOOL                                       
//DFSMSG DD SYSOUT=*                                       
//TOOLMSG DD SYSOUT=*                                     
//FILES DD DSN=FILE1,DISP=SHR                                               
//      DD DSN=FILE2,DISP=SHR
//      DD DSN=FILE3,DISP=SHR
//      .
//      .
//      .
//      DD DSN=FILEn,DISP=SHR                                             
//T1 DD DSN=&&T1,DISP=(,DELETE)                           
//OUT DD SYSOUT=*                                         
//TOOLIN DD *                                             
 SELECT FROM(FILES) TO(T1) ON(7,7,CH) FIRST USING(CTL1)   
 SORT FROM(T1) TO(OUT) USING(CTL2)                         
/*                                                                                                       
//CTL1CNTL DD *                                           
 INREC OVERLAY=(81:SEQNUM,9,ZD)                           
/*                                                         
//CTL2CNTL DD *                                           
 SORT FIELDS=(81,9,CH,A)                                   
 OUTFIL OUTREC=(1,80)                                     
/*
//

Thanks,
Shankar
Back to top
View user's profile Send private message
subarna roy

New User


Joined: 07 Dec 2007
Posts: 16
Location: mumbai

PostPosted: Mon Feb 11, 2008 2:32 pm
Reply with quote

Hi
Thanks...it worked.



Regards
Subarna
Back to top
View user's profile Send private message
subarna roy

New User


Joined: 07 Dec 2007
Posts: 16
Location: mumbai

PostPosted: Tue Feb 12, 2008 11:58 am
Reply with quote

Hi

The above code mentioned by Shankar was working fine, but as per business need we can't use ICETOOL, they r suggesting to use SYNC SORT. Can u pls tell me how I can do it with SYNC SORT or something else ( other than ICE TOOL)
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Feb 12, 2008 10:33 pm
Reply with quote

The ICETOOL application should work with SyncSort as well. However, if for some reason, you are prevented from coding PGM=ICETOOL in your shop, try PGM=SYNCTOOL.

As an alternative, you can convert the ICETOOL application to a SORT job:
Code:

//SORT1 EXEC PGM=SORT                             
//SORTIN  DD DSN=FILE1,DISP=SHR
//        DD DSN=FILE2,DISP=SHR
//         .
//         .
//        DD DSN=FILEn,DISP=SHR
//SYSOUT  DD SYSOUT=*                                 
//SORTOUT DD DSN=&&SRT1,DISP=(NEW,PASS)             
//SYSIN   DD *                                       
    INREC OVERLAY=(81:SEQNUM,9,ZD)                   
    SORT FIELDS=(7,7,CH,A),EQUALS                     
    SUM FIELDS=NONE                                   
//**************************************************   
//SORT2 EXEC PGM=SORT                             
//SORTIN  DD DSN=&&SRT1,DISP=(OLD,PASS)               
//SYSOUT  DD SYSOUT=*                                 
//SORTOUT DD DSN=FINAL.OUTPUT,DISP=(NEW,CATLG)
//SYSIN   DD *                                         
    SORT FIELDS=(81,9,CH,A)                           
    OUTREC FIELDS=(1,80) 
/*

Please note that both ICETOOL and the SORT application are passing the data twice.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
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