View previous topic :: View next topic
|
Author |
Message |
harry
New User
Joined: 27 Mar 2006 Posts: 31
|
|
|
|
There were two files they have been merged together & my input looks something like below. The value of _ and # at column 27 is an indicator that these records are from two different files, _ from file1 & # from file2 but the records & been merged & sorted in a single file
My requirement for output is, if we have a record(s) with matching key( column 18 till 24 )from file1 then I do not want record(s) of the file2 for the same key to be present in the outfile
INPUT FILE
cols
12345678901234567890123456789
xxxxxxxxxxxxxxxxx ABCDE _
xxxxxxxxxxxxxxxxx ABCDE #
xxxxxxxxxxxxxxxxx DEFGH _
xxxxxxxxxxxxxxxxx DEFGH _
xxxxxxxxxxxxxxxxx DEFFG #
xxxxxxxxxxxxxxxxx HRADD _
xxxxxxxxxxxxxxxxx HRADD #
xxxxxxxxxxxxxxxxx HRADD #
xxxxxxxxxxxxxxxxx KLMNO _
xxxxxxxxxxxxxxxxx KLMNO _
xxxxxxxxxxxxxxxxx GABCD #
xxxxxxxxxxxxxxxxx GABCD #
xxxxxxxxxxxxxxxxx UAVDE _
xxxxxxxxxxxxxxxxx SACAC #
I want my output as
OUTPUT FILE
cols
12345678901234567890123456789
xxxxxxxxxxxxxxxxx ABCDE _
xxxxxxxxxxxxxxxxx DEFGH _
xxxxxxxxxxxxxxxxx DEFGH _
xxxxxxxxxxxxxxxxx HRADD _
xxxxxxxxxxxxxxxxx KLMNO _
xxxxxxxxxxxxxxxxx KLMNO _
xxxxxxxxxxxxxxxxx GABCD # { this & below record should be present as we do not have the match for it in file1)
xxxxxxxxxxxxxxxxx GABCD #
xxxxxxxxxxxxxxxxx UAVDE _
xxxxxxxxxxxxxxxxx SACAC # { this record should be present as we do not have the match for it in file1)
The INPUT & OUTPUT file are both FB 80
Thanks and Regards
Uncle |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
shouldn't this record also be in the output file ?
Code: |
xxxxxxxxxxxxxxxxx DEFFG #
|
Gerry |
|
Back to top |
|
|
harry
New User
Joined: 27 Mar 2006 Posts: 31
|
|
|
|
No, that record should not be present in the outfile, as we have the record(s) with the matching key comming from the file1 (xxxxxxxxxxxxxxxxx DEFGH _ )
Thanks |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
DEFGH does not match DEFFG
Gerry |
|
Back to top |
|
|
harry
New User
Joined: 27 Mar 2006 Posts: 31
|
|
|
|
sorry,yes that is a typo error............ |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
harry
Your rules are not consistent. for ex: how did you end up picking HRADD _ for this input?
Quote: |
xxxxxxxxxxxxxxxxx HRADD _
xxxxxxxxxxxxxxxxx HRADD #
xxxxxxxxxxxxxxxxx HRADD #
|
The first 2 match so it is considered as a pair so you are left with HRADD # but in your output you show the reverse. Please define the rules correctly |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Kolusu,
this is how I understood the request, all records from file 1 will always be written out, records from file 2 will only be written out if that record does not exist in file 1.
Gerry |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
gcicchet,
If that is indeed the requirement then the following JCL will give him the desired results. However the output will be sorted on the key (18,7)
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXXXXXXXXXXXXXXXABCDE _
XXXXXXXXXXXXXXXXXABCDE #
XXXXXXXXXXXXXXXXXDEFGH _
XXXXXXXXXXXXXXXXXDEFGH _
XXXXXXXXXXXXXXXXXDEFGH #
XXXXXXXXXXXXXXXXXHRADD _
XXXXXXXXXXXXXXXXXHRADD #
XXXXXXXXXXXXXXXXXHRADD #
XXXXXXXXXXXXXXXXXKLMNO _
XXXXXXXXXXXXXXXXXKLMNO _
XXXXXXXXXXXXXXXXXGABCD #
XXXXXXXXXXXXXXXXXGABCD #
XXXXXXXXXXXXXXXXXUAVDE _
XXXXXXXXXXXXXXXXXSACAC #
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(18,7,CH,A,27,1,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD,RESTART=(18,7),27,1)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(90:89,1))
OUTFIL BUILD=(1,80),OMIT=(89,2,CH,EQ,C'#_')
//* |
The output from this job is
Code: |
XXXXXXXXXXXXXXXXXABCDE _
XXXXXXXXXXXXXXXXXDEFGH _
XXXXXXXXXXXXXXXXXDEFGH _
XXXXXXXXXXXXXXXXXGABCD #
XXXXXXXXXXXXXXXXXGABCD #
XXXXXXXXXXXXXXXXXHRADD _
XXXXXXXXXXXXXXXXXKLMNO _
XXXXXXXXXXXXXXXXXKLMNO _
XXXXXXXXXXXXXXXXXSACAC #
XXXXXXXXXXXXXXXXXUAVDE _
|
|
|
Back to top |
|
|
|