Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


National comparisons

A national comparison is a comparison of the national character value of two operands of class national.

When the relation condition specifies an operand that is not class national, that operand is converted to a data item of category national before the comparison. The following list describes the conversion of operands to category national.

DBCS
A DBCS operand is treated as though it were moved to a temporary data item of category national of the same length as the DBCS operand. DBCS characters are converted to the corresponding national characters. The source code page used for the conversion depends on whether the DBCS operand is an EBCDIC or ASCII data item. If the DBCS operand is an EBCDIC data item (that is, the compiler option CHAR(EBCDIC) is in effect and the NATIVE phrase is not specified for the operand), the EBCDIC code page in effect for the operand is used; otherwise, the code page indicated by the locale in effect for the operand is used. For details, see Appendix G. Locale considerations.
Alphabetic, alphanumeric, alphanumeric-edited, and numeric-edited with usage DISPLAY
The operand is treated as though it were moved to a temporary data item of category national of the length needed to represent the number of character positions in that operand. Alphanumeric characters are converted to the corresponding national characters. The source code page used for the conversion depends on whether the alphanumeric operand is an EBCDIC or ASCII data item. If the alphanumeric operand is an EBCDIC data item (that is, the compiler option CHAR(EBCDIC) is in effect and the NATIVE phrase is not specified for the operand), the EBCDIC code page in effect for the operand is used; otherwise, the code page indicated by the locale in effect for the operand is used. For details, see Appendix G. Locale considerations.
Numeric integer
A numeric integer operand is treated as though it were moved to a temporary data item of category alphanumeric of a length the same as the number of digits in the integer. The unsigned value is used. The resulting temporary data item is then converted as an alphanumeric operand.
External floating-point
A display floating-point item is treated as though it were a data item of category alphanumeric, rather than as a numeric value, and then converted as an alphanumeric operand.

A national floating-point item is treated as though it were a data item of category national, rather than as a numeric value.

The implicit moves for the conversions are carried out in accordance with the rules of the MOVE statement.

The resulting category national data item is used in the comparison of two national operands.

Comparison of two national operands

The method used for comparison is determined by the setting of the NCOLLSEQ compiler option.

If the NCOLLSEQ(BINARY) compiler option is in effect, the collating sequence is determined by the binary values of national characters. The comparison proceeds as follows:

If the NCOLLSEQ(LOCALE) compiler option is in effect, the collating sequence is determined by the runtime locale. For purposes of comparison, trailing spaces are truncated from the operands except that an operand consisting of all spaces is truncated to a single space. Locale-based comparison is not necessarily a character-by-character comparison. If the shorter operand were extended with spaces as for a nonlocale-based comparison, the result might not be the culturally-expected result. For information about locales, see Appendix G. Locale considerations.

The PROGRAM COLLATING SEQUENCE clause has no effect on comparisons of national operands.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)