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

SPLICE problem when trying to join 2 files


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

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Wed Oct 10, 2007 8:28 pm
Reply with quote

Hi all,

I'm trying to join 2 files, but I cannot manage to have the desired result.
Here is what I try to do:

----key----
IN1:

AAAA 4444
BBBB 2222
BBBB 1111
KKKK 3333
AAAA 7777
HHHH 7777
HHHH 1111
EEEE 1111

-key-
IN2:

AAAA DATA1
EEEE DATA2
HHHH DATA3
YYYY DATA4

OUTPUT:

AAAA 4444 DATA1
BBBB 2222
BBBB 1111
KKKK 3333
AAAA 7777 DATA1
HHHH 7777 DATA3
HHHH 1111 DATA3
EEEE 1111 DATA2

In IN1, each record is unique (the whole record is unique key).
In IN2, we have as key a subkey of IN1 key format (4 first chars)

Requirement:
OUTPUT contains all IN1 records, but if an IN1 record has its subkey match the key of IN2, then the DATA field of the matching IN2 record has to be appended to the IN1 OUTPUT record.

I've tried with SPLICE, but it seems no option is adequate (WITHALL, KEEPNODUPS, KEEPBASE) nor copying the files to the temp file in one order or another.
The problem is that key2 is a subkey of key1. If key1 and key2 where the same, then I could do:
1) append IN2 to IN1. SPLICE on key WITHALL.

If I do this with our input files and SPLICING on key2, then records would be lost (aggregation of same subkey in IN1)

Any idea?

Thanks.

Julien
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 Oct 10, 2007 10:23 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
AAAA 4444
BBBB 2222
BBBB 1111
KKKK 3333
AAAA 7777
HHHH 7777
HHHH 1111
EEEE 1111
/*
//IN2 DD *
AAAA DATA1
EEEE DATA2
HHHH DATA3
YYYY DATA4
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN   DD    *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(T2) ON(1,4,CH) KEEPNODUPS KEEPBASE -
  WITHALL WITH(6,4) WITH(82,9)
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,4,11:6,5,81:C'BB',83:8X)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV',83:SEQNUM,8,ZD)
/*
//CTL3CNTL DD *
  OMIT COND=(81,2,CH,EQ,C'BB')
  SORT FIELDS=(83,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Thu Oct 11, 2007 3:24 pm
Reply with quote

This works! This was kind of tricky with the 'BB' 'VV'.
I'm impressed with DFSORT again.
Thank you Frank.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top