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
 

 

Join fields from 2 files on a key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Join fields from 2 files on a key
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    Post subject: Reply to: Join fields from 2 files on a key
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 23, 2009 9:23 pm    Post subject:
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    Post subject:
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    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 How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 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 Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm


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