Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dinamically set variable without decimal values in smartforms

Former Member
0 Likes
636

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

1 ACCEPTED SOLUTION
Read only

former_member194797
Active Contributor
0 Likes
605

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.

4 REPLIES 4
Read only

Former Member
0 Likes
605

Hi

Use The condition In smartform for displaying the decimals or not

Thanks

kamath

Read only

deepak_dhamat
Active Contributor
0 Likes
605

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 .

Read only

Former Member
0 Likes
605


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.

Read only

former_member194797
Active Contributor
0 Likes
606

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.