Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

File comparsion - Records are in different Layout

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: File comparsion - Records are in different Layout
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue May 10, 2016 1:16 pm    Post subject: Reply to: File comparsion - Records are in different Layout
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    Post subject: Re: File comparsion - Records are in different Layout
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: 1738
Location: Bloomington, IL

PostPosted: Tue May 10, 2016 6:51 pm    Post subject: Re: Reply to: File comparsion - Records are in different Layout
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue May 10, 2016 11:19 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed May 11, 2016 12:50 am    Post subject: Reply to: File comparsion - Records are in different Layout
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    Post subject:
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed May 11, 2016 8:49 pm    Post subject:
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: 65
Location: India

PostPosted: Thu May 12, 2016 11:18 am    Post subject:
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    Post subject:
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    Post subject: File Comparison
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 1 Fri Dec 09, 2016 4:40 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us