cancel
Showing results for 
Search instead for 
Did you mean: 

Only two decimals while printing quantity fields

Former Member
0 Kudos

Hi all,

we have the qunatity field in script,the requirement is after comma they want

only 2 decimals how we can pass two decimals only

the field is &ITEM_QUANTITY&

Please help me.

regards

sriman

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

sorry...

&ITEM_QUANTITY(.2)&

..

create a varialble with 2 delcimals...

example avialable data element

then pass it to the ITEM_QUANTITY to that varialble..

print that varilble

Message was edited by:

Naresh Reddy

Former Member
0 Kudos

i encountered the same problem and

wrote a code like that in smart form before quan program field and problem was solved.

in code window general properties tab write input parameters "it_gen" which is structure name you will use wite yours. and in output parameters write "ztoplamgr" this is my field name, use yourself. Before all you sould add "ztoplamgr" what is your filed name to main input field parameters of form. then, use "ztoplamgr" instead of "GS_IT_GEN-GROSS_WT".that is my example. use yours field names in your code.

the code is :

clear ztoplamgr.

WRITE GS_IT_GEN-GROSS_WT DECIMALS 2 to ztoplamgr.

i hope this is answer for your problem.

Message was edited by:

ERHAN YAZICI

Former Member
0 Kudos

Hi sri,

&ITEM_QUANTITY(.2)&

YOU WILL GET 2 DECIMAL PLACES.

check this

<b> Number of Decimal Places </b>

A program symbol of one of the data types DEC, QUAN, and FLTP can contain decimal place data. Use the option below to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.

Syntax

&symbol(.N)&

Example

The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.

&EKPO-MENGE& -> 1,234.560

&EKPO-MENGE(.1) -> 1,234.6

&EKPO-MENGE&(.4) -> 1,234.5600

&EKPO-MENGE&(.0) -> 1,235

Former Member
0 Kudos

Hi,

I have tried with that (.2) but again its displaying after comma 3places.

Is there any option to eliminate that

my output is like this 123.45,890

i need to write 123.45,89 only.

Former Member
0 Kudos

is that ,2 something like that by the way wat value u r using here

Former Member
0 Kudos

I am using .2 now

but its printing 3 decimals after comma

Former Member
0 Kudos

my question was put ,2 and check the answer and wat quantity value u r printing here ,in wat form r u working ?

Former Member
0 Kudos

Hi,

I have tried with comma its giving the invaid symbol

Form related to ZINVOICE.

In main window i have these fields

&item_qunatity& and &item_unit price&

The output values are like this 5.700,000 and 4,150

so after comma we want only 2 decimals.

Former Member
0 Kudos

Hi ,

i never had this problem but can suggest that to explicitly initialize the quantity value as lv_menge = 0.00

hope u understand this

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I am not sure whether the below will work.But this is my idea.

Use search to find out the position of comma.Store the sy-fdpos in a variable called v1.

v2 = &item_quantity&.

SEARCH v2 FOR ','.

if sy-subrc eq 0.

v1 = sy-fdpos.

endif.

v1 = v1+2.

&item_quantity+0(v1)&

Check this link

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/search.htm

Message was edited by:

Jayanthi Jayaraman

Former Member
0 Kudos

As suggested, the way to print 2 decimal places is to do this:

&item_quantity(.2)&

Are you sure that you activated the form after making the above change?

You can also declare a variable of Type P Decimals 2 in the Global Definitions of your form and then move the quantity to this variable and print it.

Former Member
0 Kudos

<b>&ITEM_QUANTITY(.2)&</b>

Former Member
0 Kudos

Hi,

Try this:

&ITEM_QUANTITY(.2)&

Former Member
0 Kudos

&item_quantity(.2)&

Message was edited by:

Durgaprasad Kare