Application Development and Automation 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: 
Read only

Replacing comma with space

Former Member
0 Likes
4,775

Hi,

Note : I am using SAP 4.6

Task : Replace Comma with space

Problem : Not able to replace comma with space

I have task where I have to write result file to application server, when I am writing string to application server it is separating by comma, for example if you take below statement it is dividing by space that means in first column PO and then ITEM etcu2026.

MOVE 'PO ITEM is not there in table EKPO' TO W_RECORD_OUT-ERROR_MSG.

so to resolve this situation I have used below code for now, I know I can use

REPLACE ... ALL ENTRIES but this statement is not working in SAP 4.6

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

REPLACE ',' WITH ' ' INTO W_RECORD_OUT-ERROR_MSG.

CONDENSE W_RECORD_OUT-ERROR_MSG.

appreciate if somebody can help me.

Thanks

sarath

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,287

Hi,

just see the code below if you feel that its fine then you can proceed with it...

REPLACE ',' WITH space INTO W_RECORD_OUT-ERROR_MSG.
"  Replaced with the keyword space

Regards,

Siddarth

7 REPLIES 7
Read only

Former Member
0 Likes
2,287

You can try :

Overlay <variable> with <spaces based on length> ONLY ','.

Mathews

Read only

Former Member
0 Likes
2,287

if w_record_out-error_msg ca ','.

split w_record_out-error_msg at ',' into lv_string1

lv_string2

contatenate lv_string1 lv_string2 seperated by space.

endif.

Read only

Former Member
2,287

Ur replace statment is fine just dont use ' ' instead use ` ` ( the quotes beside number 1 on top left).

Then it will work fine.

кu03B1ятu03B9к

Read only

Former Member
0 Likes
2,288

Hi,

just see the code below if you feel that its fine then you can proceed with it...

REPLACE ',' WITH space INTO W_RECORD_OUT-ERROR_MSG.
"  Replaced with the keyword space

Regards,

Siddarth

Read only

Former Member
0 Likes
2,287

Hi,

replace all occurrences of ','

in <field> with space .

Thanks,

Krishna

Read only

0 Likes
2,287

Please see: [Inconsistent Behavior of the REPLACE statement|;

Rob

Read only

Former Member
0 Likes
2,287

Hi,

Please check the below code.


REPORT  YSAT_TEST.

Data: Var1(40) type c value 'Test1,Test2,Test3,Test4'.

break-point.

REPLACE ',' WITH space INTO Var1.                   " It will replace only first occurrence
replace all occurrences of ',' in var1 with '   '.
CONDENSE Var1 no-gaps.

write: var1.