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.
Showing results for 
Search instead for 
Did you mean: 

why do casts from char to packed fields fail?

Former Member
0 Kudos

hello there,

i try to assign a quite small value ('-9.123E-123') from a character(255) field into a field type p. but although the string is a number i get a CX_SY_CONVERSION_NO_NUMBER exception. only if i move the value into a float field first the typeconversion works.

data: var1(255) type c value '-9.123E-123',

var2 type f,

var3(7) type p decimals 2.


var3 = var2 = var1. => works fine

Does anybody know why the types aren't converted correctly and were i can get some additional documentation? the character field is also used for other not number like values and i do not want to use a lot of RTTI to determine the type of the field i assign the value to in my program.

thanks in advance



Former Member
0 Kudos

Packed variables will only allow conversion from character strings like "1234.56-", not even "1,234.56-".

Your value is not a packed number but rather a float. This is why the conversion to packed must go char -> float -> packed, accepting possible truncation and rounding along the way.

Most type-conversion documentation can be accessed by looking at the help for the MOVE command.


Message was edited by: Scott Barden