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

TYPE Conversion

Former Member
0 Likes
1,875

HI,

I am facing one problem while conversion.

At run time I am getting one field name is vbdkr-ntgew and the value of this field is 1143.541

I want to convert the above value into rounded value with out decimals in all user settings format.

I mean if it is 1143.541 then it should be 1144

If it is 1143.078 then it should be 1143.

For the above case I am using the logic

gv_a = CEIL( vbdpr-ntgew ).

In above the gv_a variable is of type I ( I have used type n and c also).

But this is not working I mean after the above statement the gv_a is showing 1143541 instead of 1144.

And one more thing this is almost similar to above

I have a variable vbdpr-fkimg and the value of this field is 1.000

Now I need to convert next rounded value with one decimal.

I mean to 1.0

For this I am using following logic.

Gv_b = ceil ( vbdpr-fkimg).

In above gv_b is of type p decimal 1.

Now after execution of above statement the gv_b is populating with 100.0 but I am expecting 1.0

Suppose the value is 1143.789 then I want 1144.0

Please tell me the logic with out using SPLIT command

If helpful I will give the points.

Thanks a lot in advance.

12 REPLIES 12
Read only

Former Member
0 Likes
1,575

Use this:

data: tt type f value '1143.541'.

data: gv_a(16) type n.

gv_a = tt.

write: / gv_a.

Read only

0 Likes
1,575

or to match the CURR data type:

data: tt type vbdkr-netwr value '1143.541'.

data: gv_a(16) type n.

gv_a = tt.

write: / gv_a.

Read only

0 Likes
1,575

Hi,

I tried this but it is not working. I mean if the value is 1143.790 it is coming 1143790.

Thanks.

Read only

0 Likes
1,575

Hey use ABS instead of ceil.... I am not sure but try out. hope it will work.

Read only

0 Likes
1,575

Not possible...

Please provide the code that returned 1143.xxx instead of 1144 into the type N field.

Read only

0 Likes
1,575

Hi,

DATA: gv_ntgew(16) TYPE n .

gv_ntgew = vbdpr-ntgew .

the vbdpr-ntgew contains value 1143.501

after execution of above line gv_ntgew contains 1143501

but i want 1144

Thanks for your help.

Read only

0 Likes
1,575

Hmmm...

This code:

DATA: gv_ntgew(16) TYPE n .

data: ll type vbdpr-ntgew value '1143.88'.

gv_ntgew = ll .

write: / gv_ntgew.

prints out 1144 in my ECC 6.0 system.

What version / system are you running in?

And what if you just paste my code into a new program with JUST THESE lines and a REPORT header statement - and execute?

Read only

0 Likes
1,575

DATA: gv_ntgew TYPE i .

gv_ntgew = ABS( vbdpr-ntgew ) .

t_ans = ABS( t_exam ).

write : t_ans.

Check with this..... Hope this is what you want....If possible get the value with type Int.

Read only

Former Member
0 Likes
1,575

Hi

If you need to have an integer value, use an integer variable:

DATA: NETGEW_I TYPE I.

MOVE VBDPR-NETGEW TO NETGEW_I.

You can use a p variable with 1 decimal if you need to convert a number with 3 decimal to one with only one decimal:

DATA: FKIMG_1 TYPE P DECIMALS 1.

MOVE VBDRP-FKIMG TO FKIMG_1.

The values'll be rounded automatically.

Edited by: max bianchi on Jan 10, 2008 3:08 PM

Read only

andreas_mann3
Active Contributor
0 Likes
1,575

try:

PARAMETERS: p3 TYPE p DECIMALS 3 DEFAULT '1143.541'.

DATA p0 TYPE p DECIMALS 0.

MOVE p3 TO p0.

WRITE: / p3, p0.

A.

Read only

Former Member
0 Likes
1,575

Hi

If you need to have an integer value, use an integer variable:

DATA: NETGEW_I TYPE I.

MOVE VBDPR-NETGEW TO NETGEW_I

The value'll be rounded automatically.

Read only

Former Member
0 Likes
1,575

Hi Ramesh,

You can use the function module MURC_ROUND_FLOAT_TO_PACKED to round off the values.

Or else you can try the following code:

DATA: num1 TYPE f value '19.468323', num2 TYPE p decimals 2.

num1 = '19.468323 '.

num2 = num1.

WRITE num2.

Reward if usefull.

Thanks,

Kashyap Ivaturi