Application Development 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: 

Conversion from CHAR to DECIMAL with different lengths

Former Member
0 Kudos

I have to move a variable of type char to decimal.

Note that ZDEC below is a data element of type DEC (10,7)

Here's an example.

DATA: gd_char(6) TYPE C VALUE '200.0000001',

gd_dec TYPE ZDEC.

MOVE gd_char TO gd_dec.

-> I get a run time error

5 REPLIES 5

Former Member
0 Kudos

Hi,

Try this..

DATA: <b>gd_char(12)</b> TYPE C VALUE '200.0000001'.

Thanks

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Make sure that you field definitions are correct. this works fine



report zrich_0001.

DATA: gd_char(11) TYPE C VALUE '200.0000001',
gd_dec(10) TYPE p decimals 7.

MOVE gd_char TO gd_dec.

write:/ gd_dec.

Regards,

Rich Heilman

Former Member
0 Kudos

SORRY I mistyped the size of gd_char, even with the correct length itdoes not work

I have to move a variable of type char to decimal.

Note that ZDEC below is a data element of type DEC (10,7)

Here's an example.

DATA: gd_char(11) TYPE C VALUE '200.0000001',

gd_dec TYPE ZDEC.

MOVE gd_char TO gd_dec.

-> I get a run time error

0 Kudos

what is the error?

0 Kudos

<b>DATA: gd_char(11) TYPE C VALUE '200.0000001',

gd_dec(10) TYPE p decimals 7.

MOVE gd_char TO gd_dec.

write:/ gd_char, gd_dec.</b>

I didn't get any error..