Author: Abid Hasan
Posted: Tue Apr 18, 2017 6:33 pm (GMT 5.5)
Hello,
Basis what is shared, and if I understand it correctly, the requirement is to read a dataset and test each record for a certain value. All of these records being tested WILL BE a part of a group which can be uniquely identified using an existing header and tail record. There can be multiple groups, and each group can have as high as 15k records.
If the value being tested matches, then the entire group of records need to be written to output, else this group needs to be discarded.
If the above understanding is correct, AND you're looking for a COBOL solution - which will be much simpler to code as against DFSORT. The underlying challenge here is to hold the group of records in place until the test is complete; and until this point TS has not stated where THIS record which is to be tested will be present - so assumption is that it can occur anywhere in the entire group.
Define a table large enough to hold the entire group of records, say 15000.
Read each record, identify if it is header, start writing to the table. At the same time also test if YOUR condition holds true. If condition is true, then set a flag to true, then first write the complete table written until this point to output DS, followed by writing subsequent records directly to output (no need to write table anymore until the tail record for this group is encountered).
Once tail record is encountered, stop writing to output, initialize the table - and repeat the complete process as stated earlier.
In case of DFSORT, at best I think 2 passes of data will be required, and presumably the code will be a little complex - reason remains same - finding an algorithm to uniquely identify the data to be grouped and written.
Edit: The complexity increases if the position of the value to be checked is not fixed in the record.
_________________
Thanks.
Posted: Tue Apr 18, 2017 6:33 pm (GMT 5.5)
Hello,
Basis what is shared, and if I understand it correctly, the requirement is to read a dataset and test each record for a certain value. All of these records being tested WILL BE a part of a group which can be uniquely identified using an existing header and tail record. There can be multiple groups, and each group can have as high as 15k records.
If the value being tested matches, then the entire group of records need to be written to output, else this group needs to be discarded.
If the above understanding is correct, AND you're looking for a COBOL solution - which will be much simpler to code as against DFSORT. The underlying challenge here is to hold the group of records in place until the test is complete; and until this point TS has not stated where THIS record which is to be tested will be present - so assumption is that it can occur anywhere in the entire group.
Define a table large enough to hold the entire group of records, say 15000.
Read each record, identify if it is header, start writing to the table. At the same time also test if YOUR condition holds true. If condition is true, then set a flag to true, then first write the complete table written until this point to output DS, followed by writing subsequent records directly to output (no need to write table anymore until the tail record for this group is encountered).
Once tail record is encountered, stop writing to output, initialize the table - and repeat the complete process as stated earlier.
In case of DFSORT, at best I think 2 passes of data will be required, and presumably the code will be a little complex - reason remains same - finding an algorithm to uniquely identify the data to be grouped and written.
Edit: The complexity increases if the position of the value to be checked is not fixed in the record.
_________________
Thanks.