In Matching function, if the sizes of the compared key fields of primary and secondary files are different, how are the key fields of the files compared?

book

Article ID: 40897

calendar_today

Updated On:

Products

CA PanAudit Plus CA Easytrieve Report Generator CA PAN/SQL

Issue/Introduction

Question:

In Matching function, if the sizes of the compared key fields of primary and secondary files are different, how are the key fields of the files compared?

Answer:

According to the "Synchronized File Input" in the Easytrive Programming Guide, the following is described.
************************************************************************************
Corresponding keys of all files must be either alphanumeric or numeric. An alphanumeric key must be alphanumeric in all files, but can have different lengths. A numeric key must be numeric in all files, but can have different data types (N, P, U, B, F, I) and lengths.
************************************************************************************

The more detailed explanation is shown in the following.

In case that the corresponding key fields are numeric, just the effective numeric values within the key fields are compared.
So, the corresponding key fields can have different data types (N, P, U, B, F, I) and lengths.

In case that the corresponding key fields are alphanumeric, the corresponding key fields can have different lengths.  In this case, if the corresponding key fields have different lengths, among the corresponding key fields, longer one is used as the length of the key fields.  The shorter corresponding key field is padded with spaces.

The example is as follows.

FILE  FILEA
P-FLD1   4  3 A
FILE  FILEB
S-FLD1   4  5 A
*
JOB INPUT(FILEA KEY(P-FLD1) FILEB KEY(S-FLD1))
IF MATCHED
   DISPLAY '## MATCHED ##'
END-IF
...
...

In the above example, length of 5 bytes is used as the length of the matching key fields because the S-FLD1 is longer than the P-FLD1. So, on the right side of the P-FLD1 field, two bytes are added for the comparison and they are padded with spaces.

Note:
In the R6.4 or lower releases, as the length of the matching keys, the current length of the key field of a primary file was always used. So, the behavior on the length of the matching key fields were changed since R11.0. 
(So, there is difference in the behavior of the matching function between the Easytrive MF edition and Easytrieve Open edition(Windows, Unix and Linux).

 

Environment

Release: EDBMSU00200-11.5-Easytrieve-Report Generator-Option for DB2-MSU
Component: