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
 

 

Validate keys in a data file against a master key file?

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

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Thu Sep 07, 2006 1:09 am    Post subject: Validate keys in a data file against a master key file?
Reply with quote

Here's my task:

- I have a master file of all valid keys allowed on a data file
- I need to compare the data file against the master file and only retain records that have a matching key on the master file

Other criteria/issues:
- the data file may have zero, one, or many records for each key on the master file

Assume the key to be the one byte in column 1. Here's a data file:

A1
A2
A3
B1
B2
C1
D1
D2
E1

Here's the master file:

A
D
E

I want to end up with:


A1
A2
A3
D1
D2
E1

Can this be done in one pass with DFSORT or ICETOOL? Apologies if this has already been answered elsewhere, I did search for a bit but didn't come up with anything.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 07, 2006 1:33 am    Post subject:
Reply with quote

Quote:
Can this be done in one pass with DFSORT or ICETOOL?


Yes, assuming that

1) There's some way to distinguish the records in the Master File from the records in the Data File. For your example, the records in the Master file have a blank in position 2 whereas the records in the Data file have a non-blank in position 2, so we can use that to distinguish them.
2) You have z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) installed so you can use INREC with SPLICE. If you see 'ICE201I E' in //DFSMSG, you have that PTF. If you see 'ICE201I 0' in //DFSMSG, you do not have that PTF. Without that PTF, the one pass solution won't work, but you could do it in multiple passes.

I also assumed that your input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Here's the DFSORT/ICETOOL job:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=...  Master file (FB/80)
//    DD DSN=...  Data file (FB/80)
//OUT DD DSN=...  Output file (FB/80)
//TOOLIN DD *
SPLICE FROM(CON) TO(OUT) ON(1,1,CH) -
  WITHALL WITH(1,2) WITH(81,1) USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(2,1,CH,EQ,C' '),OVERLAY=(81:C'BB')),
        IFTHEN=(WHEN=NONE,OVERLAY=(81:C'VV'))
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'VB'),
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Thu Sep 07, 2006 1:39 am    Post subject:
Reply with quote

Frank - I thought I'd given you all the info you needed, you're right, I didn't specify that you can distinguish between the files and it is true that you can.

Thanks once again for the impossibly quick and concise reply.
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Thu Sep 07, 2006 2:17 am    Post subject:
Reply with quote

Hmm, maybe I spoke too fast, I can't get this example to work.

Here's my datafile:

Code:
A1     
A2     
A3     
B1     
B2     
B3     
C1     
C2     
C3     
X1     
Y1     


Here's my key file:

Code:
B   
Q   


and here's the result I got:

Code:
A2         
A3         
B1         
B2         
B3         
C2         
C3         



I wanted to get:

Code:
B1     
B2     
B3 


I ran this query:

Code:
//S1 EXEC PGM=ICETOOL                                           
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG DD SYSOUT=*                                           
//CON DD DSN=RMOULTO.SORTTEST.IN2,DISP=OLD                     
//    DD DSN=RMOULTO.SORTTEST.IN1,DISP=OLD                     
//OUT DD DSN=RMOULTO.SORTTEST.OUT,                             
//      DISP=(,CATLG,DELETE),                                   
//      SPACE=(CYL,(1,1),RLSE),                                 
//      UNIT=PROD,                                             
//      DCB=(DSORG=PS,LRECL=82,RECFM=FB)                       
//TOOLIN DD *                                                   
SPLICE FROM(CON) TO(OUT) ON(1,1,CH) -                           
  WITHALL WITH(1,2) WITH(81,1) USING(CTL1)                     
/*                                                             
//CTL1CNTL DD *                                                 
  INREC IFTHEN=(WHEN=(2,1,CH,EQ,C' '),OVERLAY=(81:C'BB')), ),   
        IFTHEN=(WHEN=NONE,OVERLAY=(81:C'VV'))                   
  OUTFIL FNAMES=OUT,                                           
    BUILD=(1,82)                                               
/*                                                             
//                                                             


The only change I made to the code was to exclude the inclusion criteria on the output file (I would fix that later once I got the data coming out as I wanted). Did I mess something up? Another factor to consider is that a key in the key file does not have to appear in the data file.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 07, 2006 3:25 am    Post subject:
Reply with quote

Quote:
The only change I made to the code was to exclude the inclusion criteria on the output file


That's like saying "the only thing I did was to remove the key from the ignition and now the car won't start". icon_lol.gif

When I run your new data with my original job, I get the output you want.

Without the INCLUDE condition, you'll get

Code:

A2             VV
A3             VV
B1             VB
B2             VB
B3             VB
C2             VV
C3             VV


You need the INCLUDE condition to only get the VB records which are the ones you want.
Back to top
View user's profile Send private message
Div Grad

New User


Joined: 08 Apr 2005
Posts: 43

PostPosted: Thu Sep 07, 2006 6:40 pm    Post subject:
Reply with quote

Frank - I had taken out the include statement and wrote out the full 82 bytes to see what was going into in columns 81 and 82. I was getting low values, not 'VB' or 'VV'.

Now reading your original note closer I see my real problem: My site doesn't have the latest PTF installed so I need to use the mutliple pass method. I went this route and everything is ok now.

Thanks again for your help and I apologize for not reading your original note more closely.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 07, 2006 9:51 pm    Post subject:
Reply with quote

Oh, ok. Glad I could help.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


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