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

Decimal issue please help

Former Member
0 Likes
869

Gurus,

Please help with decimal issue.

My sending field type is packed decimal and has a value of 11.88 and I defined receiving field as Numeric text with size 10. I am expecting 0000001188 in my receiver field after the move. But I am getting 0000000012 in my receiver field.

My requirement is to have 0000001188 in my receiver field. Can you please guide me how to do this?

Thanks for your time!

Best regards,

Pavan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
843

Hi Pavan,

p -> string -> n

this should work.

Regards,

DK

7 REPLIES 7
Read only

Former Member
0 Likes
844

Hi Pavan,

p -> string -> n

this should work.

Regards,

DK

Read only

0 Likes
843

Hi DK,

Thanks for your reply,

I didn't got your answer. Can you please explain in detail?

Thanks again for your time!

Best regards,

Pavan

Read only

0 Likes
843

pavan,

what chee means to say is, convert that packed field to string first and then pass it to your final field

Read only

0 Likes
843

Hi,

The earlier post has correct direction. Here is the sample implementation

 

data lv_num TYPE p DECIMALS 2 VALUE '11.88'.
data : lv_char TYPE c LENGTH 10.
data : lv_string TYPE string.
data : lv_neum TYPE n LENGTH 10.
lv_char  = lv_num. " Value is 11.88
lv_string = lv_num. "  Value is 11.88
lv_neum = lv_num. "  Value is 12
lv_neum = lv_string. "  Value is 11.88
lv_neum = lv_char. "  Value is 11.88
WRITE lv_string.

So, based on the implicit type casting you can use the following logic.

Hope this helps.

Thanks,

Samantak.

Read only

0 Likes
843

Hi Samantak

Thanks!

I don't need decimal in my result field it should read as 0000001188. How can I get in that way? My sender field value is 11.88.

Thanks for your time!

Best regards,

Pavan

Read only

0 Likes
843

Hi Pavan,

In the sample code, the fourth assignment statement is returning the data the way you want.

lv_neum = lv_char. " Value is 0000001188

Hope this will help.

Thanks,

Samantak.

Read only

0 Likes
843
data : p1 type p decimals 2 value '11.88',
       p2 type string,
       p3 type n LENGTH 10.

p3 = p2 = p1.

write p3.