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: 

Convert long char-number into p results in overflow

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

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

7 REPLIES 7

former_member181995
Active Contributor
0 Kudos

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.

0 Kudos
The following code works fine for numbers up to 13 places. All above 13 decimal places results in a dump

DATA amount_c(20) TYPE c.
DATA amount_p TYPE p DECIMALS 2.

START-OF-SELECTION.
  amount_c = '12345678901234,12'.  " added one more char it does not work
  REPLACE ',' IN amount_c WITH '.'.
  amount_p = amount_c.
  WRITE:amount_p.

0 Kudos

Thats why i said

its can have 16 places.

F1 help says:

p 1 to 16 bytes 8 bytes Packed number

Flip your Code like:

REPORT zztemp.
DATA AMOUNT_C(20) TYPE C.
  DATA AMOUNT_P TYPE TTET_AMOUNT_CURR_PD."look here
START-OF-SELECTION.
  AMOUNT_C = '1234567890123123,12'.
  REPLACE ',' IN AMOUNT_C WITH '.'.
  AMOUNT_P = AMOUNT_C.
  WRITE:AMOUNT_P.

amount_c = '1234567890123'4',12'.  " Does danial Had '4' in his first post?

0 Kudos

gOtz U!!

Hi Daniel 1234567890123,12 reached the saturation of Type P.

former_member194669
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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.