Former Member

### Not required to print decimal places

Hi,

In the sapscript for printing production order, we are printing the order quantity field MGVRG

present in the structure AFVGD. &AFVGD-MGVRG&

But we dont want the decimal places to be printed.

Suppose if the quantity is 10,000 it should be printed as 10.

I tried using &AFVGD-MGVRG(.0)& , but no result.

Please let me know how we can achieve this.

Poornima

10|10000 characters needed characters exceeded

• Former Member
Jan 21, 2009 at 11:14 AM

data lv_qty type vbap-zmeng.

data char_qty(10).

lv_qty = '10.000'.

Move lv_qty TO char_qty.

Replace '.000' IN char_qty WITH ''.

CONDENSE char_qty.

write / char_qty. " output 10

lv_qty = '10.100'.

Move lv_qty TO char_qty.

Replace '.000' IN char_qty WITH ''.

CONDENSE char_qty.

write / char_qty. " output 10.100

10|10000 characters needed characters exceeded
• Former Member
Jan 21, 2009 at 12:13 PM

Hi Poornima,

Get the value of your field i.e AFVGD-MGVRG into a variable of type p deciamal 2 as shown in the code below.

DATA a TYPE I.

DATA b TYPE P DECIMALS 2 VALUE '10.15'.

a = TRUNC( b ).

WRITE: / 'TRUNC:', a.

Let me know if this is useful

Nayan

10|10000 characters needed characters exceeded
• Jan 21, 2009 at 01:17 PM

Hello,

Suppose if the quantity is 10,000 it should be printed as 10.

I tried using &AFVGD-MGVRG(.0)& , but no result.

I see that the decimal separator is comma(,).

Plz change &AFVGD-MGVRG(.0)& to

`&AFVGD-MGVRG(,0)&`

BR,

Suhas

10|10000 characters needed characters exceeded
• Suhas Saha Former Member

Hello Poornima,

I think you have to use TRUNC keyword to get the decimal value & print that in the SAPscript.

Plz search in SDN you have lots of posts on this.

[Sapscript removing 0 values |Sapscript removing 0 values;

BR,

Suhas

Edited by: Suhas Saha on Jan 28, 2009 6:33 PM

• Former Member
Jan 30, 2009 at 05:53 AM

Hi poornima,

Do one thing.

Declare one field as

Data z_mgvrg TYPE i. in your driver program.

Now z_mgvrg = AFVGD-MGVRG.

No print &z_mgvrg& in your script.

regrds,

Lokesh

10|10000 characters needed characters exceeded
• Former Member
Jan 30, 2009 at 06:56 AM

DATA: val TYPE P DECIMALS 2 VALUE 1000.00 ,

Amt type i.

Amt = TRUNC( val ).

WRITE: / Amt.

Regards,

Joan