‎2009 Jul 15 12:40 PM
Hi All,
I wish to display a price in a smartforms with decimal or not values, depending on a condition on a field of an internal table.
At the moment I have this code in my smartforms.
DATA l_ret_price TYPE komv-kwert.
l_ret_price = gwa_komv-kwert.
WRITE gwa_komv-kwert TO gv_ret_price CURRENCY rte014-currency
LEFT-JUSTIFIED.
In my smartforms cell I have &gv_ret_price&.
I find that setting &gv_ret_price(.0)& I can avoid decimal values This is right for a first case but I need the possibility tu have or nor decimal values. Haw can I set this condition?
I can define a global variable and change the previous variable gv_ret_price but how can I set (.0) or not on a condition?
Any help will be well appreciated.
Thanks in advance.
Regards,
Giovanni
‎2009 Jul 15 12:55 PM
try this:
DATA l_ret_price TYPE komv-kwert.
data wwdecimals type i.
IF (your_condition)
wwdecimals = 2.
ELSE.
wwdecimals = 0.
ENDIF.
l_ret_price = gwa_komv-kwert.
WRITE gwa_komv-kwert TO gv_ret_price CURRENCY rte014-currency DECIMALS wwdecimals
LEFT-JUSTIFIED.
‎2009 Jul 15 12:45 PM
Hi
Use The condition In smartform for displaying the decimals or not
Thanks
kamath
‎2009 Jul 15 12:46 PM
hi ,
define your field in character format which you want to show in smartform
assign that value in charactr field and can check before assigning that if price value is zero then assign nulll to character field
or when not Zero then assign that value in same decimal format to character field .
Redards
Deepak .
‎2009 Jul 15 12:47 PM
DATA l_ret_price TYPE komv-kwert.
DATA: var TYPE i.
DATA: w_decflag TYPE i.
l_ret_price = gwa_komv-kwert.
WRITE gwa_komv-kwert TO gv_ret_price CURRENCY rte014-currency
LEFT-JUSTIFIED.
var = FRAC( gv_ret_price ).
IF var IS NOT INITIAL " Implies that there is a value at the decimal part
w_decflag = 1.
ELSE
w_decflag = 0.
ENDIF.
Try the above part of code and see if the same helps .. In the Cell you may check based on the w_decflag that you have set.
‎2009 Jul 15 12:55 PM
try this:
DATA l_ret_price TYPE komv-kwert.
data wwdecimals type i.
IF (your_condition)
wwdecimals = 2.
ELSE.
wwdecimals = 0.
ENDIF.
l_ret_price = gwa_komv-kwert.
WRITE gwa_komv-kwert TO gv_ret_price CURRENCY rte014-currency DECIMALS wwdecimals
LEFT-JUSTIFIED.