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

Packed datatype with Character datatype issue.

karthick1608
Participant
0 Kudos
1,441

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
Read only

Sandra_Rossi
Active Contributor
0 Kudos
1,327

To be precise, you get CX_SY_CONVERSION_NO_NUMBER

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

Read only

SimoneMilesi
Active Contributor
0 Kudos
1,327

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

Read only

matt
Active Contributor
1,327

And read the ABAP documentation.

Read only

1,327

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

Read only

1,327

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

Read only

0 Kudos
1,327

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

Read only

DoanManhQuynh
Active Contributor
0 Kudos
1,327

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.

Read only

0 Kudos
1,327

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

Read only

0 Kudos
1,327

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.

Read only

0 Kudos
1,327
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
Read only

1,327
sandra.rossi : OK i got it now, sorry i missunderstood your comment.
Read only

Sandra_Rossi
Active Contributor
1,327

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.