InFormWe want to format a number line on the interface, for example:123456.03Then, we canItemAttributes
In this way
Original number |
Format mask |
Result |
Description |
123456.03 |
Fm999,990 |
Fm999,990.00 |
|
0.123 |
Fm999, 999.00. |
. 12 |
Before decimal point9 |
0.123 |
Fm999, 990.00. |
0.12 |
Before decimal point0 |
123456789.03 |
Fm999, 990.00. |
###### |
BecauseFormat maskNot enough |
123456789.03 |
Fm999, 999,990.00. |
123,456,789.03 |
|
InTo_charMediumTo_char (A, B)
A |
B |
Result |
Description |
0.123 |
Fm999, 999.00. |
. 123 |
Before decimal point9 |
0.123 |
Fm999, 990.00. |
0.123 |
Before decimal point0 |
The preceding method should not be used for the format input of the amount, because the format masks of different types of currencies are different. For example, if the currency is'CNY'The amount is retained with two decimal places and the currency is'BHD'Is displayed in three decimal places. There are two ways to achieve this:
<! -- [If! Supportlists] -->(1) <! -- [Endif] -->UseCodeDynamic Control format mask based on currency
Set the block to be formattedTest,ItemIsAmount, In the blockTestOfPost-QueryAdd the following code:
App_item_property.set_property ('test. amount ', --To be formattedItem
Format_mask,
Fnd_currency.get_format_mask (
/*Format the currency to use. If you want to use the standard currency, you can obtain it in this way.
Select currency_code
Into l_currency_code
From gl_sets_of_books
Where set_of_books_id = fnd_profile ('Gl _ set_of_books_id ');
*/
'Usd ',
Get_item_property ('test. Amount ', --ReturnItemLength
Max_length )));
This method is simple, but if a block is displayed as multiple rows of data and the currency of each row is different, it does not work.
<! -- [If! Supportlists] -->(2) <! -- [Endif] -->FunctionsApp_currency.line_dyn_currencyThis method can format multiple rows of different currencies.
The specific method is as follows:
Set the block to be formattedTest,ItemIsAmount, The currency of each row isItem currency_codeCreate a non-database Description field in the data block.Desc,AmountNot displayed, displayedDesc, In the blockTestOfPost-QueryAdd the following code:
: Test. Desc: = test. DESC;
App_currency.line_dyn_currency (: Test. currency_code, 'Test. Amount ', 'Test. desc ', 'Post-query ');
InItem:DescOfWhen-validate-itemAdd the following code:
App_currency.line_dyn_currency (: Test. currency_code, 'Test. Amount ',
'Test. desc ', 'When-validate-item ');
It is used whenDescAnd then reset the settings.
of course, this method also has its limitations. After querying on a block, the user does not perform any operations, the status of the current block changes to ' changed ' display amount , the function app_currency.line_dyn_currency pair amount Returns a value. Solve the above problems, test post-query Add app_record.set_status ('query ') : Change the block status back.