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

Is SPLICE supposed to work this way?


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

New User


Joined: 11 Sep 2006
Posts: 23

PostPosted: Fri Jul 27, 2007 1:53 am
Reply with quote

I ran a SPLICE in ICETOOL:

Code:
SPLICE FROM(IN1) TO(OUT1) ON(001,005,CH) KEEPNODUPS -
  WITHEACH WITH(013,005) WITH(019,005) USING(CTL1)


Where the input was:

Code:
ITEM1 XXXXX
ITEM4 XXXXX
ITEM5 XXXXX
ITEM7 XXXXX
ITEM2       XXXXX
ITEM4       XXXXX
ITEM6       XXXXX
ITEM7       XXXXX
ITEM3             XXXXX
ITEM5             XXXXX
ITEM6             XXXXX
ITEM7             XXXXX





I expected the results to be:

Code:
ITEM1 XXXXX
ITEM2       XXXXX
ITEM3             XXXXX
ITEM4 XXXXX XXXXX
ITEM5 XXXXX       XXXXX
ITEM6       XXXXX XXXXX
ITEM7 XXXXX XXXXX XXXXX



But instead I got:

Code:
ITEM1 XXXXX
ITEM2       XXXXX
ITEM3             XXXXX
ITEM4 XXXXX XXXXX
ITEM5 XXXXX
ITEM6
ITEM7 XXXXX XXXXX XXXXX



ie the WITHEACHing stopped as soon as it found a record with spaces in one of the WITH fields (look at ITEM5 and ITEM6).

Is that how it's supposed to 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 Jul 27, 2007 2:41 am
Reply with quote

SPLICE is working as expected:

WITHEACH WITH(013,005) WITH(019,005)

tells DFSORT to overlay 13,5 from the second record with the same key onto the base record, and to overlay 19,5 from the third record with the same key onto the base record.

So when you have:

Code:

ITEM5 XXXXX                 <--- base
ITEM5             11111     <--- second record


you get

Code:

ITEM5 XXXXX   


ITEM5 XXXXX comes from the base record. Blanks come from 13,5 of the second record overlay the blanks in 13,5 of the base record. Since there's no third record, you don't get 19,5 from anywhere.

When you have:

Code:

ITEM6       XXXXX           <--- base
ITEM6             22222      <--- second record


you get:

Code:

ITEM6


ITEM6blanksXXXXX comes from the base record. Blanks from 13,5 of the second record overlay the XXXXX in the base record. Since there's no third record, you don't get 19,5 from anywhere.

Now is your next question, how can I get what I want?
Back to top
View user's profile Send private message
helga

New User


Joined: 11 Sep 2006
Posts: 23

PostPosted: Fri Jul 27, 2007 3:04 am
Reply with quote

Yes icon_razz.gif


Thanks Frank, that makes perfect sense when you explain it that way and also makes me realise why the examples in the book are the way they are.

So SPLICE works very well with "reliable" data, ie a list of state codes and then an invoice total by states for whatever states you sold in, or in this case a specific number of records for each state activity, say gross sales and taxes paid.

It's a little bit trickier if you're merging two files with some state codes on one file and some state codes on another and either might or might not have repeated records. Though I have managed somethign along those lines. How come I always seem to be pushing the envelope? icon_surprised.gif

To make the above example work, all I have to do is insert records for the "blank" fields before I get to the SPLICE
Back to top
View user's profile Send private message
helga

New User


Joined: 11 Sep 2006
Posts: 23

PostPosted: Fri Jul 27, 2007 3:24 am
Reply with quote

...what I hadn't realised was that with WITHEACH each WITH applies to an individual duplicate record. I was looking at it like OCCURS and using the WITHs to select fields from all the duplicate records. This wouldn't work anyway as if every WITH applied to every duplicate record, they'd overwrite the WITHs from the previous duplicate record.


...erm I think icon_lol.gif



Good stuff, but like I said, suited mostly to dependalbe file configurations.
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 isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts Negative value - packed field - Natur... Java & MQSeries 0
This topic is locked: you cannot edit posts or make replies. Splice JCL into one record for DD sta... SYNCSORT 2
No new posts TWS - ETT File triggering does not wo... IBM Tools 4
Search our Forums:

Back to Top