If you needed to keep track to see if any field changed in group, knowing the data is passed thru several subroutines, what would be the most efficient code? You could save a copy of the group item in working storage and just do a If =, but is there a better way? Keeping a flag seems error prone when considering future maintenance.
02 X1 PIC XX.
02 X2 PIC S9(5) COMP-3.
02 X3 PIC S9(5) COMP-3.
02 SAVE-X PIC X(8).
MOVE X TO SAVE-X
CALL PROG01 USING X.
CALL PROG02 USING X.
IF X = SAVE-X
DISPLAY 'NO CHANGE'
If X were really 1000 bytes, how efficient is this code?
all ideas welcome, thanks!
BillWoodger 270005Q076285 Posts
Re: Comparing Data2013-03-22T20:21:00ZThis is the accepted answer. This is the accepted answer.What are you actually trying to identify by the code, what is your reason for wanting to know in your program that the data is the same before/after?
Note, this does not mean that neither of the sub-programs has done "anything", as they could have set any of those three values to the same value that it already had. If you want to know about those as well, you will need a "flag" for each sub-routine set by each sub-routine.
Your proposed IF will identify any change in any bit in the data-structure.
Do you have an unusually large amount of data?
There is a way to "mangle" this, if your data does not always "conform to PICture", then things which are "numerically equivalent" might end up with different "signs" so cause the IF to fail. I guess you'll find out if that is the case with your data.