MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort to retrieve certain records - DFOSRT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Mar 15, 2004 8:54 am    Post subject: Sort to retrieve certain records - DFOSRT Reply with quote

Hello Gurus

Another slightly different requirement for DFSORT:

1. File A. Sort column (also the key) starts in position 11. Length 11. File length 477.
2. File B. Sort column (also the key) starts in position 1. Length 11. File length 11.

Requirement:

Output file should contain record from FileA for those keys present in both input files.

Note: I have seen Kolusu/Frank's sort that creates 3 files (1. Records unique to file A 2. Records unique to file B 3. Intersection of fileA and FileB). Here the requirements are different:

1. Sort columns are not same
2. File lengths are not same.

Could you please guide me.

Regards
Relaxing
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12383
Topics: 75
Location: San Jose

PostPosted: Mon Mar 15, 2004 9:13 am    Post subject: Reply with quote

Relaxing,

couple of questions before providing the solution.

1. Can file A have duplicates ?
2. What is the max no: records in file B?
3. What is the RECFM of both the files?
4. Is easytrieve an option?

Thanks

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Mar 15, 2004 9:20 am    Post subject: Reply with quote

Hi Kolusu

1. No duplicates in either files.
2. File A - 22,000 records. File B - 6000 records (around)
3. RECFM is fixed block.
4. I have already written a PL1 for this (sorted file logic). So Eazytieve is not necessary. Thanks anyway. I was curious how we go about this with DFSORT.

Regards,
Relaxing.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12383
Topics: 75
Location: San Jose

PostPosted: Mon Mar 15, 2004 9:55 am    Post subject: Reply with quote

Relaxing,

The following DFSORT/ICETOOL job will give you desired results. If you have syncsort, change the pgm name to synctool.

A brief explanation of the Job. We first take file B and pad it with spaces to length of file a and also move the key from pos1 to pos 11. By doing so we can concatenate the 2 files and extract the keys we need. when we concatenate the files after reformating any key present file B will be a duplicate in the concatenated file. so using select operator we select the first dup which is what you want.Make sure to have file A as the first file in the concatenation. Select operator has EQUALS as default , so you will get the first duplicate record which is from from file A

Code:

//STEP0100 EXEC PGM=ICETOOL                                   
//TOOLMSG   DD SYSOUT=*                                       
//DFSMSG    DD SYSOUT=*                                       
//IN1       DD DSN=YOUR FILE B,
//             DISP=SHR                                               
//CON       DD DSN=YOUR FILE A
//             DISP=SHR
//          DD DSN=*.T1,DISP=(OLD,PASS),VOL=REF=*.T1           
//T1        DD DSN=&T1,SPACE=(CYL,(X,Y),RLSE),DISP=(,PASS)     
//OUT       DD DSN=YOUR OUTPUT FILE,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=PROD,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD   *                                             
  COPY FROM(IN1) USING(CTL1)                                   
  SELECT FROM FROM(CON) TO(OUT) ON(11,11,CH) FIRSTDUP
//CTL1CNTL  DD *                                               
  OUTFIL FNAMES=T1,OUTREC=(10X,       $ PAD 10 SPACES
                           1,11,      $ FILE B KEY IN POS11
                           477:X)     $ PAD SPACES TO LENGTH OF FILE A
/*


Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
relaxing
Beginner


Joined: 25 Aug 2003
Posts: 73
Topics: 29

PostPosted: Mon Mar 15, 2004 10:11 am    Post subject: Reply with quote

Really cool solution..I did not know we could play with DFSORT so well..I have made some cosmetic changes to the code below. Thanks a ton Kolusu.

Code:
//STEP0100 EXEC PGM=ICETOOL                                   
//TOOLMSG   DD SYSOUT=*                                       
//DFSMSG    DD SYSOUT=*                                       
//IN1       DD DSN=YOUR FILE B,                               
//             DISP=SHR                                       
//T1        DD DSN=&T1,SPACE=(CYL,(1,1),RLSE),DISP=(,PASS)     
//CON       DD DSN=YOUR FILE A,                               
//             DISP=SHR                                       
//          DD DSN=*.T1,DISP=(OLD,PASS),VOL=REF=*.T1           
//OUT       DD DSN=YOUR OUTPUT FILE,                           
//             DISP=SHR                                       
//TOOLIN    DD   *                                             
  COPY FROM(IN1) USING(CTL1)                                   
  SELECT FROM(CON) TO(OUT) ON(11,11,CH) FIRSTDUP               
//CTL1CNTL  DD *                                               
  OUTFIL FNAMES=T1,OUTREC=(10X,                               
                           1,11,                               
                           477:X)                             
/*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12383
Topics: 75
Location: San Jose

PostPosted: Tue Mar 16, 2004 3:50 am    Post subject: Reply with quote

Ravi,

Quote:

Now I got the above solution. Assume that If file A have duplicates ! and file B is just unique records.. then how will be the approach? Is it same or will it be different.


well if you have duplicates the above solution is not going to work. You will probably need SPLICE operator to get the desired results.Frank has provided a solution using SPLICE operator. My shop has syncsort and it does not support SPLICE.

http://www.mvsforums.com/helpboards/viewtopic.php?t=1572&highlight=splice

Quote:

for you 2nd question .. is there any problem if max no: records in file B is large? And if yes what could be the limit?


It does not matter how big the second file is. If the no: of records are less then , I thought of an alternate solution. let us assume that you have few records (say <500) then we can generate INCLUDE statements for these records dynamically and extract records from the file A. In the above link take a look at the solution provided by me by generating dynamic control cards.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group