Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
Hi,
I have this job which reads in 2 files of same format, parses out the data then outputs the field values with a pipe char for spreadsheet use. ( thx for help prior on doing that type of thing ).
What I am wondering is how can one retain all of the parsed variable fields so when I process the second files record I could check if %63 in file 1 is different to %63 in the next file. The second file variable %63 will be call %163 or something like that.
When they are different I will need to build output records indicating that a change was made from the last time this file was produced.
I was heading in the direction of building a Symnames file that had field1,(02,10,ch) field2,(102,110,ch) so when I run the following:
I can interrogate the SORTOUT dataset. Which looks like this:
Code:
SDSF OUTPUT DISPLAY Z3A3EB JOB50106 DSID 126 LINE 0 COLS 03- 82
COMMAND INPUT ===> SCROLL ===>
********************************* TOP OF DATA *****************************
0006480 |N001| |ZH01|Johnson law offic |
0021970 |N001| |ZH01|who knows why we do this |
0080360 |N001| |ZH01|get your beer at the git n go |
and the second files record is appended starting here:
Code:
SDSF OUTPUT DISPLAY Z3A3EB JOB50106 DSID 126 LINE 0 COLS 1307- 1386
COMMAND INPUT ===> SCROLL ===> CSR
********************************* TOP OF DATA **********************************
0006480 |N001| |ZH01|KEAHEY LAW OFFICE |
0021970 |N001| |ZH01|PERMIAN BASIN RAILWAYS INC |
0080360 |N001| |ZH01|LUCAS COUNTY CLERK OF COURTS |
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
madmartinsonxx,
I can show you a way to parse and perform the comparison in one go instead of what you are trying to do in multiple passes. However I need more details details.
After the parse what are the fields you need to compare in file 1 and file 2? I see that you are matching the first 10 bytes as key, is that the only key ? If that is the key do you want to validate %63 in file 1 to %63 in the next file AFTER the match is completed on the key?
Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
Yes, Skolusu. The first 10 bytes is the key, and, the only key in the 2 files. Validation is done after a match as well. Some of these keys may be additions ( new in file 1 ) or deletions ( not in file 2 ).
So, from parsed variable %02 through %72 in file one needs to be compared one on one against %02 through %72 in the second file ( file 2 ). This is because the business wants to know exactly which of these fields have changed. Every time a change is identified I need to output the key, the previous % variable then the current % variable. Oh, and in pipe delimited spreadsheet of course.
I will just bet, probably as you would too, that I will be asked the question 'why has this changed for this vendor'. And I won't have a clue because approximately 4 other systems which I dont know anything about had something to do with creating these files !!! So, they want to track this going forward.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
madmartinsonxx,
Here is a DFSORT JCL which will parse and them compare the matched records field by field and then write them out with indicators. I just showed 5 fields and you can extend that to all the 72 parsed fields.
I took your sample input and changed the pipe symbol to tab character for my test data and added a few records to illustrate the match function.
The output contains 4 different type records
Code:
MCH = Match on the key and ALL the other fields are identical in both files
MBD = Match on the key BUT one of the field is different
NEW = A new record which only exists in FILE 1
DEL = A deleted record which only exists in FILE 2
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
0001111 N001 ZH01 ALL FIELDS MATCH
0006480 N001 ZH01 JOHNSON LAW OFFICE
0021970 N001 ZH01 PERMIAN BASIN RAILWAYS INC
0080360 N001 ZH01 LUCAS COUNTY CLERK OF COURTS
7777777 N001 ZH01 NEW RECORD
//IN2 DD *
0001111 N001 ZH01 ALL FIELDS MATCH
0006480 N001 ZH01 KEAHEY LAW OFFICE
0021970 N001 ZH02 PERMIAN BASIN RAILWAYS INC
0080360 N003 ZH01 LUCAS COUNTY CLERK OF COURTS
8888888 N001 ZH01 DELETED RECORD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=IN1,FIELDS=(1,10,A)
JOINKEYS F2=IN2,FIELDS=(1,10,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,1304,F2:1,1304,?)
MCH|0001111 |N001| |ZH01|ALL FIELDS MATCH |
MBD|0006480 |JOHNSON LAW OFFICE |KEAHEY LAW OFFICE |%04 FIELD DOES NOT MATCH|
MBD|0021970 |ZH01|ZH02|%03 FIELD DOES NOT MATCH|
MBD|0080360 |N001|N003|%01 FIELD DOES NOT MATCH|
NEW|7777777 |N001| |ZH01|NEW RECORD |
DEL|8888888 |N001| |ZH01|DELETED RECORD |
Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
whoo hoo !! I got 6 of these right behind it. now my fingers wont go numb typing in all the field offsets. Hot snot.
Hey !! Mind if call my JCL Deck Skolusu ?
thank you, thank you thank you. I would never have pulled that one off.
OUTFIL FNAMES=XOUT01,
IFTHEN=(WHEN=(2609,1,CH,EQ,C'B',AND,(01,1304,CH,NE,1305,1304,CH)),
BUILD=(C'CHG|',135,01,C'|',
1,11,12,5,1316,5,C'%02 FIELD CHANGED'))
ICE282I 0 PERFORMING SYMBOL SUBSTITUTION AS NEEDED
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 - 18:14 ON WED AP
OPTION COPY
JOINKEYS F1=IN1,FIELDS=(1,10,A)
JOINKEYS F2=IN2,FIELDS=(1,10,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,1304,F2:1,1304,?)
OUTFIL FNAMES=XOUT01,IFTHEN=(WHEN=(2609,1,CH,EQ,C'B',AND,(01,1304,CH,
E,1305,1304,CH)),BUILD=(C'CHG|',135,01,C'|',1,11,12,5,1
16,5,C'%02 FIELD CHANGED'))
ICE411I 0 THIS IS THE JOINKEYS MAIN TASK FOR JOINING F1 AND F2
ICE416I 0 JOINKEYS IS USING THE F1 SUBTASK FOR IN1 - SEE JNF1JMSG MESSAGES
ICE416I 1 JOINKEYS IS USING THE F2 SUBTASK FOR IN2 - SEE JNF2JMSG MESSAGES
ICE419I 0 JOINED RECORDS: TYPE=F, LENGTH=2609
ICE201I G RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE221A 1 INVALID FIELD OR CONSTANT IN XOUT01 IFTHEN 1 CONDITION 2
ICE751I 0 C5-K51707 C6-K51707 C7-K54603 C8-K51707 E9-K51707 E7-K51707
ICE052I 3 END OF DFSORT
Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
ok, gotcha. what i thought you were saying in previous post is that i could only have 256 in one ifthen=when. like 256 in a row.
i will adjust the proc.
ty.
Joined: 10 Dec 2010 Posts: 96 Location: Massachusetts
Code:
IFTHEN=(WHEN=NONE,
pertaining to this post and the great advice therein is there a way when the preceding conditions do not get satisfied and there is a WHEN=NONE raised to 'do nothing' ? like maybe write to a DD DUMMY ?
reason for this is i am using this identical logic in another proc and a S222 is happening do to the large volume of data i am not dealing with. that is what this shop forces if estimated lines are exceeded too many times.
thanks.
p.s. yes i looked around at other posts and the manual.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
madmartinsonxx wrote:
Code:
IFTHEN=(WHEN=NONE,
pertaining to this post and the great advice therein is there a way when the preceding conditions do not get satisfied and there is a WHEN=NONE raised to 'do nothing' ? like maybe write to a DD DUMMY ?
Not really. When=NONE is applied when all the other when=cond are false. In your case when=none is to capture the record which is a match and ALL the fields are identical from both files. And it writes the record with MCH indicator and record from file 1 (it doesn't matter which file record you write out as both the records are identical).
Quote:
reason for this is i am using this identical logic in another proc and a S222 is happening do to the large volume of data i am not dealing with. that is what this shop forces if estimated lines are exceeded too many times.thanks.
S222 abend is an "operator cancel" abend. Did you talk to your systems folks and see as to why they might have canceled the job? Are the files on tape?
p.s. yes i looked around at other posts and the manual.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Martin,
Two comments:
Quote:
is a WHEN=NONE raised to 'do nothing'
Depends on what you mean by "do nothing". If you mean "don't make any changes to the record", you can use something like this as a NOP:
Code:
WHEN=NONE,OVERLAY=(1:1,1)
If you mean something else, you need to explain what you mean.
This will overlay position 1 with the character in position 1 which essentially does "nothing".
Quote:
i have tried hit=next, when=init but get syntax issues.
WHEN=INIT clauses are always treated as if HIT=NEXT was specified, so you can't specify HIT=NEXT for them. WHEN=INIT and WHEN=GROUP clauses must be first and are ALL processed regardless of the results of the previous clause.