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

Match to get first 50 records


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

New User


Joined: 21 Jun 2007
Posts: 30
Location: Baltimore

PostPosted: Tue Sep 23, 2008 12:54 am
Reply with quote

Hi

FILEA has 500k records and FILEB has 100 records . For each record in FILEB there can a matching record in FILEA .FILEA is sorted as per FILEB records. I want to match FILEA and FILEB and want to extract only the first 50 of each matching into one FILEC from FILEA and all the other records into FILED from FILEA(FILEA – FILEC).

MSTP.
Back to top
View user's profile Send private message
MSTP

New User


Joined: 21 Jun 2007
Posts: 30
Location: Baltimore

PostPosted: Tue Sep 23, 2008 8:08 pm
Reply with quote

Hi

FILEA has 500k records and FILEB has 100 records . For each record in FILEB there can a matching record in FILEA .FILEA is sorted as per FILEB records. I want to match FILEA and FILEB and want to extract only the first 50 of each matching into one FILEC from FILEA and all the other records into FILED from FILEA(FILEA – FILEC).

MSTP
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Sep 23, 2008 9:29 pm
Reply with quote

MSTP,

I have assumed FB files of LRECL=80 and key fields of both the files starting at pos 1-3 and for extracting 2 matching records from file1 instead of 50. You can modify it as per your file attributes.
Code:
//STEP00   EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTJNF1 DD *                     
AAA 123                             
AAA 414                             
AAA 343                             
AAA 233                             
BBB 234                             
BBB 223                             
BBB 355                             
CCC 532                             
CCC 222                             
//SORTJNF2 DD *                     
AAA                                 
BBB                                 
CCC                                 
DDD                                 
//OUT1    DD SYSOUT=*               
//OUT2    DD SYSOUT=*               
//SYSIN   DD *                                         
  JOINKEYS FILE=F1,FIELDS=(1,3,A)                       
  JOINKEYS FILE=F2,FIELDS=(1,3,A)                       
  REFORMAT FIELDS=(F1:1,80)                             
  SORT FIELDS=COPY                                     
  INREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))         
  OUTFIL FNAMES=OUT1,INCLUDE=(81,8,ZD,LE,2),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)                 
//* 

OUT1
Code:
AAA 123
AAA 414
BBB 234
BBB 223
CCC 532
CCC 222

OUT2
Code:
AAA 343
AAA 233
BBB 355

The above SYNCSORT works only if you have Syncsort for z/OS release 1.2 or later. Let me know if you come across any issues.
Back to top
View user's profile Send private message
MSTP

New User


Joined: 21 Jun 2007
Posts: 30
Location: Baltimore

PostPosted: Tue Sep 23, 2008 10:48 pm
Reply with quote

Arun

I tried with the above SORT parameters. It works to some extent but I am losing records from fileA like rcds ABC 111 which don't have a match to fileB records. Please let me know what modification is needed.

thanks
mstp
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: Wed Sep 24, 2008 12:44 am
Reply with quote

There seems to be some confusion about which SORT product you're using. Please run the following job and post the //SYSOUT messages:

Code:

//S1    EXEC  PGM=ICEMAN                                           
//SYSOUT    DD  SYSOUT=*                                           
//SORTIN DD *                                                     
RECORD 1                                                           
//SORTOUT DD SYSOUT=*   
//SYSIN    DD    *                                                 
  OPTION COPY     
/*                                               
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Sep 24, 2008 9:22 am
Reply with quote

Hello ,
Quote:
It works to some extent but I am losing records from fileA like rcds ABC 111 which don't have a match to fileB records.

From the above post, I assume the jcl ran successfully, but dint produce the results as you expected. Can you post the actual file attributes and the key positions on both the files and also some sample input/output records.
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: Wed Sep 24, 2008 9:30 pm
Reply with quote

JOINKEYS implies the OP is using Syncsort, but he told another Moderator in an offline note that he's not using Syncsort. So we need to clear up which product he's using before we go any further with this.
Back to top
View user's profile Send private message
MSTP

New User


Joined: 21 Jun 2007
Posts: 30
Location: Baltimore

PostPosted: Sat Oct 11, 2008 1:01 am
Reply with quote

We are using Syncsort and below is the sort card I used to get the rqd data.Thank for all the help

OPTION EQUALS
JOINKEYS FILE=F1,FIELDS=(65,8,A)
JOINKEYS FILE=F2,FIELDS=(1,8,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,300,F2:1,8)
SORT FIELDS=COPY
INREC OVERLAY=(309:SEQNUM,8,ZD,RESTART=(65,8))
OUTFIL FNAMES=SORTOUT1,INCLUDE=((309,8,ZD,LE,50),
AND,(301,8,CH,NE,C' ')),
BUILD=(1,300)
OUTFIL FNAMES=SORTOUT2,INCLUDE=((309,8,ZD,GT,50),
OR,(301,8,CH,EQ,C' ')),
BUILD=(1,300)
************************** Bottom of Data ********************
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Oct 12, 2008 7:55 am
Reply with quote

MSTP,

You can further simplify this by using the SAVE parameter for SORTOUT2 like this.
Code:
OUTFIL FNAMES=SORTOUT2,SAVE,BUILD=(1,300)
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top