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

Remove trailing zeroes in quantity field.

Former Member
0 Likes
6,451

Hi all,

I am having quantity field in ALV grid display : VBAP-KWMENG. Iam getting quantity value as 1,000.My requirement is to get quantity value as 1.(without ',' and zeroes).

Suggest me a suitable solution.

Thanks all.

Hi all,

I am having quantity field in ALV grid display : VBAP-KWMENG. Iam getting quantity value as 1,000.My requirement is to get quantity value as 1.(without ',' and zeroes).

Suggest me a suitable solution.

Thanks all.

9 REPLIES 9
Read only

Former Member
0 Likes
2,218

DECLARE A VARIABLE OF TYPE C.

and pass your quantity value to that variable and use this variable

Read only

Former Member
0 Likes
2,218

Hi Soumya,

the best way to tackale this is .. pass the value to type P variable with decimals 0 ... i.e,.


data: v_quant like VBAP-KWMENG,
        v_newquant type P decimals 0.

 v_newqunat = v_quant.
 

Read only

0 Likes
2,218

Hi santosh,

Im getting quantity as 1,000 .I want to get it as 1.

Thanks.

Read only

0 Likes
2,218

Hi,

Problem solved.

Thanks.

Read only

Former Member
0 Likes
2,218

Hi,

You better check ur select query first. If that is write, check if ur filling your field cat with the correct values.

Thanks

Nayan

Read only

Former Member
0 Likes
2,218

Other way is check for the below code ..


DATA:
  lv_decimal TYPE f DECIMALS 3,
  lv_string  TYPE string.
 
lv_decimal = '22.010'.
 
WRITE lv_decimal TO lv_string.
SHIFT lv_string RIGHT DELETING TRAILING '0'.
 
* also delete trailing '.', if possible
SHIFT lv_string RIGHT DELETING TRAILING'.'.
CONDENSE lv_string NO-GAPS.
 
* now no trailing zeros are in the decimal stored in LV_STRING 

Read only

Former Member
0 Likes
2,218

Hi,

The reason for having quanting value with leading zeros is because of the property of data type. You need to change the data type of the particular field in your internal table.You have to make it into character format.

regards

Sourabh Verma

Read only

Former Member
0 Likes
2,218

First you need to pass the quantity field to another field of character type.

After that you can do Shift operations.

Regarads,

Debi

Read only

Former Member
0 Likes
2,218

Hi, Try this below code

data : w_menge TYPE MENGE_D
     , w_temp_menge TYPE i.

w_menge = '1'.

move w_menge to w_temp_menge.

Thanks

Senthil