View previous topic :: View next topic
|
Author |
Message |
Suganya87
New User
Joined: 09 May 2016 Posts: 12 Location: India
|
|
|
|
Hi,
I need to write a Cobol program which does file comparison between Latest Generation of file & Base Version of file. Record is 100 bytes long.
Each and every record in the file is in different layout. But we have unique record id for each record. I need to find the fields in the record layout whose values have changed in the latest file .
My approach :
01 latest-file
copy customer-rec1
copy customer-rec2
01 base-file
copy customer-rec1
copy customer-rec2
05 customer-rec1
1o employee id pic x(10).
10 employee pic x(10).
10 designation pic x(10).
10 salary pic 9(10).
Procedure :
Evaluate employee-id of latest-file
when '1000'
if employee of latest-file not= employee of base-file
Write "Mismatch found in employee"
end-if
if designation of latest-file not = designation of base-file
Write "Mismatch found in designation"
end-if
if salary of latest-file not= salary of base-file
Write "Mismatch found in salary
end-if
when other
continue
end-evaluate.
Instead of manual comparison of each and every field in copybook. do we have any other approach to do the same.
Thanks in Advance. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
do we have any other approach to do the same. |
the description of the requirement is too foggy tp provide a good answer...
anyway,
if the comparison is only on selected fields,
You have no alternatives
but You might try, if Your organisation has FILEAID or FILEMANAGER
to see if it can be done with those products ...
I looked once upon a time at FILEMANAGER templates ( the equivalent of cobol copy books )
but building the templates for each record type was pretty complicated ( IMO )
since You have already the copy books
and for both FILEAID and FILEMANAGER You will have to create the templates for each record type
probably a cobol program is the fastest way out |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
You can do it through FILEAID if you have the XREF record layout for your file. One you get the differences in the records you can isolate them and manually browse and see the difference for further analysis. You need to create the XREF layout for your file to do this type of comparison using Fileaid.
If you do not have Fileaid then other approach may be to split the file into different files based on record type. And then manually compare each file of similar records type using Superce 3.13 and list the differences.
If it is a one time activity then it is better to use tools to complete the task than to write a cobol program to achieve the same as you are not doing any processing and its just a simple compare. But if it is a periodic task then its better to write a program as it will help to reduce the effort every time. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
enrico-sorichetti wrote: |
I looked once upon a time at FILEMANAGER templates ( the equivalent of cobol copy books )
but building the templates for each record type was pretty complicated ( IMO ) |
IIRC, File Mangler...err, File Manager can generate the templates from COBOL, HLASM, or PL/I copybooks; at my last client there was a tool (partially written by me) that did just this sort of comparison. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Do both the Unstring and make each field one by one compared. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can there be additions or deletions of records? Are any additions at the "end" of the data, or distributed throughout the data? Do the records have a "key", or "groups" by a key?
You have to describe your data to get simple solutions (if they exist). |
|
Back to top |
|
|
Suganya87
New User
Joined: 09 May 2016 Posts: 12 Location: India
|
|
|
|
Its not an one time activity , we are doing it as a part of regression testing. Actually we have done a manual comparison all those years using 3.13 and identified the mismatch record and do the comparison manually. Since we have all the record layout in place. But now we are planning to automate it. I hope cobol program is oly soln.
Do both the Unstring and make each field one by one compared.
_________________
Regards,
Rohit Umarjikar
Can you please explain me how to unstring the copybook and do the comparison if possible. |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
Suganya87 wrote: |
Its not an one time activity , we are doing it as a part of regression testing. Actually we have done a manual comparison all those years using 3.13 and identified the mismatch record and do the comparison manually. Since we have all the record layout in place. But now we are planning to automate it. I hope cobol program is oly soln.
Do both the Unstring and make each field one by one compared.
_________________
Regards,
Rohit Umarjikar
Can you please explain me how to unstring the copybook and do the comparison if possible. |
If you are doing this comparison activity as part of your regression testing I don't understand the need to write a cobol program for it. Instead you can go for fileaid comparison in batch mode if the files are very huge.
In Fileaid all the changes are detected and any mismatch will be recorded. There are different modes of comparison in Fileaid like R - read ahead Sorted and 1 to 1. You can select mode based on your need. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Or FTP these files to excel ( Only if you have a permission) and then write a simple macro which does column comparison and write mismatch records into another tab. |
|
Back to top |
|
|
Abid Hasan
New User
Joined: 25 Mar 2013 Posts: 88 Location: India
|
|
|
|
Hello,
If it is just comparison of data you're looking for - and you want to use COBOL - doable; but requires quite a bit of coding, and a condition miss here and there, the whole thing can fall apart.
Make sure your input records are SORTed - and SORTing is done on the keys which can act as unique identifiers between both files, such as your report identifier AND acct number (if you have it) - basically the idea is to prepare an input file which would have records in either of them in sequence.
Once you have the two input files ready, now comes the bigger task at hand - writing your COBOL prog.
Use a 2 file-balancing/file-matching logic, to balance both files. Since you have a fixed length of 100 bytes, that makes life easy. Read the input file into a 100 byte record, using reference modification test your record-id, basis the same MOVE the read record into the layout you need. Once you have the data moved into a layout - rest is easy breeze.
Points to remember:
a. The records MUST-AND-MUST be sorted on correct keys prior balancing/matching.
b. You NEED to ensure that there are NO RECORD DROPs during balancing, which is a very common error while writing a matching/balancing logic.
c. End-of-file handling for both files.
For beginner's, I remember Mr. Scherrer sharing a well written and tested code for file matching/balancing on the forum; use it as a reference starting point and build your logic around itl; or use Google to first understand the concept of balancing files. Once you get a hang of it, you'll realize it is a very powerful and handy algorithm if-done-right.
If you face issues, share your code and we can tweak it further.
Hope this helps.
Edit: On an afterthought, if the source that generates these files, is driving the process from VSAM files and building them (which I am assuming will be the case here), then it'd be safe to assume that the data is pre-sorted on keys, and you can jump to balancing minus SORTing (though - do verify this point). |
|
Back to top |
|
|
Suganya87
New User
Joined: 09 May 2016 Posts: 12 Location: India
|
|
|
|
Thanks all for your help. If i find any issue while writing the cobol program. Will keep in touch with guys. Thanks for your valuable feedback and time. |
|
Back to top |
|
|
polamsreddy
New User
Joined: 28 Jun 2016 Posts: 1 Location: India
|
|
|
|
Hi Suganya,
Could you please post the code you tried for comparison.
Thanks,
PSReddy |
|
Back to top |
|
|
|