cancel
Showing results for 
Search instead for 
Did you mean: 

Converting CHAR , Test 1 and Test 2 both require to work !!

pubudug
Explorer
133

DATA: lv_dec TYPE p descimal 2.

DATA: lv_string TYPE char10.

REPLACE ALL OCCURRENCES OF SUBSTRING ',' IN lv_string WITH ''.
lv_dec = lv_string.

Test 01 - success

input ---- >lv_string = 1,123

output ---->lv_dec = 1123.00

Test 02 - Fail

input ---- >lv_string = 178,862‬

output ---->lv_dec = Error

Why test 02 fail , how to make Test 01 and Test 02 both work ?

Sandra_Rossi
Active Contributor

I can't reproduce your problem. Please provide your code with exact initial lv_string values.

Accepted Solutions (0)

Answers (1)

Answers (1)

aoyang
Contributor
0 Kudos

There is a hidden character at the end of 178,862.

I copied your number from this thread to my code and when I checked in debug, it says 7 characters(as shown in my screenshot), when there is obviously 6. If you use arrow key to check each numbers, at the end it looks like there is a hidden character.

Please re-enter your number 178,862 properly. It solved the issue for me and no more dump.

Sandra_Rossi
Active Contributor
0 Kudos

In OP code, lv_string is of type CHAR10. I think the question needs to be clarified.