The WRITE
operator allows you to specify a currency. Example:
DATA price TYPE p DECIMALS 2. price = '3000000'. WRITE: / price CURRENCY 'USD'.
Please note that this does not interpret the number itself, but simply adds commas and periods to certain positions depending on the currency you specify. Therefore, if you have an integer with a value of 3000000
, and you write it using the USD
currency, the result will be 30.000,00
.
I suggest you read the F1 help information in the WRITE
instruction, as there are many more options besides this.
-
Leading zeros are removed using the conversion procedure. CONVERSION_EXIT_ALPHA_INPUT
will add leading zeros, and CONVERSION_EXIT_ALPHA_OUTPUT
will remove them. You can add these routines to the domain in the dictionary, so the conversion will be performed automatically. For example, type MATNR
:
DATA matnr TYPE matnr. matnr = '0000129'. WRITE: / matnr.
This will lead to conclusion 129
, because in the MATNR
domain the specified conversion procedure.
In the case of a type that does not have this, for example:
DATA value(7) TYPE n. value = '0000129'. WRITE: / value.
The output will be 0000129
. You can call the CONVERSION_EXIT_ALPHA_OUTPUT
procedure to achieve a result without leading zeros:
DATA value(7) TYPE n. value = '0000129'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = value IMPORTING output = value. WRITE: / value.
RenΓ© source share