Former Member

# Convert long char-number into p results in overflow

Hi,

how can i convert a long char into a p-number? The following code works fine for numbers up to 13 places. All above 13 decimal places results in a dump "Overflow when converting from ".

```  DATA AMOUNT_C(20) TYPE C.
DATA AMOUNT_P TYPE P DECIMALS 2.

AMOUNT_C = '1234567890123,12'.
REPLACE ',' IN AMOUNT_C WITH '.'.
AMOUNT_P = AMOUNT_C.
```

Thanks,

Daniel

##### Add a comment
10|10000 characters needed characters exceeded

### Related questions

Posted on Dec 18, 2008 at 04:52 PM

For type "P", a maximum length specification of 16 is allowed.

##### Add a comment
10|10000 characters needed characters exceeded
• Posted on Dec 18, 2008 at 04:50 PM

It should work,beyond 16 char you might get dump,but not in 13 char.

```REPORT zztemp.
DATA AMOUNT_C(20) TYPE C.
DATA AMOUNT_P TYPE P DECIMALS 2.
START-OF-SELECTION.
AMOUNT_C = '1234567890123,12'.
REPLACE ',' IN AMOUNT_C WITH '.'.
AMOUNT_P = AMOUNT_C.
WRITE:AMOUNT_P.```

This code works ok for me.

##### Add a comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 19, 2008 at 08:35 AM

Hi,

thanks for this explanation. I was not aware the comma and decimal places are also being taken into account.

So what can i do to extend the amount of digits being processed?

I tried using float, but this results in max 15 digits (without decimal places). Is there any way to go further?

Another constraint i have: Later on i need to pass the data into a p again, so i'm really confused why the code below works at all, as the Float "amount_p" is being moved to a p-type again.

Any hints are welcome.

```REPORT  ZP_DPU_TEST.

DATA AMOUNT_C(20) TYPE C.
DATA AMOUNT_P TYPE f.
DATA AMOUNT(9) TYPE p DECIMALS 2.

AMOUNT_C = '123456789012345,23'.
REPLACE ',' IN AMOUNT_C WITH '.'.
AMOUNT_P = AMOUNT_C.

amount = AMOUNT_P.

WRITE:/ amount.```

best regards,

Daniel

##### Add a comment
10|10000 characters needed characters exceeded
• Hi Daniel,

In your Case Type P or Type F cannot be used.Because they have certain limitation with their Length,which is not suffcient in your case.

So you may use Below Data element(UC_IPA_GCIC_RET) like:

Use this Data element

```REPORT:test.
data: char TYPE char20  VALUE '123456789012345,23',
num type UC_IPA_GCIC_RET .
CALL FUNCTION 'MOVE_CHAR_TO_NUM'
EXPORTING
chr                   = char
IMPORTING
NUM                   = num.
WRITE: num.```

It shoud work for your Case anyhow.

Cheers,

Amit.