IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

File comparsion - Records are in different Layout


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Tue May 10, 2016 1:05 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue May 10, 2016 1:16 pm
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue May 10, 2016 4:00 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue May 10, 2016 6:51 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Tue May 10, 2016 11:19 pm
Reply with quote

Do both the Unstring and make each field one by one compared.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 11, 2016 12:50 am
Reply with quote

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
View user's profile Send private message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Wed May 11, 2016 2:09 pm
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Wed May 11, 2016 3:46 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Wed May 11, 2016 8:49 pm
Reply with quote

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
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Thu May 12, 2016 11:18 am
Reply with quote

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
View user's profile Send private message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Thu May 12, 2016 12:22 pm
Reply with quote

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
View user's profile Send private message
polamsreddy

New User


Joined: 28 Jun 2016
Posts: 1
Location: India

PostPosted: Wed Jun 29, 2016 12:30 pm
Reply with quote

Hi Suganya,
Could you please post the code you tried for comparison.

Thanks,
PSReddy
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top