|
|
| Author |
Message |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
I have two files of LRECL 100 each.
I want to match the two files record-wise.
My intention is to write a record to the output file (from the first i/p file) if there is any change in the 10th character of the two i/p files.
Basically I'm matching 1st record of i/p file-1 to 1st record of i/p file-2 and if a change happens in 10th character, record from i/p file-1 will be written to o/p.
I wrote an SYNCTOOL job to perform this.
| Code: |
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(102,8,ZD) ON(10,1,CH) NODUPS-
USING(CTL3)
|
where IN1 and IN2 are i/p files.
CTL1 is
| Code: |
| INREC OVERLAY=(101:C'1',102:SEQNUM,8,ZD) |
CTL2 is
| Code: |
| INREC OVERLAY=(101:C'2',102:SEQNUM,8,ZD) |
CTL3 is
| Code: |
| OUTFIL FNAMES=OUT,INCLUDE=(101,1,CH,EQ,C'2'),BUILD=(1,100) |
Now I have an added requirement. According to the card given here, whatever be the change for 10th character, it will be written to the o/p file.
Now I want it as only if the 10th character changes from Y to N, I need to write the record to the o/p file.
Can something be added to this same sort card to get the desired o/p |
|
| Back to top |
|
 |
References
|
|
 |
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 162 Location: hyderabad
|
|
|
|
raak,
The best way to do this one is using 'JOIN' function of SYNCSORT.Please check the SYNCSORT version of your shop and let us know.
Please also provide the sample input and the expected output.
Thanks
Krishy |
|
| Back to top |
|
 |
kalukakkad
Active User
Joined: 10 Mar 2005 Posts: 73
|
|
|
|
Here's the SYNCSORT JOINKEYS method that would do the trick.
CTL1
INREC FIELDS=(1,100,101,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'Y')
CTL2
INREC FIELDS=(1,100,101,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'N')
CTL3
JOINKEYS FILES=F1,FIELDS=(101,8,A)
JOINKEYS FILES=F2,FIELDS=(101,8,A)
SORT FIELDS=COPY
OUTFIL FILES=01,OUTREC=(1,100) |
|
| Back to top |
|
 |
kalukakkad
Active User
Joined: 10 Mar 2005 Posts: 73
|
|
|
|
sorry the CTL1 & CTL2 should be
CTL1
INREC FIELDS=(1,100,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'Y')
CTL2
INREC FIELDS=(1,100,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'N') |
|
| Back to top |
|
 |
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1159 Location: Mumbai - India
|
|
|
|
raak,
Search the JCL forum for "JOINKEYS" and you would find similar topics/examples. |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
| Quote: |
Here's the SYNCSORT JOINKEYS method that would do the trick.
CTL1
INREC FIELDS=(1,100,101,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'Y')
CTL2
INREC FIELDS=(1,100,101,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'N')
CTL3
JOINKEYS FILES=F1,FIELDS=(101,8,A)
JOINKEYS FILES=F2,FIELDS=(101,8,A)
SORT FIELDS=COPY
OUTFIL FILES=01,OUTREC=(1,100) |
there is one problem with this card.. It will take only those records which has a 'Y' in the 10th position from file-1 and 'N' in the 10th position from file-2.
here the problem is that my record sequence in both files might get corrupted..for eg:
File 1
123456789Y
012345678N
901234567Y
File 2
123456789N
012345678N
901234567N
in this case, only the first 2 records from the input file-1 will be included and 3 records from file-2 will be included - as per the INCLUDE condition in the cards.
So effectively the 3rd record from input file-1 will be matched against 2nd record from file-2.
Is this happening the same way I described or am I getting wrong somewhere??? |
|
| Back to top |
|
 |
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 162 Location: hyderabad
|
|
|
|
raak,
What is the output file you are expecting from the below 2 sample i/p files ?
File 1
123456789Y
012345678N
901234567Y
File 2
123456789N
012345678N
901234567N
Thanks
Krishy |
|
| Back to top |
|
 |
kalukakkad
Active User
Joined: 10 Mar 2005 Posts: 73
|
|
|
|
did you try the JOINKEYs. What was the output you were getting. Please let us know.
Below is the description of what the Sort is doing.
File-1
123456789Y
012345678N
901234567Y
File-2
123456789N
012345678N
901234567N
Selection from File-1
123456789Y00000001
901234567Y00000003
Selection from File-2
123456789N00000001
012345678N00000002
901234567N00000003
The JOINKEYS are on SEQNUM,hence,
123456789Y00000001 of File-1 will match against 123456789N00000001 of File-2
901234567Y00000003 of File-1 will match against 901234567N00000003 of File-2
In the output you will get
123456789
901234567 |
|
| Back to top |
|
 |
raak
Active User
Joined: 23 May 2006 Posts: 174 Location: chennai
|
|
|
|
| Can we actually combine ICETOOL with JOINKEYS feature...I am getting some error messages as DDnames CTL3JNF1 and CTL3JNF2 are required... |
|
| Back to top |
|
 |
kalukakkad
Active User
Joined: 10 Mar 2005 Posts: 73
|
|
|
|
you have to use SYNCTOOL. Try with this JCL.
//SORT EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=XXXX.IN1,DISP=SHR
//IN2 DD DSN=XXXX.IN2,DISP=SHR
//CTL1JNF1 DD DSN=XXXXXX.Temp1,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,1))
//CTL1JNF2 DD DSN=XXXXXX.Temp2,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,1))
//CTL1OF01 DD DSN=XXXXXXX.OUTPUT,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(1,1))
//TOOLIN DD *
SORT FROM(IN1) TO(CTL1JNF1) USING(CTL0)
SORT FROM(IN2) TO(CTL1JNF2) USING(CTLA)
SORT FROM(CTL1JNF1) USING(CTL1)
//CTL0CNTL DD *
INREC FIELDS=(1,100,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'Y')
//CTLACNTL DD *
INREC FIELDS=(1,100,SEQNUM,8,ZD)
SORT FIELDS=COPY
INCLUDE FIELDS=(10,1,CH,EQ,C'N')
//CTL1CNTL DD *
JOINKEYS FILES=F1,FIELDS=(101,8,A)
JOINKEYS FILES=F2,FIELDS=(101,8,A)
REFORMAT FIELDS=(F1:1,100)
SORT FIELDS=COPY
OUTFIL FILES=01,OUTREC=(1,100)
/*
IN1 File has
123456789Y
012345678N
901234567Y
IN2 File has
123456789N
012345678N
901234567N |
|
| Back to top |
|
 |
|
|
|