2019 Feb 14 11:09 AM
Hi Abapers,
I am fresher to ABAP.
I am facing error while passing character value into Packed datatype variable.
var1(C16) having value -2,00.
var2(P(6) decimals 2).
When var2 is trying to store in var1, it creates an error 'sy-conversion no number'.
Can anyone explain me why it is happened and what is the solution?
Thanks a lot.
Karthick
2019 Feb 14 12:42 PM
To be precise, you get CX_SY_CONVERSION_NO_NUMBER
Please provide the code so that we can easily reproduce your issue
2019 Feb 14 1:23 PM
'-2.00' is not a number in SAP format.
Did you try with '2.00-' ?
And, why are you doing such thing?
Even more, this is a really basic question, something you could solve with just a bit of debug, assigning values manually to your packed variable and see how it's stored.
Remember: debug is your friend!
2019 Feb 14 2:49 PM
2019 Feb 15 6:02 AM
'-2.00' (period) should work, but in fact the Karthik question is about '-2,00' (comma) ... cf my answer
2019 Feb 15 8:04 AM
sandra.rossi you are totally right!
I was sure it couldn't work with sign on the front.
My bad!
Sorry for the wrong answer
2019 Feb 15 8:45 AM
SCN, please change your font, and guys, please post reproducible code, formatted with CODE button, that'll avoid confusions 😉
2019 Feb 15 1:34 AM
Its the matter of decimal point. i think your system have decimal format as: 1,234,567.89 (decimal point = dot) so your value with decimal point = comma is not concerned as a decimal. change var1 to -2.00 and it will work. you can see this format setting in tcode SU01 in default tab.
2019 Feb 15 6:00 AM
Correct finding for comma, but the cause is not related to user's decimal format - cf my answer
2019 Feb 18 12:25 AM
sandra.rossi : I tried with comma and user setting = dot, i got same exception so i guess its about decimal point. but lets wait for his reply about real code.
2019 Feb 18 7:47 AM
data var1 type c length 16 value '-2,00'. " that's a comma
data var2 type p length 6 decimals 2.
var2 = var1.
will never work (var2 = var1 will do a CX_SY_CONVERSION_NO_NUMBER exception)The only possibility is to use the period/point (here written in "commercial notation" i.e. with a leading minus sign, which is accepted):data var1 type c length 16 value '-2.00'. " period/point
2019 Feb 18 10:46 AM
2019 Feb 15 5:59 AM
Arf, in SCN, commas look like periods (points), I initially thought your source text was 2 with a period, but in fact it's a comma.
So important to post reproducible code (along with a clear description), so that we can copy & paste in an instant ! (you would have received an answer immediately !)
As said in the ABAP documentation for implicit conversions from C to P fields, "The source field must contain a number in mathematical or commercial notation"
I let you read the notation documentation, I think it's very clear.