GET_CORRESPONDING
GETCORR

Summary

GET_CORRESPONDING compares two files (which must both be sorted) and outputs records which are either present on both files or present on one file only. The file referred to as the driver file is assumed to be a subset of the file referred to as the major file, though this need not be the case. The key being compared need not be in the same position on both files.

GET_CORRESPONDING(
@literal@DRIVERFILE,
@literal@MAJORFILE,
@literal@OUTFILE,
@int@DKEYSTART,
@int@KLENGTH,
@int@MKEYSTART:= 0,
@literal@ERRORFILE:= "",
@literal@MATCHING:= "Y",
@response@RESPONSE:= RESULT)

Parameter details

KeywordMeaningDefault
DRIVERFILE The name of the file containing the subset of records to be matched (where this is appropriate), otherwise one of the files to be matched

= file_name

None. The parameter is mandatory
MAJORFILE The name of the file containing the full set of records to be matched (where this is appropriate), otherwise one of the files to be matched. Note that this is the file containing the records to be written to OUTFILE (see below).

= file_name

None. The parameter is mandatory
OUTFILE The name of the file to contain matched or unmatched records (see the MATCHING parameter below).

= file_name

None. The parameter is mandatory
DKEYSTART The start position of the key in the driver file

= int_value (1 = first character)

None. The parameter is mandatory
KLENGTH The length of the key to be compared

= int_value

None. The parameter is mandatory
MKEYSTART The start position of the key in the major file

= 0

The key starts in the same position as in the driver file

= int_value

The key starts at the specified position

The key is assumed to start in the same position as in the driver file
ERRORFILE The name of an optional file to contain records which appear in the driver file but not in the major file

= file_name

The presence of unmatched driver records is signalled by a warning
MATCHING Specifies whether matching or non-matching records are to be output to OUTFILE

= Y

Matching records are to be output

= N

Non-matching records are to be output

Y

Matching records are to be output

RESPONSE Response code variable RESULT

Examples

If file A contains

AAAA  Aardvark
BBBB  Becqueral
CCCC  Constantinople
DDDD  Disingenuous

and file B contains

AAAA
CCCC

then using A as the major file, B as the driver file, a key position of 1, and 4 as the key length, the contents of the output file if MATCHING = "Y" would be:

AAAA  Aardvark
CCCC  Constantinople

and if MATCHING = "N" would be:

BBBB  Becqueral
DDDD  Disingenuous

Note that the record output is that in the major file.

If file C contains

AAAA
CCCC
EEEE

then using A as the major file, C as the driver file, a key position of 1, and 4 as the key length, the contents of the output file if MATCHING = "Y" would be

AAAA  Aardvark
CCCC  Constantinople

but also, if ERRORFILE was specified, the contents of ERRORFILE would be

EEEE

and if it was not specified, the message

SOME UNMATCHED DRIVER RECORDS WERE FOUND BUT NOT REPORTED

would be output.