I have requirement where I have compare TWO files with first file of length 5551 and second of 9(which will have only the key record which will be compared with first file) .Then compare the key(of length 9) in first file in the position 422 and second file in position 1.
If key record matches in both files then include a comment 'Amendment' and if its a new record and doesn't match the key record then include a comment 'New' - This will be written to third file which will of length 5560 (Where last 9 places will be the 2 comments which I have mentioned in quotes above).
P.S : The third file contents is always a copy of FIRST file + comments in the last 9 position.
FILE 1:
This I tried to do using COBOL program using SEARCH and two READ statements. Somehow all the time I am ending up in getting only NEW as comment in the output irrespective of the key match and un-match.
So started testing using ICETOOL and the used below common JCL, which is roaming around in forum for quite a long.But somehow it's becoming little hard to fit into my requirement.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input File1
//IN2 DD DSN=... input File2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5))
//* USE MOD FOR T1
// DISP=(MOD,PASS)
//OUT13 DD SYSOUT=* records in File1 and File2
//OUT1 DD SYSOUT=* records in File1 only
//OUT3 DD SYSOUT=* records in File2 only
//TOOLIN DD *
* Add '11' identifier for FILE1 records.
COPY FROM(IN1) TO(T1) USING(CTL1)
*Add '22' identifier for FILE2 records.
COPY FROM(IN2) TO(T1) USING(CTL2)
* SPLICE to match up records and write them to their appropriate output files.
SPLICE FROM(T1) TO(OUT12) ON(422,9,CH) WITH(1,9) -
USING(CTL3) KEEPNODUPS
/*
//CTL1CNTL DD *
* Mark FILE1 records with '11'
INREC OVERLAY=(12:C'11')
/*
//CTL2CNTL DD *
* Mark FILE2 records with '33'
INREC OVERLAY=(12:C'33')
/*
//CTL3CNTL DD *
**** Write matching records to OUT13 file and removes id.
OUTFIL FNAMES=OUT13,INCLUDE=(12,2,CH,EQ,C'13'),BUILD=(1,1*)
**** Write FILE1 only records to OUT1 file and removes id.
OUTFIL FNAMES=OUT1,INCLUDE=(12,2,CH,EQ,C'11'),BUILD=(1,1*)
**** Write FILE2 only records to OUT3 file and removes id.
OUTFIL FNAMES=OUT3,INCLUDE=(12,2,CH,EQ,C'33'),BUILD=(1,1*)
/*
Could you please guide with the right JCL or valuable comments ??
I'm getting below error in sysout though the length of the file I've mentioned is right.Also,want to know if the above JCL is right for the requirement I've mentioned in my first post.
Code:
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 09:40 ON SUN FE
JOINKEYS FILE=F1,FIELDS=(1,5551,A)
JOINKEYS FILE=F2,FIELDS=(1,9,A)
JOIN UNPAIRED,F1,F2
OPTION COPY
REFORMAT FIELDS=(F1:1,5551,F2:1,9)
INREC IFOUTLEN=5560,
IFTHEN=(WHEN=(5551,1,CH,EQ,C'B'),
OVERLAY=(5552:C'Amendment')),
IFTHEN=(WHEN=(5551,1,CH,EQ,C'1'),
OVERLAY=(5552:C'New'))
ICE405A 0 JOINKEYS STATEMENTS HAD MISMATCH IN NUMBER, LENGTH OR ORDER OF KEYS
ICE751I 0 C5-K51707 C6-K51707 C7-K51707 E7-K51707
ICE052I 3 END OF DFSORT
Alas!! The output doesn't giving the data I'm expecting.The first file is getting copied completely inopt output and for the matching keys,the key field is copied from (5552 to 5560) instead of 'Amendment' and 'New'.
P.S : I removed WHEN=OTHERS statement as I was getting errros and I feel this statement won't make any difference.
Please guide me meanwhile I'm trying with trial and error method by referring the DFSORT manual.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
mandyaharsha,
Your control cards are a mess. As bill pointed out
1. Your match indicator is at position 5561 and you are checking for 5552.
2. When you use JOIN UNPAIRED,F1,F2 you would also get the non matching records from FILE2 and you don't have a condition to handle that.
3. I am not even sure why you need to pad the key from File2 at position 5552 as you don't seem to have any use for it.
Assuming you only wanted the matched and unmatched records from just FILE 1 with constants appended at the end then use the following DFSORT control cards.