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: 

Packed datatype with Character datatype issue.

karthick1608
Participant
0 Kudos
193

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

12 REPLIES 12

Sandra_Rossi
Active Contributor
0 Kudos
79

To be precise, you get CX_SY_CONVERSION_NO_NUMBER

Please provide the code so that we can easily reproduce your issue

SimoneMilesi
Active Contributor
0 Kudos
79

'-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!

matt
Active Contributor
79

And read the ABAP documentation.

79

'-2.00' (period) should work, but in fact the Karthik question is about '-2,00' (comma) ... cf my answer

79

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

0 Kudos
79

SCN, please change your font, and guys, please post reproducible code, formatted with CODE button, that'll avoid confusions 😉

DoanManhQuynh
Active Contributor
0 Kudos
79

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.

0 Kudos
79

Correct finding for comma, but the cause is not related to user's decimal format - cf my answer

0 Kudos
79

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.

0 Kudos
79
Quynh Doan Manh you can test it easily, change your user settings.But
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

79
sandra.rossi : OK i got it now, sorry i missunderstood your comment.

Sandra_Rossi
Active Contributor
79

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.