Posted: Wed Oct 13, 2004 4:36 pm Post subject: Help on SPLICE
I have a requirement which goes as follows.
My first input file looks like this.
Code:
Appointment First-Appointment Status
100 100 N
200 100 N
300 100 N
400 400 N
500 500 N
600 500 N
700 500 N
800 800 N
900 800 N
1000 1000 N
My second input file looks like this.
Code:
Appointment First-Appointment Status
1100 100 Y
1200 500 Y
1300 1300 Y
1400 800 Y
My output file should look like
Code:
Appointment First-Appointment Status
100 100 Y
200 100 Y
300 100 Y
1100 100 Y
400 400 N
500 500 Y
600 500 Y
700 500 Y
1200 500 Y
800 800 Y
900 800 Y
1400 800 Y
1000 1000 N
In short if the First-Appointment field of second input file is present in First-Appointment field of first input file,
then I want the Status field of first input file to be updated to 'Y'(that of second input file which will always be 'Y').
After that both files need to be merged.
Is there any way we can do it through SPLICE or other opeartor. Or program is the only way.
I tried doing it, but realized that SPLICE will overlay the records thus changing the fields of first input file. I want to
retain all records as it is except Status field changed to 'Y' for those cases which are present in first input file.
Thanks for reply.
Yes both files may have duplicates. Appointment field is the key field which would always be unique in both files and First-Appointment can have duplicates in both files.
Both files are 80 bytes in length with RECFM as FB.
I think I almost have done it, having some small problems. But I would be happy if you or Frank can give solution to this.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Oct 13, 2004 6:15 pm Post subject:
Quote:
Appointment field is the key field
Isn't First-Appointment the key field? The Appointment field in file1 doesn't have any matching Appointment fields in file2, whereas the First-Appointment field in file1 has matching First-Appointment fields in file2.
Please clarify which field you're matching on and whether that field can have dups in file1 and/or in file2. Show a more complete example (with dups) of input and output if appropriate.
On the other board, I gave you a solution that matches the input data you showed assuming that First-Appointment is the key and that file2 does not have any duplicate First-Appointment values. We need to clear up the assumptions either over here or over there. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Oct 14, 2004 9:39 am Post subject:
For closure, here's the DFSORT/ICETOOL job that does what Hasan needed, including handling dups in file2:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1
//IN2 DD DSN=... input file2
//TX DD DSN=&&TX,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON1 DD DSN=*.TX,VOL=REF=*.TX,DISP=(OLD,PASS)
// DD DSN=*.IN1,VOL=REF=*.IN1,DISP=(OLD,PASS)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON2 DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=*.IN1,VOL=REF=*.IN1,DISP=(OLD,PASS)
// DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
* IN2->TX: Eliminate dups from IN2
SELECT FROM(IN2) TO(TX) ON(13,4,CH) FIRST
* TX/IN1->T1: Get first record for each set of dups in T1.
* We need this to "protect" the records in IN2 since
* they are to be kept along with the records from IN1.
SELECT FROM(CON1) TO(T1) ON(13,4,CH) FIRSTDUP
* T1/IN1/T1: SPLICE records on key. Keep nodups.
* Keep the flag field (Y or N) from the base record
* (first T1) and overlay all the other fields from
* the overlay records (IN1 and second T1).
SPLICE FROM(CON2) TO(OUT) ON(13,4,CH) KEEPNODUPS -
WITHALL WITH(1,30)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum