We have two records in the VSAM file one is primary and secondary
S0100DDAAAAA ==Secondary
P0100DDAAAAA ==Primary
Always primary key has FLAG at 450 postition 'N'.
If primary flag has 'N' in 450th position then i should also skip the secondary record. But secondary record will not have the flag to skip or omit.
Currently the program just check the matching record for FLAG 'N', If matched it just skip the record from the copy. Due to this only primary record is skipped, But secondary record is written.
Code:
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(3,1,A,5,2,A,8,4,A,13,5,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A,2,2,A,4,4,A,8,5,A),SORTED,
TYPE=F,NOSEQCK
REFORMAT FIELDS=(F1:1,1354)
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
SORT FIELDS=COPY
//JNF2CNTL DD *
INCLUDE COND=(450,1,CH,NE,C'N')
INREC BUILD=(1,12)
/*
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
How do you determine the primary key and the secondary key? The char 's' or 'p' in the first byte? If so since it is VSAM file and is already sorted on the key field how did you have "S" record before a "P" record?
Either way remove the include cond in JNF2CNTL and use INREC WHEN=GROUP to push the "N" Indicator to the secondary record. Build the record with Key and indicator
Change the reformat to include the indicator on the main task and code an OMIT condition to remove the joined records with "N" indicator on the main task.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
magesh23586 wrote:
thank you for the kind advice.
Sorry Kolusu, I couldn't get you, doesn't have much knowledge, IF you could share me a sample code will be great.
Here is what I did to fix this issue, Please advice.
You did NOT answer any of questions but you want a sample code? Quite demanding eh? Remember that I can neither read your brain or look over your shoulder to understand the requirement. You need to explain in detail about the requirement.
Secondly Why would you split the job into 2 steps? when a single pass of Joinkeys was doing the job earlier? Why couldn't you code the same control cards you used in step01 as JNF2CNTL?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
magesh23586 wrote:
Tried this way but no joy, none of records are filtered, all the records came into the output file I think I am missing something
Code:
JOINKEYS FILE=F2,FIELDS=(1,2,A,3,4,A,7,5,A)
//JNF2CNTL DD *
INCLUDE COND=(450,1,CH,EQ,C'N')
/*
Looks like we are going in circles. I guess I should give up. Did you even compare the step01 control cards with your JNF2CNTL control cards?
Code:
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(450,1,CH,EQ,C'N')
OUTREC FIELDS=(1:2,11)
/*
You are moving the key value using OUTREC from position 2 to position 1 and you don't that in your JNF2. If you haven't done then you at least need to change the Joinkey FIELDS and you haven't done that and you are wondering why you got wrong results?
I have no clue as to why you removed the SORTED,NOSEQCK from your joinkey statements or why your key fields changed from 4 fields to 3 fields.
Anyway good luck. I can't be spending time on an infinite loop of requirements.
The reason why removed OUTREC, it is not supporting, But yes over sight error missed to look at Joinkey of F2.
Because I missed to look at joinkey, on a trail error I removed it which is my mistake
The reason why I changed 4 to 3 fields is because, 1st colum in vsam file is of Record type S OR P OR 1 OR 9 etc. If I compare it will full key then, only 1 record will be skipped
For example
IF we have three records in the Flat file 1
C~S~01~00DD~AAAAA ==Secondary
C~1~01~00DD~AAAAA ==Primary
C~2~01~00DD~AAAAA ==Secondary
Three records in the VSAM File
S0100DDAAAAA
10100DDAAAAA N
20100DDAAAAA
Output file will have following records, where these record also needs to skipped, because all three belongs to same group.
C~S~01~00DD~AAAAA
C~2~01~00DD~AAAAA
So if I remove the first field then it will compare only the below values
File1 VSAM1
0100DDAAAAA ==> 0100DDAAAAA
All the three records will be skipped, which is what required.
Here is the updated code which worked.
Code:
//SYSIN DD *
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(3,1,A,5,2,A,8,4,A,13,5,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A,2,2,A,4,4,A,8,5,A),SORTED,
NOSEQCK,TYPE=F
REFORMAT FIELDS=(F1:1,1354)
JOIN UNPAIRED,F1,ONLY
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
SORT FIELDS=(3,15,CH,A) ==> added this to make the output file in the same seq of the source,
/*
//JNF2CNTL DD *
INCLUDE COND=(450,1,CH,EQ,C'N')
/*
Only one question, is there a way to retain the same sequence of source file in the output file, Currently I am doing via sort fields.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
magesh23586 wrote:
Thank you very much, Your advice/solution worked.
The reason why removed OUTREC, it is not supporting, But yes over sight error missed to look at Joinkey of F2.
I gather from this you did NOT read upon Joinkeys or look at your previous working solution where an INREC was used. When a solution is posted , just don't copy a working solution and forget about it. Understand what the job does and in future any changes((like the one you had) will be an easy task. Don't rely on someone to help you round the clock. As is learning is not a bad thing, so you should give it a try.
Here is the link to Joinkeys documentation and read upon the section 4.1.1 JOINKEYS Application Processing
I really doubt if the code worked for you as you still show that you are comparing the 1 first byte of VSAM key which you are supposed to ignore. But if you say it works then whom I to complain.
magesh23586 wrote:
Only one question, is there a way to retain the same sequence of source file in the output file, Currently I am doing via sort fields.
Thanks for all your valuable inputs.
Code a JNF1CNTL with an INREC Overlay an 8 byte sequence number at the end (pos 1395) and sort on that sequence number in the main task and remove it using OUTREC.
Sorry copied the other code which i did for my testing. Please find the below code, which worked.
Code:
//SYSIN DD *
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(5,2,A,8,4,A,13,5,A)
JOINKEYS FILE=F2,FIELDS=(2,2,A,4,4,A,8,5,A),SORTED,
NOSEQCK,TYPE=F
REFORMAT FIELDS=(F1:1,1354)
JOIN UNPAIRED,F1,ONLY
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
SORT FIELDS=(3,15,CH,A) ==> added this to make the output file in the same seq of the source,
/*
//JNF2CNTL DD *
INCLUDE COND=(450,1,CH,EQ,C'N')
INREC BUILD=(2,11)
/*