There is not specific identification of the main records. But the trick here would be we are not considering the main records if we dont have any sub ones.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Niki wrote:
Kolusu,
There is not specific identification of the main records. But the trick here would be we are not considering the main records if we dont have any sub ones.
huh? if there is no unique identity to main records , how do you distinguish which positions to pick? You are picking fields from 4 different places and there should be a way to identify them.
If you can't identify the main record or the sub records how do you know which record to drop or which record to pick?
Cannot we have some condition to check, If the first record value from 11 to 7 position is same as the next ones 22 to 7 then the prior one is the main record and the below one as the Sub records.
Because always the key value is getting stored in different places for main record and sub record.
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
Niki wrote:
Cannot we have some condition to check
Of course we can. However, it is necessary that you tell us what the criteria are; we will not play "Hot and Cold" trying to drag them out of you.
Quote:
If the first record value from 11 to 7 position is same as the next ones 22 to 7 then the prior one is the main record and the below one as the Sub records.
Is that the complete and only criterion? Answer "yes" or "no". If the answer is "no", give us the complete list.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
I looked at this more closely and your shown output does NOT match the input. I don't see a sub record PLER123 AA01 for the 3rd group you show in your output. Where did you get this from?
Assuming that it is a typo, the following DFSORT JCL will give you the desired results.
Step0100 - will create the Output file 1 which will be used later to generate output files 2 and 3.
Step0300 - will create Output 2 and 3.
The only trick here is to use the same input file twice with Joinkeys and create a matched records whenever we find a sub record.
Since your input is a VB file you need to account for the RDW and all the fields you need actual start adding 4 bytes to the positions you mentioned.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Isn't every program which reads this file faced with the same problem? It would only know whether a record is "main" (except for the first one) by reference to the previous record? Which could be a "main" or a "sub". Even ignoring the possibility of an unfortunate mismatch of keys (where data happens to equal key value) it is a pretty absurd (rather than complex) structure.
Why don't you change the program which creates the file to include a record-type?
If that is somehow "impossible", why don't you "post-process" the file to include a record-type so that the rest of the system can know easily what is going on? Except...
If the original program creates a sub-record with an incorrect key, you are pickled, as you now have a new "main" record, as are any genuine sub-records which follow it.
Change the program which creates the file, or your system deserves everything it has coming to it.