View previous topic :: View next topic
|
Author |
Message |
krishnakanagal
New User
Joined: 27 Feb 2009 Posts: 12 Location: Bangalore
|
|
|
|
Hi,
I have, say 3 variable length recod files of max legth 32756. I want to merge the data in all the 3 files eliminating the dulicates but the latest record should be in output file for e.g the input files are
File1
AA1
BB1
FF1
XX1
File2
CC2
AA2
DD2
FF2
File3
MM3
BB3
AA3
DD3
The output should be
AA3
BB3
CC2
DD3
FF2
MM3
XX1 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What defines "latest"?
What are the positions of the "keys"? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT/ICETOOL job that will do what you asked for. I used the positions shown in your example. Adjust appropriately for other positions, but remember that for a VB file, the RDW is in positions 1-4 so the first data byte starts at position 5.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1 (VB/32756)
// DD DSN=... input file2 (VB/32756)
// DD DSN=... input file3 (VB/32756)
//OUT DD DSN=... output file (VB/32756)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,2,CH) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(5,2,CH,A,7,1,ZD,D)
/*
|
|
|
Back to top |
|
|
krishnakanagal
New User
Joined: 27 Feb 2009 Posts: 12 Location: Bangalore
|
|
|
|
I am sorry the Key Fields are first two bytes i have added the Suffix to identify from which file the record is coming. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
From your example, I assumed that the "latest record" was indicated by the highest number in the suffix and that's what I gave you the job for. If that's not what you're trying to do, then please show a better example of input and expected output and explain the "rules" for getting from input to output (e.g. how do you determine the "latest record"). |
|
Back to top |
|
|
krishnakanagal
New User
Joined: 27 Feb 2009 Posts: 12 Location: Bangalore
|
|
|
|
In the Example, File3 is having the latest records and file1 is having oldest. There is some data after the first two bytes. that data being different for a given key. So the in put files are
File1
AAxxxxxxxxxxxxx
BBhhhhhhhhhhhhh
FFnnnnnnnnnnnnnn
XXkkkkkkkkkkkkk
File2
CCrrrrrrrrrrrrrrrrr
AAcccccccccccccc
DDsssssssssssss
FFiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
File3
MMqqqqqqqqqqqqq
BBaaaaaaaaaaaaaaaaa
AAzzzzzzzzzzzzzzzzz
DDwww
The 3rd file is latest file.
The output file should be
AAzzzzzzzzzzzzzzzzz
BBaaaaaaaaaaaaaaaaa
CCrrrrrrrrrrrrrrrrr
DDwww
FFiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
MMqqqqqqqqqqqqq
XXkkkkkkkkkkkkk |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Oh, that's even easier. Just concatenate the files in reverse order - file3, file2, file1 and use this DFSORT/ICETOOL job:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file3 (VB/32756)
// DD DSN=... input file2 (VB/32756)
// DD DSN=... input file1 (VB/32756)
//OUT DD DSN=... output file (VB/32756)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,2,CH) FIRST
/*
|
|
|
Back to top |
|
|
krishnakanagal
New User
Joined: 27 Feb 2009 Posts: 12 Location: Bangalore
|
|
|
|
Frank,
Any idea Wat will happen if i do a normal sort
Code: |
//ABCDEFGH EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FILE3
// DD DSN=FILE2
// DD DSN=FILE1
//SORTOUT DD DSN=FILE4
//SYSIN DD *
SORT FIELDS=COPY
SUM FIELDS=NONE
/*
|
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
SORT FIELDS=COPY would do a copy, not a sort and you'd get all of the records since SUM is ignored for COPY.
You can do it with DFSORT instead of ICETOOL like this:
Code: |
//ABCDEFGH EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FILE3
// DD DSN=FILE2
// DD DSN=FILE1
//SORTOUT DD DSN=FILE4
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(5,2,CH,A)
SUM FIELDS=NONE
/*
|
|
|
Back to top |
|
|
|