|
View previous topic :: View next topic
|
| Author |
Message |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Hi friends,
Input1 -
FB
LRECL = 60
Key = 27,8,CH
INCLUDE COND=(38,1,CH,EQ,C'N')
Input2 -
FB
LRECL = 32
Key = 3,8,CH
INCLUDE COND=(1,2,CH,EQ,C'13')
Match ON Key, and match only those records which satisfy INCLUDE COND
Expected:
Output1 - Matched records
Output2 - Unmatched records
For Output1, I have tried following SPLICE JCL:
| Code: |
//STEP001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=MYINPUT1
//IN2 DD DSN=MYINPUT2
//TEMP1 DD DSN=&&TEMP1,DISP=(,PASS),SPACE=(CYL,(1,5)),UNIT=SYSDA
//TEMP2 DD DSN=&&TEMP2,DISP=(,PASS),SPACE=(CYL,(1,5)),UNIT=SYSDA
//CONCAT DD DSN=*.TEMP1,VOL=REF=*.TEMP1,DISP=(OLD,PASS)
// DD DSN=*.TEMP2,VOL=REF=*.TEMP2,DISP=(OLD,PASS)
//OUTPUT1 DD DSN=matchind output1.........
//TOOLIN DD *
COPY FROM(IN1) TO(TEMP1) USING(CTL1)
COPY FROM(IN2) TO(TEMP2) USING(CTL2)
SPLICE FROM(CONCAT) TO(OUTPUT1) ON(61,8,CH) WITH(69,32) -
KEEPNODUPS USING(CTL3)
/*
//CTL1CNTL DD *
SORT FIELDS=(27,8,CH,A)
INCLUDE COND=(38,1,CH,EQ,C'N')
OUTREC FIELDS=(1,60, INPUT1 DATA
61:27,8, ADD KEY ON RIGHT
69:32X) ADD SPACES TO MATCH WITH TEMP2
/*
//CTL2CNTL DD *
SORT FIELDS=(3,8,CH,A)
INCLUDE COND=(1,2,CH,EQ,C'13')
OUTREC FIELDS=(61:1,8, PUT MERCHANT ID RHS
69:1,32) ENTIRE INPUT
/*
//CTL3CNTL DD *
OPTION COPY
OUTFIL FNAMES=OUTPUT1,OUTREC=(1,60)
/*
|
After running, I am getting lots of records which have spaces. I am also not sure if my SPLICE is working as I am running the JCL with lots of records.
Can you please advice, how can I create output2 (unmatched)?
Many thanks,
zh_lad |
|
| Back to top |
|
 |
PeterHolland
Global Moderator

Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
| If you want any help use code tags. I do that only once. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Forget SPLICE unless your DFSORT is not up-to-date.
Can you post the ICE201I message from any Sort step and we can see?
JOINKEYS is what you want.
In the JNFnCNTL files you can do your INCLUDEs for the separate files.
The matched/unmatched is simple using the ? (match marker) on the REFORMAT record.
You need two OUTFILs.
Do you have duplicates by key on either file? |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks for your reply. I am returning to Mainframe, JCL and SORT after 3 years gap, was doing Non Mainframe related work.
My files can have duplicates on Key, but with INCLUDE COND in both files, I will have only one record (1 to 1).
Input1:
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6
***************************** Top of Data *******************
HDR,2012-06-26,
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,R,2012-06-26,
DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26,
TRL,00000009 |
Input2:
| Code: |
----+----1----+----2----+----3--
***************************** To
----+----1----+----2----+----3--
***************************** To
13000001 CB2012-10-22
13000002 CB2012-10-22
13000007 CB2012-10-22
13000010 CB2012-10-22
14000010 CB2012-10-22
13000011 CB2012-10-22 |
Expected Output1:
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6
***************************** Top of Data *******************
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26, |
My JCL is giving this output1:
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6
****** ***************************** Top of Data ******************
000001 DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
000002 DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
000003 DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26,
000004 DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
000005 DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
000006 DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26,
000007
000008
000009
000010
000011 |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK. But....
When you run your job you get messages in the Sysout. One of which is ICE201I. I asked if you could show us that, because unless you have no option (due to out-of-date product) then SPLICE is not the way to go, and I, for one, am not going to look at a SPLICE for problems unless there is a reason to.
From what you have described, the task is very simple with JOINKEYS. The ICE201I will tell us if you have JOINKEYS. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
When I use JOINKEYS.
| Code: |
//STEP001 EXEC PGM=SORT
//SORTJNF1 DD DSN=TTMA.L.NMA0306.#N.MREGCSV.RV4,DISP=SHR
//SORTJNF2 DD DSN=TTMA.N.NMA0125.#1.MADBMFNX.O6,DISP=SHR
//SORTOF01 DD DSN=TTMA.N.NMA0306.#N.MREGCSV.NOTIFIED.FOUND,
// RECFM=FB,LRECL=60,DISP=(,CATLG),
// DATACLAS=DSIZE100
//SORTOF02 DD DSN=TTMA.N.NMA0306.#N.MREGCSV.NOTIFIED.NOTFD,
// RECFM=FB,LRECL=60,DISP=(,CATLG),
// DATACLAS=DSIZE100
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(27,8,A)
JOINKEYS FILE=F2,FIELDS=(3,8,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,60,F2:1,1)
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(61,1,CH,NE,X'40'),BUILD=(1,60)
OUTFIL FILES=02,INCLUDE=(61,1,CH,EQ,X'40'),BUILD=(1,60)
/* |
I am getting following output:
Output1:
| Code: |
000001 DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
000002 DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
000003 DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
000004 DTL,2012-06-23,00:00:0000,000010 ,C,R,2012-06-26,
000005 DTL,2012-06-23,00:00:0000,000010 ,C,R,2012-06-26,
000006 DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26, |
Output2:
| Code: |
HDR,2012-06-26,
TRL,00000009
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26, |
Please advice, what is wrong in my JCL?
Updated later - Apology as I have not used INCLUDE COND on both inputs. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You have a "hit" on 7 and 11, a "miss" with 12, 13 and 15, and four "hits" for 10 because, despite what you thought, you have two 10s on your input and two on your output.
You haven't done the INCLUDEs.
These should be in the JNFnCNTL files, which you aren't using.
You are not using the ? (match marker).
You have not posted the ICE201I.
Do you have SyncSort? |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi zh_lad,
What is your expected output in both the output files?
If you could say that someone will be able to tell you |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
| Bill Woodger wrote: |
You have a "hit" on 7 and 11, a "miss" with 12, 13 and 15, and four "hits" for 10 because, despite what you thought, you have two 10s on your input and two on your output.
You haven't done the INCLUDEs.
These should be in the JNFnCNTL files, which you aren't using.
You are not using the ? (match marker).
You have not posted the ICE201I.
Do you have SyncSort? |
I do not know the syntax to use INCLUDE COND on JOINKEYS
What is that?
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
I do not know but I can say this supports both SPLICE and JOINKEYS |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| zh_lad wrote: |
I do not know the syntax to use INCLUDE COND on JOINKEYS
What is that? |
In that case, you may wish to read the fine manual on JOINKEYS. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Input1 (driver):
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6
HDR,2012-06-26,
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,R,2012-06-26,
DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,R,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26,
TRL,00000010 |
While matching use INCLUDE COND=(38,1,CH,EQ,C'N'),
FB
LRECL = 60
Key = 27,8,CH
Input2:
| Code: |
----+----1----+----2----+----3--
----+----1----+----2----+----3--
13000001 CB2012-10-22
13000002 CB2012-10-22
13000007 CB2012-10-22
13000010 CB2012-10-22
14000010 CB2012-10-22
13000011 CB2012-10-22
14000011 CB2012-10-22
13000019 CB2012-10-22 |
while matching use INCLUDE COND=(1,2,CH,EQ,C'13')
FB
LRECL = 32
Key = 3,8,CH
Expected Output1 (Matched from Input1):
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6
***************************** Top of Data *******************
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26, |
Expected Output2 (unmatched from Input1):
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6
***************************** Top of Data *******************
DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26, |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, you're pretty up-to-date (that's the H bit in the message).
Like the "CNTL" files for ICETOOL, JOINKEYS has "CNTL" files. JNF1CNTL (for the first file on the JOINKEYS) and JNF2CNTL (for the second).
So, for testing
| Code: |
//JNF1CNTL DD *
INCLUDE COND=(whatever for file 1
//JNF2CNTL DD *
INCLUDE COND=(whatever for file 2
|
Once out of unit-testing, I'd hope they'd be on a PDSE/PDS, but that is another story.
On your REFORMAT try this:
| Code: |
| REFORMAT FIELDS=(F1:1,60,?) |
The ? (you code it like that) is the "match marker". On the REFORMAT record, it will have a value of "B" for Both files, 1 for File 1 only and 2 for File 2 only (which you won't get with your control cards).
On the OUTFIL, rather than negating the test, you can use SAVE, which says "everything else you haven't already written to an OUTFIL". |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks. My latest code:
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(27,8,A)
JOINKEYS FILE=F2,FIELDS=(3,8,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,60,F2:1,1)
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(61,1,CH,NE,X'40'),BUILD=(1,60)
OUTFIL FILES=02,INCLUDE=(61,1,CH,EQ,X'40'),BUILD=(1,60)
/*
//JNF1CNTL DD *
INCLUDE COND=(38,1,CH,EQ,C'N')
/*
//JNF2CNTL DD *
INCLUDE COND=(1,2,CH,EQ,C'13')
/* |
Input1:
| Code: |
HDR,2012-06-26,
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,R,2012-06-26,
DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26,
TRL,00000009 |
Input2:
| Code: |
13000001 CB2012-10-22
13000002 CB2012-10-22
13000007 CB2012-10-22
13000010 CB2012-10-22
14000010 CB2012-10-22
13000011 CB2012-10-22 |
Output1:
| Code: |
DTL,2012-06-23,00:00:0000,000007 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000010 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000011 ,C,N,2012-06-26, |
Output2:
| Code: |
DTL,2012-06-23,00:00:0000,000012 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000013 ,C,N,2012-06-26,
DTL,2012-06-23,00:00:0000,000015 ,C,N,2012-06-26, |
Many thanks for your help. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| No problem. I still think you should look at the ? and the SAVE. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(27,8,A)
JOINKEYS FILE=F2,FIELDS=(3,8,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,60,?)
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(61,1,CH,NE,X'40'),BUILD=(1,60)
OUTFIL FILES=02,SAVE,BUILD=(1,60)
/*
//JNF1CNTL DD *
INCLUDE COND=(38,1,CH,EQ,C'R')
/*
//JNF2CNTL DD *
INCLUDE COND=(1,2,CH,EQ,C'14')
/* |
| Code: |
| REFORMAT FIELDS=(F1:1,60,?) |
does not work. I am getting Empty file in SAVE.
Do I need to modify INCLUDE as you said Indicator can have: 'B', '1' or '2'.
| Code: |
| INCLUDE=(61,1,CH,NE,X'40') |
to
| Code: |
| INCLUDE=(61,1,CH,EQ,'B') |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yep. The indicator in your case will be B for on both files or 1 for a record on File 1 only (you are not interested in File 2 mismatches).
So, change the INCLUDE and it should all be there. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
I am getting this error:
| Code: |
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 09:17 ON WED OC
JOINKEYS FILE=F1,FIELDS=(27,8,A)
JOINKEYS FILE=F2,FIELDS=(3,8,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,60,?)
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(61,1,CH,EQ,'B'),BUILD=(1,60)
£
ICE113A E COMPARISON FIELD ERROR
OUTFIL FILES=02,INCLUDE=(61,1,CH,EQ,'1'),BUILD=(1,60)
£
ICE113A E COMPARISON FIELD ERROR |
I have tried without quotes as well. Is format of indictor is other than CH?
Thanks. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
FM,
CH,EQ,'B'
should be
CH,EQ,C'B' |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You specify a character literal by prefixing with C and bounding by single quotation marks:
You already saw a "hex" literal (X'40') which you could also have specified as C' '. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
| Many thanks, and apology for not resolving my own. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Hi,
Some questions on REFORMAT statement.
SORT Manual says:
The REFORMAT statement indicates the fields from the F1 file and/or the F2 file you want to include in the joined records, and the order in which you want the fields to appear. You can also include an indicator of where the key was found in the joined records ('B' for key found in F1 and F2, '1' for key found in F1 only, or '2' for key found in F2 only).
Method1:
| Code: |
REFORMAT FIELDS=(F1:1,60,F2:1,1)
OUTFIL FILES=01,INCLUDE=(61,1,CH,NE,X'40'),BUILD=(1,60) |
Question1 - Why it is F2:1,1 (pos 1, length 1 from file2)? How come file2 first byte has indicator?
Method2:
| Code: |
REFORMAT FIELDS=(F1:1,60,?)
OUTFIL FILES=01,INCLUDE=(61,1,CH,EQ,C'B'),BUILD=(1,60) |
Can I reformat joined record from both the files? I mean:
| Code: |
| REFORMAT FIELDS=(F1:1,25,F2:1,15,?) |
first 25 bye from F1 + First 15 bytes from F2 + Indicator
provided, I have done JOIN UNPAIRED,F1,F2
Question2: Would this have still worked for Indicator identification in INCLUDE COND used in OUTFIL?
Many thanks. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The Fn:1,1 and then test for space is a SyncSort technique because SyncSort does not have the ? marker. You need to choose a location which cannot possibly have that value, so doesn't need to be 1,1, you can change the fill character (used to create "no data" for a mismatch) to another value as well.
Yes, your REFORMAT can contain data from both files. Most often it will. Where there is a mismatch, the data from the file which did not match gets set to a "pad" value.
Yes, the ? indicator will still tell you the "condition" of the JOIN. B, 1 or 2, and this is 100% reliable without expending effort choosing a location/different pad value. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Many thanks for addressing these questions. I have tried REFORMAT having fields from both the files - it works very well.
It has been two good days of learning SORT/JOINKEYS.
Cheers! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|