ABAP Keyword Documentation → ABAP - Reference → Predefined types, data objects, and functions → Predefined Data Types → Predefined Types in ABAP Dictionary → Use of Predefined Data Types from ABAP Dictionary
A currency field is a component of a structure defined in ABAP Dictionary or of a database table of type CURR, for the inclusion of an amount in a specific currency. The amount is specified as a whole number in the smallest unit of the currency. A currency field must be linked to the currency key of a structure or of a database table, which determines the currency and the number of decimal places. A currency key is a component of a structure or of a database table which has been defined in ABAP Dictionary, has the type CUKY, and can contain a currency code from the TCURC database table.
By default, the number of decimal places for a currency is always two. Currencies with a different number of decimal places must also be entered in the TCURX table, where the number of decimal places can be defined explicitly.
7.40 | 7.54
Handling in ABAP Dictionary
A data element of data type CURR is treated as a field of data type DEC and is stored in database tables in the BCD format. When creating a data element or a structure component of the data type CURR in the ABAP Dictionary tool, a number of decimal places other than zero must be defined. The standard value is two decimal places.
For every structure component of data type CURR, a component of the same structure or of a different structure or database table must be specified in the individual maintenance of the component as a reference field, which has the data type CUKY. This field is the currency key which determines the actual currency.
The number of decimal places for the currency defined by the currency key of type CUKY only determines the formatting and checking of a currency field on a screen. In principal, it is independent of the number given for the currency field of type CURR. The default value of two decimal places for currency fields in ABAP Dictionary is chosen because most of the currencies in the TCURC database table have two decimal places and are not listed in the TCURX database table. We recommend not using any other value, since then any unforeseen operations with currency keys in ABAP programs have little effect.
Handling in Screens
For the display of an input/output field of type CURR on a screen, the content is displayed as character-like and in accordance with a type dependent template, as for all screen fields. The positioning of the decimal point for a currency field of type CURR on a screen is thereby completely independent of the number of decimal places specified by the data element in ABAP Dictionary (greater than or equal to one, the default value is two). The number of decimal places on a screen is determined as follows:
- When displaying a screen field of type CURR, the reference field for the currency key is searched for in the global data of the current ABAP program. The content of this field must be a valid
currency code from the
TCURC database table. If the reference field is not found or there is no entry in the TCURX database
with the content of the field, the currency field is displayed by default with two decimal places.
The reference field is either defined in the relevant structure in ABAP Dictionary or was determined using the Screen Painter for the attributes of the screen field. It does not have to be present on the screen itself.
- If the currency code for the reference field is found in the TCURX database table, the currency field is displayed with the decimal places specified there. This also applies to initial reference fields.
A screen therefore only uses the string of digits of a currency field from the ABAP program (or a
in between) or just sends this. Information about currency keys and decimal places is not passed automatically.
You must ensure that the reference field for PBO is filled by the desired value. For PAI, the correct
currency key plays a part in the automatic format check. Especially on screens in which currency fields
are displayed in differing currencies, you must ensure that the reference field is transported before
the currency by using the statements
Handling in ABAP Programs
The ABAP type which corresponds to the CURR data type is
p. An ABAP data
object, which is declared with reference to a dictionary type of type CURR, has the number of decimal
places defined there (greater than or equal to one, the default value is two). These decimal places
are respected for all operations and calculations, as for all packed numbers. The only exceptions are
the programs for which the program property fixed point arithmetic has not been set.
In order to work correctly with a currency field, all figures of the number must be recorded as currency
amounts in the smallest possible currency units, independent of the number of decimal places. This occurs
automatically sometimes, for example, if you use
or the formatting option
CURRENCY in an
embedded expression of a
character string template. For other operations, the following restrictions apply:
- Comparison, addition, subtraction, and division of two currency fields with the same number of decimal places are not critical.
- Multiplications with and division by a currency-independent number are not critical.
- All other operations are critical, for example:
- Multiplication of two currency fields.
- Operations between two fields with different currencies that include assignments.
- Assignments of currency-independent numbers to currency fields.
Do not expect accurate results when performing critical operations if the number of decimal places in the program does not match the number in the currency.
For currencies, one of the data types for decimal
floating point numbers is recommended rather than the data type CURR. The correct currency formatting is supported on screens by output styles and in ABAP programs by
appropriate formatting for the
EXTENDED_MONETARY options. This always records amounts in the main unit of the currency, unlike the data type CURR (or DEC, or the ABAP type