MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help on SPLICE

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
hasan
Beginner


Joined: 02 Sep 2004
Posts: 9
Topics: 3

PostPosted: Wed Oct 13, 2004 4:36 pm    Post subject: Help on SPLICE Reply with quote

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.

Can anybody help me.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 13, 2004 4:47 pm    Post subject: Reply with quote

hasan,

A couple of questions.

1. Are there any dupes in any of the input files?
2. what is the lrecl,recfm of the files?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hasan
Beginner


Joined: 02 Sep 2004
Posts: 9
Topics: 3

PostPosted: Wed Oct 13, 2004 4:56 pm    Post subject: Reply with quote

Kolusu,

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.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Oct 13, 2004 6:15 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hasan
Beginner


Joined: 02 Sep 2004
Posts: 9
Topics: 3

PostPosted: Wed Oct 13, 2004 6:39 pm    Post subject: Reply with quote

I have given more information about requirement on other board. We will continue there. If possible please close the topic here.

Thanks & Sorry for confusion.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Oct 14, 2004 9:39 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group