Application Development 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: 

How to display or write quantity with decimals?

alonso_valenzue
Participant
0 Kudos

Exists some mask or function that make next?:

1.- If a quantity is 1500.000 should display 1,500

2.- If a quantity is 1500.010 should display 1,500.01

3.- If a quantity is 1500.555 should display 1,500.555

In others words, only display decimals if apply.

7 REPLIES 7

Former Member
0 Kudos

Are you displaying through ALV ?

0 Kudos

Hi Kinjal, I'm using a list ( command WRITE )

0 Kudos

i think below code will helpful to u :

data: var(10) type c,

var2 type string,

var3 type string,

var1 type string.

var = '15000.000'.

var1 = var.

split var1 at '.' into var2 var3.

if var3 ge '000'.

condense var3.

SHIFT var3 RIGHT DELETING TRAILING '0'.

condense var3.

endif.

if not var3 is initial.

concatenate var2 '.' var3 into var.

write: / var.

else.

write: / var2.

endif.

Former Member
0 Kudos

1.- If a quantity is 1500.000 should display 1,500

2.- If a quantity is 1500.010 should display 1,500.01

3.- If a quantity is 1500.555 should display 1,500.555

If list use:

WRITE filed_name TO Destination_fieldname UNIT Unit_value deleting trailing zeros.

If ALV:

Try to add no_zero = 'X'. in the field catalogue of the field.

Please update this call how you hanldled this situation.

All the best for ur efforts.

Baburaj

Former Member
0 Kudos

dATA money like bseg-DMBTR.

money = 234234523.

write money CURRENCY 'CLP'.

use the mask CURRENCY 'CLP' ....'USD', etc

Former Member
0 Kudos

Hello,

Using the function module 'Spell_amount' you can find out the value before the decimal point and the value after the decimal point in separate variables.

Now if the variable for the value after decimal point has only 00, then do not display that.

If it is not equal to 00, then concatenate the 2 variables and display. This should solve the purpoe.

cheers,

Sushil Joshi

0 Kudos

Hi Sushil,

I'm using a quantity and could have 3 decimals.

The FM SPELL_AMOUNT only take 2 decimals. For example, for 1500.555 the result is:

NUMBER = 000000000015005

DECIMAL = 550

How can I obtain NUMBER = 000000000001500 and DECIMAL = 555? I'm using CURRENCY = USD. What currency should I use?