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
 

 

copybook compare

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sumit agarwalla

New User


Joined: 13 Nov 2008
Posts: 17
Location: hyderabad

PostPosted: Fri Mar 05, 2010 11:25 am    Post subject: copybook compare
Reply with quote

i have got two similar copybooks with more than 400 fields.

copybook1
copybook2

copybook1 is populated with some initial data
copybook2 is populated with some updated data

Now i need to compare this two copybooks for any of 400+ field changes.

Is there any simple way to compare and get the changed field except for the
field by field comparison thing?

Code:
IF A.COPYBOOK1 = A.COPYBOOK2 THEN
   NOT CHANGED
ELSE
   CHANGED.


Please suggest.[/code]
Back to top
View user's profile Send private message

Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Mar 05, 2010 4:16 pm    Post subject:
Reply with quote

Hi Sumit,

I guess there aint no single statement to do it...

Can we get the clarification on what u intend to do with the field ?

Quote:
Is there any simple way to compare and get the changed field except for the field by field comparison thing
Instead of the field by field comparison for 400 fields in your code, you could have a loop to compare just 1 byte at a time. This would certainly give the position where there is any data difference.
Disadvantage : You wouldn't know which field immediately if you need to do some processing.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Mar 05, 2010 4:21 pm    Post subject:
Reply with quote

A good Software Configuration tool could do the job.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Mar 05, 2010 8:45 pm    Post subject:
Reply with quote

Hello,

Different people have understood your requirement differently icon_confused.gif

It is not clear if you want to compare the 2 copybook definitions or if the 2 copybooks are used inside a program and you want to compare the content of all of the fields named in both copybooks.

If the copybooks contain exactly the same fields in the same order and you want to compare the content within a program, your originial "IF" will identify when there is a difference. If you used reference modification, you could compare byte-by-byte and show the position of the first (or all) mismatches in the data. It would not be the field name, but would point to the position of the difference(s).
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sat Mar 06, 2010 3:34 am    Post subject:
Reply with quote

If you need to write the code, I'd use an edit macro to create the code for you. Just loop through the lines of the copybook and add the compare for each field. I had to do something like this on a few hundred fields recently and it only took a few minutes to generate the program that way.
Back to top
View user's profile Send private message
sumit agarwalla

New User


Joined: 13 Nov 2008
Posts: 17
Location: hyderabad

PostPosted: Sat Mar 06, 2010 11:59 am    Post subject: Reply to: copybook compare
Reply with quote

yes, the two copybooks contain exactly the same fields in the same order and i want to compare the content within the program.

I need to have the fields which are changed.
So,i can do a field by field comparison using the "IF" statement which is the only solution which is coming to my mind but that i have to do for all the 400 fields to check for each field.

I was wondering if there is any other way to compare each field in the first copybook to each field in the second copybook with the same layout.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sat Mar 06, 2010 2:08 pm    Post subject:
Reply with quote

Hi Sumit...

You still haven't answered the query.... icon_neutral.gif
Quote:
Can we get the clarification on what u intend to do with the field ?


As it has been already posted... if u just want is the position or just if there is some difference - byte by byte comparison would be a better approach...
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Sat Mar 06, 2010 7:33 pm    Post subject:
Reply with quote

Do you have you a good idea of what a file on Mainframe is. Do you really know what a copybook is.
If you say that copybook1 and copybook2 are strictly the same then forget one of them, concentrate of the content of the files ( different values at various locations depending of copybook and use a compare software like SUPERC, DFSORT, SYNCSORT ( last two not striclty compare software ), COMPAREX, or ECOMP


That's all !!!!!!!!!!!!!!
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sat Mar 06, 2010 8:51 pm    Post subject:
Reply with quote

Hi Pierre...

To be fair to the owner, I think he meant the content of the files only... and in his second post he has mentioned "within the program"..
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sat Mar 06, 2010 11:32 pm    Post subject:
Reply with quote

Also, a copybook is just a file containing one or more data structures (assuming it doesn't contain executable instructions).

It can be a mapping of a file, but by no means must be. It could be a system control block, a program control block, a mapping of any type of data such as input parameters, translatable strings or other types, arrays, or any other data structure. I realize that most COBOL code probably uses copybooks primarily for file mapping, but it isn't fair to accuse someone of ignorance because they might be using a copybook for something else. That would be like saying that an assembler DSECT or C structure can only be used for file mapping (they are exactly the same as a COBOL structure but are very rarely used for file mapping). The original question and followup do not mention files at all. I see no reason to suspect that this is a record compare problem.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Mar 07, 2010 3:14 am    Post subject:
Reply with quote

Hi Sumit,

Why don't you provide a view (5 or 6 entries) of each copybook, then show us the results of the compare you're looking to perform?

It might give us some insight to a solution.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Sun Mar 07, 2010 8:03 pm    Post subject: Reply to: copybook compare
Reply with quote

If you want to display/store the field names, then there is not much choice: you have to have the 400 names listed somewhere:
Code:
    IF CB1-FIELD001 NOT = CB2-FIELD001 THEN
        DISPLAY 'FIELD001 is different'
    END-IF

    IF CB1-FIELD002 NOT = CB2-FIELD002 THEN
        DISPLAY 'FIELD002 is different'
    END-IF
or:
Code:
    IF CB1-FIELD001 NOT = CB2-FIELD001 THEN
        ADD 1 TO LIST-I
        MOVE 'FIELD001' TO LIST-DIFF-FLDS (LIST-I)
    END-IF

    IF CB1-FIELD002 NOT = CB2-FIELD002 THEN
        ADD 1 TO LIST-I
        MOVE 'FIELD002' TO LIST-DIFF-FLDS (LIST-I)
    END-IF


There is something strange in your example:
Quote:
Code:
IF A.COPYBOOK1 = A.COPYBOOK2 THEN
   NOT CHANGED
ELSE
   CHANGED.
What did you mean by "A.COPYBOOK1" ? It is not exactly cobol notation, it looks almost like DB2 notation.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Mar 08, 2010 2:11 pm    Post subject:
Reply with quote

In your ISPF is there a compare utility under option 3 Utilities.

Use that to compare the 2 copy members to list changed lines.

If your copybooks are added to a library system with version control, you might also use a function in the library system to identify changes.

If the 2 copybooks are from different origins (different field names) you might compare the memory mapping of each elementary item to identify where the structure differs.
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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
No new posts COMPARE command sivatechdrive TSO/ISPF 7 Fri Sep 16, 2016 4:31 pm
No new posts Icetool or Joinkeys example to compar... ishant chauhan DFSORT/ICETOOL 21 Sat Aug 20, 2016 2:40 am
No new posts Compare each GDG Generations to other... Ayyappa1 JCL & VSAM 13 Tue Jun 28, 2016 1:48 pm


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