View previous topic :: View next topic
|
Author |
Message |
sumit agarwalla
New User
Joined: 13 Nov 2008 Posts: 17 Location: hyderabad
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
A good Software Configuration tool could do the job. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Different people have understood your requirement differently
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 |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
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 |
|
|
sumit agarwalla
New User
Joined: 13 Nov 2008 Posts: 17 Location: hyderabad
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Sumit...
You still haven't answered the query....
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 |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
|