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

How to find the dup and non-dup in a PS file


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

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Tue Oct 13, 2009 7:09 pm
Reply with quote

Hi,

I have two files. I have to compare these two files and I have to seperate the duplicates and NON-dupes using JCL.

My shop uses DFSORT. Could anybody give me a jcl on how i can perform it.
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 Oct 13, 2009 9:26 pm
Reply with quote

Quote:
I have to compare these two files and I have to seperate the duplicates and NON-dupes using JCL.


This is a rather ambiguous statement. It's not clear exactly what you want to do.

Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Oct 19, 2009 4:08 pm
Reply with quote

Input1:
Abdul
Prashant
Ram
Sam
Arun

Input2:
Abdul
Prashant
Ram

After comparison the output should like the one given below:

Output1:
Abdul
Prashant
Ram

Output2:
Sam
Arun
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Oct 19, 2009 9:03 pm
Reply with quote

abdulrafi,

The following DFSORT/ICETOOL JCL will give you the desired results


Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD *                                                       
ABDUL                                                                 
PRASHANT                                                             
RAM                                                                   
SAM                                                                   
ARUN                                                                 
//         DD *                                                       
ABDUL                                                                 
PRASHANT                                                             
RAM                                                                   
//OUT1     DD SYSOUT=*                                               
//OUT2     DD SYSOUT=*                                               
//TOOLIN   DD *                                                       
SELECT FROM(IN) TO(OUT1) ON(1,10,CH) ALLDUPS DISCARD(OUT2) USING(CTL1)
//CTL1CNTL DD *                                                       
  OUTFIL FNAMES=OUT1,REMOVECC,NODETAIL,                               
  SECTIONS=(1,10,HEADER3=(1,80))                                     
  OUTFIL FNAMES=OUT2                                                 
//*
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Oct 19, 2009 10:22 pm
Reply with quote

Thanks a lot for your help. The code is working.

But I have a doubt. Could you tell me what for,
SECTIONS=(1,10,HEADER3=(1,80)) this statement has been given for the file OUT1 and not for OUT2
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Oct 19, 2009 10:27 pm
Reply with quote

abdulrafi,

All the matching rows will be duplicates. Since you only wanted 1 record per duplicate , we use sections to eliminate the duplicates and only write the first dup.

Non matching keys are unique and you don't need to eliminate any records and hence we don't use sections

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
arindambanerjee

New User


Joined: 30 Jun 2007
Posts: 39
Location: India

PostPosted: Tue Oct 20, 2009 7:48 pm
Reply with quote

Hi Kolusu,

Thanks a lot for bringing such an wonderful utility into light.I was not aware of this. Earlier I used to code Cobol pgm to find duplicate and non duplicate records.
But I have some doubts with the CTL card. can you please help me in explaining that. Iwent through the link as mentioned by you but still have some doubts. My understanding is given below:

OUTFIL FNAMES=OUT1,REMOVECC,NODETAIL,
SECTIONS=(1,10,HEADER3=(1,80))
OUTFIL FNAMES=OUT2

1. I think REMOVECC removes duplicate.
2. NODETAIL is just to extract records in position 1-10 as given in the SECTIONS.
3.Sections is used to declare the layout of the output or sysout, of 80 bytes and 1-10 position will have the key on which it is compared.

Please correct me if my understandings are wrong.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Oct 20, 2009 10:26 pm
Reply with quote

arindambanerjee,

You understanding of the keywords is completely wrong. I suggest you read this "DFSORT: Getting Started"

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG40/CCONTENTS


NODETAIL/REMOVECC is explained here

SECTIONS is explained here

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG40/2.6.8.6?
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 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
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top