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

Conversion Problem...

Former Member
0 Likes
932

Hi All

i had a quantity feild gamng and it contains three decimals

like this 1000.000

now i want to remove the decimal part of that value and it should be stored as 1000.

can any body hlp me how to do that..

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

Hi,

try with below code,

data:

l_value type i,

l_val1 type p decimals 3 value '1000.000'.

l_value = abs( l_val1 ).

write:/ l_value.

Reward if useful.

Regards,

Sreeram.

9 REPLIES 9
Read only

former_member404244
Active Contributor
0 Likes
911

Hi,

Decalre the quantity field as character field.

Regards,

Nagaraj

Read only

Former Member
0 Likes
911

Hi,

Do like this

Data: Var type i.

Move GAMNG value to Var, Now Var will have only 1000.

Regards.

Satish

Read only

Vijay
Active Contributor
0 Likes
911

hi

just create a variable of type i and assign ur variable to that integer type variable.

regards

vijay

reward points if helpfull

Read only

Former Member
0 Likes
912

Hi,

try with below code,

data:

l_value type i,

l_val1 type p decimals 3 value '1000.000'.

l_value = abs( l_val1 ).

write:/ l_value.

Reward if useful.

Regards,

Sreeram.

Read only

0 Likes
911

i tried abs( i_val1) but that is not working. i think we dont have any such keyword in ABAP

Read only

0 Likes
911

Oh Yes ABS is working..

thanks a lot

Read only

Former Member
0 Likes
911

Hi,

Try the below logic.

1.Assign qty value to numeric.

2.Numeric to char.

3.delete the leading zeros.

DATA: l_f_qty type gamng,

l_f_char type char10,

l_f_num(10) type n.

l_f_qty = '1000.000'.

l_f_num = l_f_qty.

l_f_char = l_f_num.

shift l_f_char left deleting leading '0'.

write: / l_f_char.

Or

l_f_qty = '1000.500'.

l_f_char = TRUNC (l_f_qty)

write: / l_f_char.

Hope this helps u.

Edited by: Ramesh Hirial on Dec 20, 2007 5:00 PM

Read only

Former Member
0 Likes
911

HI

First get the Value into character field .

Then Use Split Command ..

l_charfield = 1000.00

SPLIT l_charfield AT '.' INTO l_field1 L_field2 .

L_field1 will contain 1000 .Use l_field1 as per your reqmt .

Hope this Helps.

Praveen

Read only

Former Member
0 Likes
911

Hi,

If you are using ABS(), it will not truncate the decimal values, it will round the value.

Ex: ABS ( 1000.500) : Result : 1001

TRUNC( 1000.500) : Result : 1000

Decide based on ur requirement.