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
 

 

To get first record in case the file has duplicates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
krishna_ragav

New User


Joined: 29 Oct 2010
Posts: 10
Location: Chennai

PostPosted: Fri Jan 20, 2012 11:59 am    Post subject: To get first record in case the file has duplicates
Reply with quote

Hi all,

I have a flat file which can have 2 records with same key. My requirement is to fetch first occurrence among the duplicates from the flat file using DFSORT. Can you guys help me.

Thanks,
Krishna
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Jan 20, 2012 12:03 pm    Post subject:
Reply with quote

http://ibmmainframes.com/post-98317.html
Back to top
View user's profile Send private message
krishna_ragav

New User


Joined: 29 Oct 2010
Posts: 10
Location: Chennai

PostPosted: Fri Jan 20, 2012 1:01 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

I just want to expand the situation. The flat file created contains the records from two input flat files. I have merged these two input files by using DFSORT - MERGE=COPY command.

Now the requirement is changed. I want the records from these two input flat files to be sort/merged and loaded into one VSAM file having key from 1-43 location. In case the two flat files have record with same key, the record from first file has to be loaded into VSAM file directly. We dont want any intermediate workfile.

Thanks,
Krishna
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Jan 20, 2012 3:17 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

nobody prevents You from using as output dataset the VSAM itself
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Jan 20, 2012 3:29 pm    Post subject:
Reply with quote

Quote:
In case the two flat files have record with same key, the record from first file has to be loaded into VSAM file directly.

If both the files have the same LRECL and DSORG then make a concatenated DD statement in SORTIN and use the technique on http://ibmmainframes.com/post-98317.html

If this is not the solution you are looking for, then it would be better if you give us more information, like show the input/output records. LRECL,DSORG of the i/p files.
Back to top
View user's profile Send private message
krishna_ragav

New User


Joined: 29 Oct 2010
Posts: 10
Location: Chennai

PostPosted: Fri Jan 20, 2012 4:13 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

Hi All,

I have tried using JOINKEYS but i do not know how can we use both F1 and F2 Full LRECL Length in REFORMAT. Because

1) I need complete record from F1 if there any key present in both F1 and F2
2) I need complete record F1 if its un-paired record ( i.e. Its available only in F1)
3) I need complete record F2 if its un-paired record ( i.e. Its available only in F2)

We have done using ICETOOL but people wants either DFSORT - SORT Utility( Not with ICETOOL) / Join Keys.

Code:

//PS010   EXEC PGM=ICEMAN                                               
//SYSOUT    DD SYSOUT=*                                                 
//SYSPRINT  DD SYSOUT=*                                                 
//SYSUDUMP  DD SYSOUT=*                                                 
//SORTJNF1  DD DSN=XXXXX.CASVSMOT,DISP=SHR                             
//SORTJNF2  DD DSN=XXXXX.CASMONTH,DISP=SHR                             
//SORTOUT   DD DSN=XXXXX.CASMONTH.TST1,  CAS MONTHLY VSAM               
//             DISP=(NEW,CATLG,DELETE),                                 
//             UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),                     
//             DCB=(SYS3.DSCB,                                         
//             RECFM=VB,LRECL=254,DSORG=PS,BLKSIZE=0)                   
//*                                                                     
//SYSIN     DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(1,43,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,43,A)                                     
  JOIN UNPAIRED,F1     
  REFORMAT FIELDS=(F1:1,250)                                               
  SORT FIELDS=COPY                                                     
//*                   
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Fri Jan 20, 2012 5:15 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

Krishna,

Try this..

1) complete record from F1 if there any key present in both F1 and F2
Code:
 
//SYSIN     DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(1,43,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,43,A)                                           
  REFORMAT FIELDS=(F1:1,250)                                               
  SORT FIELDS=COPY                                                     
//*               

2) complete record F1 if its un-paired record ( i.e. Its available only in F1)
Code:
 
//SYSIN     DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(1,43,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,43,A)                                     
  JOIN UNPAIRED,F1,ONLY                                                     
  SORT FIELDS=COPY                                                     
//*     

3) complete record F2 if its un-paired record ( i.e. Its available only in F2)
Code:

//SYSIN     DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(1,43,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,43,A)                                     
  JOIN UNPAIRED,F2,ONLY                                                 
  SORT FIELDS=COPY                                                     
//*   



Thanks
-3nadh
Back to top
View user's profile Send private message
krishna_ragav

New User


Joined: 29 Oct 2010
Posts: 10
Location: Chennai

PostPosted: Fri Jan 20, 2012 5:28 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

Thank You. I do not wants to increase no of steps

I am also trying other possibilities

Code:
//JS010 EXEC PGM=SORT                                                   
//SORTIN01 DD DSN=XXXX.CASVSMOT.EDIT,DISP=SHR                 
//SORTIN02 DD DSN=XXXX.COMJW.CASMONTH.EDIT,DISP=SHR           
//SORTOUT DD DSN=XXXX.SEQ.CASMONTH,                           
//             DISP=(NEW,CATLG,DELETE),                                 
//             UNIT=PERMDA,SPACE=(CYL,(100,50),RLSE),                   
//             DCB=(SYS3.DSCB,                                         
//             RECFM=VB,LRECL=254,DSORG=PS,BLKSIZE=0)                   
//SYSOUT DD SYSOUT=*                                                   
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN DD *                                                           
   MERGE FIELDS=(1,43,CH,A)                                             
   SUM FIELDS=NONE                                                     
/*                     


It takes the record from second file and writes into output file If the key present in both the file. But I need to write from 1st file if key is available in both the files. Can you please help me.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Jan 20, 2012 5:33 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

the link posted had already given You the reply ...

Code:
//SORTIN    DD <first dataset>
//          DD <second dataset>
//SORTOUT   DD <output dataset> could be the VSAM                       
//SYSIN     DD *                                                       
  OPTION EQUALS                                                       
  SORT   FIELDS=(<position>,<length>,<type>,<order>)                                             
  SUM    FIELDS=NONE                                                   


the option equals makes sure that the sorted records with the same key are in the original order
( file1 records before file2 records )
Back to top
View user's profile Send private message
krishna_ragav

New User


Joined: 29 Oct 2010
Posts: 10
Location: Chennai

PostPosted: Fri Jan 20, 2012 5:57 pm    Post subject: Reply to: To get first record in case the file has duplicate
Reply with quote

Thank You All,

I have tried with option EQUALS and It worked.
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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