Skip to main content

DECIMAL-POINT IS COMMA clause versus NLS compiler directive

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

DECIMAL-POINT IS COMMA is a clause which is used in the IDENTIFICATION DIVISION of a COBOL program which changes the thousand separator (comma) and decimal point (point), which are the default settings, to thousand separator (point) and decimal point (comma).

Naturally, if using this clause, the program is compiled and ultimately run to use this format.  This is not always desirable and can be resolved at runtime when running the program.  

Resolution:

To change the format during execution the NLS compiler directive must be used.

At compile time the checker must know which symbol is used for the decimal point in the program source code itself; for example, in PIC clauses.

Then there is the value that is used at run time; for example,  the value which is ultimately displayed and written to data files.

Normally these are the same. However, if you compile the program with the checker directive NLS then the runtime value is determined by checking the following environment variables.  Note that the first one defined wins:

  LC_NUMERIC

  LC_ALL

  LANG

If you set LC_NUMERIC to en_US you will get USA and UK usage of "." for decimal point. If, on the other hand, you set it to something like "it_IT" you will get Italian usage, that is "," for decimal point.

Please note that if you compile with NLS you cannot use the DECIMAL-POINT IS COMMA clause. Instead, you have to use the default and it may be necessary to do some slight recoding but it should allow you to have a single application which will run with any Latin alphabet-based language.

Old KB# 1566

0 replies

Be the first to reply!