09-24-2008 8:07 AM
Hello everyone,
I have a problem with data convert from char to packed number.
Ex code:
data: str(10) value '1,200.12'.
data: amount(13) type p decimals 2.
amount = str.
I got an runtime error: "Unable to interpret "1,200.12 " as a number"
Could you please help me to convert char to number?
Many thanks!
09-24-2008 8:15 AM
data: str(10) value '1,200.12'.
data: amount(13) type p decimals 2.
REPLACE ALL OCCURRENCES OF ',' IN str WITH ''.
Else to make it better
SELECT SINGLE dcpfm "Decimal notaion
FROM usr01 "User master record (runtime data)
INTO l_user_decimal
WHERE bname EQ sy-uname.
CASE l_user_decimal.
WHEN ' '. " Decimal point is comma: N.NNN,NN
TRANSLATE str USING '. '.
TRANSLATE str USING ',.'.
WHEN 'X'. " Decimal point is period: N,NNN.NN
TRANSLATE str USING ', '.
WHEN 'Y'. " Decimal point is N NNN NNN,NN
TRANSLATE str USING ',.'.
ENDCASE.
CONDENSE str NO-GAPS.
amount = str.
Edited by: Swastik Bharati on Sep 24, 2008 9:20 AM
09-24-2008 8:09 AM
09-24-2008 8:13 AM
Remove the coma in the value and pass, as coma is given by system itself according to user settings
Data :
char(10) type c value '1200.12',
pack type p decimals 2,
int type i.
pack = char.
int = char.
Write 😕 pack,
int.
09-24-2008 8:15 AM
data: str(10) value '1,200.12'.
data: amount(13) type p decimals 2.
REPLACE ALL OCCURRENCES OF ',' IN str WITH ''.
Else to make it better
SELECT SINGLE dcpfm "Decimal notaion
FROM usr01 "User master record (runtime data)
INTO l_user_decimal
WHERE bname EQ sy-uname.
CASE l_user_decimal.
WHEN ' '. " Decimal point is comma: N.NNN,NN
TRANSLATE str USING '. '.
TRANSLATE str USING ',.'.
WHEN 'X'. " Decimal point is period: N,NNN.NN
TRANSLATE str USING ', '.
WHEN 'Y'. " Decimal point is N NNN NNN,NN
TRANSLATE str USING ',.'.
ENDCASE.
CONDENSE str NO-GAPS.
amount = str.
Edited by: Swastik Bharati on Sep 24, 2008 9:20 AM
09-24-2008 8:22 AM
Thank you Swastik Bharati,
I gave points to all of you!
Thanks again!