Using currency signs
Many programs need to process financial information and present that information using the appropriate currency signs. With COBOL currency support (and the appropriate code page for your printer or display unit), you can use several currency signs in a program.
About this task
You can use one or more of the following signs:
- Symbols such as the dollar sign ($)
- Currency signs of more than one character (such as USD or EUR)
- Euro sign, established by the Economic and Monetary Union (EMU)
To specify
the symbols for displaying financial information, use the CURRENCY
SIGN
clause (in the SPECIAL-NAMES
paragraph
in the CONFIGURATION SECTION
) with the PICTURE
characters
that relate to those symbols. In the following example, the PICTURE
character $
indicates
that the currency sign $US
is to be used:
Currency Sign is "$US" with Picture Symbol "$".
. . .
77 Invoice-Amount Pic $$,$$9.99.
. . .
Display "Invoice amount is " Invoice-Amount.
In this example, if Invoice-Amount
contained
1500.00, the display output would be:
Invoice amount is $US1,500.00
By
using more than one CURRENCY SIGN
clause in your
program, you can allow for multiple currency signs to be displayed.
You can
use a hexadecimal literal to indicate the currency sign value. Using
a hexadecimal literal could be useful if the data-entry method for
the source program does not allow the entry of the intended characters
easily. The following example shows the hexadecimal value X'80'
used as the currency sign:
Currency Sign X'80' with Picture Symbol 'U'.
. . .
01 Deposit-Amount Pic UUUUU9.99.
If there
is no corresponding character for the euro sign on your keyboard,
you need to specify it as a hexadecimal value in the CURRENCY
SIGN
clause.
The hexadecimal value
for the euro sign
is X'80'
with code page 1252 (Latin 1).