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

Join fields from 2 files on a key


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Thu Oct 22, 2009 6:37 pm
Reply with quote

Hello,
I want to join fields from two files on a key.

My master file is like that;
AAAA FIELD1 FIELD2
BBBB FIELD1 FIELD2
CCCC FIELD1 FIELD2
CCCC FIELD1 FIELD2
DDDD FIELD1 FIELD2
DDDD FIELD1 FIELD2

My control file is like that;
AAAA FIELD3
BBBB FILED3
CCCC FILED3

Desired output is like that;
AAAA FIELD1 FIELD2 FIELD3
BBBB FIELD1 FIELD2 FIELD3
CCCC FIELD1 FIELD2 FIELD3
CCCC FIELD1 FIELD2 FIELD3

I am trying something with SPLICE command but if there was 2 or more record in master file which have same key field. Only first one is listing out.
I want to list out for every occurance of record in master file. and another issue is;
if there are two record that have same key area and there aren't any record in control file for that two record, that records musn't listing out.

(The data is unique on key field in control file)

Is it possbile?
Thanks you very much?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Oct 22, 2009 9:18 pm
Reply with quote

ozgurseyrek,

Assuming your master and control file are of the same lrecl and RECFM , here is a DFSORT JCL which will give you the desired results in 1 pass

I assumed that both your input files are FB and recfm of 80.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTIN   DD *                                                         
HDR                                                                     
//         DD *                                                         
AAAA VALUEA                                                             
BBBB VALUEB                                                             
CCCC VALUEC                                                             
//         DD *                                                         
HDR                                                                     
//         DD *                                                         
AAAA FIELD1 FIELD2                                                     
BBBB FIELD1 FIELD2                                                     
CCCC FIELD1 FIELD2                                                     
CCCC FIELD1 FIELD2                                                     
DDDD FIELD1 FIELD2                                                     
DDDD FIELD1 FIELD2                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:ID=1))     
  SORT FIELDS=(1,4,CH,A),EQUALS                                         
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,4))),     
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(82:81,1,20:6,6))       
  OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'HDR'),BUILD=(1,80)     
/*



The output from this job is

Code:

AAAA FIELD1 FIELD2 VALUEA 
BBBB FIELD1 FIELD2 VALUEB 
CCCC FIELD1 FIELD2 VALUEC 
CCCC FIELD1 FIELD2 VALUEC 
Back to top
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Fri Oct 23, 2009 11:02 am
Reply with quote

Thaks you Skolosu,
but we have "Z/OS DFSORT V1R5", "WHEN=GROUP" coding didn't work...
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: Fri Oct 23, 2009 9:23 pm
Reply with quote

WHEN=GROUP is supported with z/OS DFSORT V1R5 PTF UK90013 (July, 2009). Ask your System Programmer to install that PTF (it's free).

Alternatively, you can use a DFSORT/ICETOOL job like the following:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD *
AAAA FIELD1 FIELD2
BBBB FIELD1 FIELD2
CCCC FIELD1 FIELD2
CCCC FIELD1 FIELD2
DDDD FIELD1 FIELD2
DDDD FIELD1 FIELD2
//IN2 DD *
AAAA FIELD3
BBBB FILED3
CCCC FILED3
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) WITHALL -
  WITH(6,6) WITH(13,6) WITH(81,1) USING(CTL3)
//CTL1CNTL DD *
  INREC BUILD=(1,4,20:6,6,81:C'BB')
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV')
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'VB'),
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Fri Oct 23, 2009 10:01 pm
Reply with quote

Thank you very much Frank Yaeger...
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top