Splicing and keeping duplicates



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Splicing and keeping duplicates

Postby profondo » Fri May 02, 2008 9:30 pm

In the example below, I would like to pick up the 3-byte field from record A and try to apply it to other records with a matching key but I would like to keep the base record A unchanged and keep all the updated records. I thought splice with KEEPBASE would help do the trick but I'm having difficulty applying the update to the duplicate matching records (like the C record and duplicate B records shown in the example below) and keeping those records in the output.

Input:
A KEY1 111
B KEY1 000
C KEY1 000
A KEY2 123
B KEY2 000
B KEY2 000
B KEY2 000
D KEY2 000
D KEY2 000
A KEY3 101
B KEY3 000
C KEY3 000


Output I need:
A KEY1 111
B KEY1 111
C KEY1 111
A KEY2 123
B KEY2 123
B KEY2 123
B KEY2 123
D KEY2 123
D KEY2 123
A KEY3 101
B KEY3 101
C KEY3 101

Can splice help do something like this?
profondo
 
Posts: 6
Joined: Fri May 02, 2008 8:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Splicing and keeping duplicates

Postby Frank Yaeger » Fri May 02, 2008 11:10 pm

You can use a SPLICE operator like this to do what you asked for:

SPLICE FROM(IN) TO(OUT) ON(9,4,CH) KEEPBASE -
  WITHALL WITH(1,1) WITH(9,4)
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Splicing and keeping duplicates

Postby profondo » Mon May 05, 2008 11:29 am

Thanks, Frank - that worked well.

Another problem - say I want to perform the same task but this time I'm dealing with a 100 byte variable length file where, using the same example above, records A, B, C, D are each of different lengths - "A" = 100 bytes, B = 80, C=90, D=40...
I tried it using VLENMAX and noticed what I expected - the resulting spliced records were given the length of the base record because it had the largest length of all records. The data in bytes 80-100 of "A" were carried over to "B"'s record. So I'm thinking SPLICE may not be the way to go here if i'm looking to keep the overlay records their original size, correct?
profondo
 
Posts: 6
Joined: Fri May 02, 2008 8:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Splicing and keeping duplicates

Postby Frank Yaeger » Mon May 05, 2008 8:32 pm

If you want to keep the length of the OVERLAY records, why did you choose VLENMAX rather than VLENOVLY? Doesn't it seem obvious that VLENOVLY would give you the length of the overlay records?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Splicing and keeping duplicates

Postby profondo » Fri May 09, 2008 10:02 pm

Yikes - I must have read through the DFSORT guide a bit too quick. Maybe because each overlaid record is of different length, I didn't think VLENOVLY would maintain the original size of each but I was mistaken.

The key was actually in 2 different places in that variable length file so I added another ON and WITH for that, and along with the WITH for the rest of the record, everything's now looking dandy.

Many thanks!
profondo
 
Posts: 6
Joined: Fri May 02, 2008 8:52 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post