Format 2 of the @COMPARE statement can be used to compare the contents of two work files line by line. EDT stores the results in a work file. This is deleted before the result is stored in it. It is also possible to send the results to SYSLST
and, in L mode, SYSOUT
.
Operation | Operands | F mode / L mode |
@COMPARE | { [procnr1] WITH procnr2 | procnr1 }
|
procnr1 | Number of the work file that is to be compared. If |
procnr2 | Number of the work file against which the comparison is to be performed. If |
LIST | If If |
procnr3 | Work file in which the detailed result of the comparison is stored if any such The work file is deleted before being used. If a file is open in this work file |
procnr4 | The specification of a work file as an auxiliary file is now only permitted for |
The work files procnr1
and procnr2
must be different from one another. Otherwise, the @COMPARE statement is rejected with the message EDT5499
. The work file procnr3
can be identical to procnr1
or procnr2
. However, in this case no detailed result is output (see below).
If all the lines to be compared are either identical or different then only the message EDT0291
or EDT0290
respectively is output. In this case, no detailed result of the comparison is output.
If a detailed result is to be sent to procnr3
then the message EDT0297
is output once the comparison has been completed. In this case, if one of the two files for comparison is the work file which is to contain the result then the message EDT5350
is output and no detailed result is output.
If one of the files for comparison is work file 0 then no ISAM file may be opened for real processing with @OPEN, format 2. Otherwise, the @COMPARE statement is rejected with the message EDT4935
.
To make it possible to query the result of the comparison in EDT procedures, the EDT error switch is set in addition to the output of the messages EDT0290
and EDT0297
. This can be queried using the @IF statement (see @IF statement):
EDT error switch | Work file | |
EDT0291 | Not | Empty |
EDT0290 | Set | Empty |
EDT0297 | Set | Not |
If it is necessary to distinguish between all the cases listed above then it is necessary to reset the EDT error switch with @RESET and delete the work file procnr3
before performing a comparison with @COMPARE.
Before performing the comparison, EDT internally converts each line into UTF16
and compares the resulting lines as byte sequences. The lines are identical if both the line content and line length of these byte sequences are identical. The line numbers are ignored during the comparison of the files. If both work files use the same character set then this procedure is equivalent to a byte-by-byte comparison of the original lines.
It may be necessary to convert the output of the result of this comparison into a suitable character set. If the output is sent to SYSOUT
or SYSLST
then this is the character set that has been defined for SYSOUT
or SYSLST
. If the output is sent to a work file then this is the character set of the compared work files. If these use different character sets then the output takes place in the character set UTFE
.
If the statement is interrupted with [K2] and the EDT session is continued with /INFORM-PROGRAM
then the processing of the statement is aborted and message EDT5501
is output.
The format of the output is identical irrespective of whether it is written to a work file or sent to SYSLST
or SYSOUT
:
LINE#( 1) FILENAME: DAT.270104
LINE#( 0) FILENAME: COMP.1
A header line is output which identifies the columns assigned to the compared work files together with LINE#
... and the number of the relevant work file (in parentheses). In addition, if present, the name of an opened file or library element or a local @FILE entry is output.
0007.10 CUST-100 SORT 0007.20 CUST-200 PERCON 0007.30 CUST-700 FDDRL 0010.00 $CUST-900 LMS 0010.00 $CUST-900 LMSCONV
In the case of lines which occur in only one work file, the line numbers and the content of the records (possibly truncated by 17 characters) are output. Here, the location of the line in either column 1 or in column 2 under the heading LINE#
... indicates which of the work files contains the record. This also applies equivalently for records with different contents. These occur with one content only in the first work file and with the other content only in the second work file and will generally appear consecutively.
0008.00=0010.00
0018.00=0020.00
In the case of lines with the same content, the identified line numbers are output in the form 0001.00=0006.00
. If a number of consecutive records are identical (range of identical records) then only the first and last pairs of line numbers in the range are output (for further details, see the example).
Example
Processing switches from work file 2 to work file 1.
Work file 2 is compared with work file 1 and the result is stored in work file 3. Processing then switches to work file 3.
The result of comparing work files 1 and 2 is stored in work file 3.