I have a record with logical record length of 11150. First character is a control character. 2 through 11(length of 10) is key field. 12 through 11150 (length of 11139) is data field. Now I have to compare the field 12 through 11150 (data field). If there is change I have to write to an output file1. If there is any add in key field (column 1 through 11) I have to write to output file2 similarly if there is any delete I have to write to output file3.
• Is there any best way to handle this situation?
• Is there any possibility to compare the character field which has length greater than 4096?
Joined: 18 Jul 2007 Posts: 2150 Location: At my coffee table
Is there any possibility to compare the character field which has length greater than 4096?
In one pass, no....
But with multple passes, it should be easy.
One pass to get the last two outputs built (but I'm not of how the deletes will be worked).
Since the only output from the first requirement is differences, scan each 4000 or so bytes in 4 passes.......
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
I've moved your topic from JCL to COBOL.
Is there any best way to handle this situation?
Suggest you write a 2-file match/merge to accomplish what you want. If you do not know how to write match/merge code there is working sample code in a "Sticky" at the top of this cobol part of the forum.
Download the code and modify for your use. If you find something in the code you do not understand, post questoins here and someone will be able to clarify.
Each of the files needs to be sorted in key sequence before this code is executed.
If the key field of file-1 and file-2 matches (column 2 through 11 - length of 10) then I have to compare the data field of file-1 and file-2 (column 12 through 11150 - length of 11139). It both data fields 1 and 2 are same then there is no problem. If there is change then I have to write the record from file-2 (column 1 through 11150) to output file1.
If it is in COBOL then we can compare field of with any length.
If data-field-1-Length- 11139 = data-field-2-Length- 11139
Even if the solution from Arun works, the reuse is not met.
It is just harcoded.
But OK it should run.
I think the OP was not asking about a reuse. I just re-read the entire thread. It seems like he/she was worried about comparing fields of such huge length.i.e., a field1-of-length-11139 with another field2-of-length-11139. Or is there something which I missed here?