12-18-2008 4:34 PM
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
12-18-2008 4:52 PM
For type "P", a maximum length specification of 16 is allowed.
a®
12-18-2008 4: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.
12-18-2008 4:54 PM
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.
12-18-2008 4:58 PM
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?
12-18-2008 5:02 PM
gOtz U!!
Hi Daniel 1234567890123,12 reached the saturation of Type P.
12-18-2008 4:52 PM
For type "P", a maximum length specification of 16 is allowed.
a®
12-19-2008 8: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
12-19-2008 2:31 PM
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.