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

Problem with REPLACE statement

Former Member
0 Likes
1,875

Hi Friends,

I have a field (CHAR TYPE) value as 200,000,000.00000

I want to replace the ',' with '.'

I tried with REPLACE statement. But it replaces only the first occurrence.

How to do this?

The expected output is 200.000.000.00000

Regards,

Viji

17 REPLIES 17
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,600

Hi,

Try with REPLACE ALL OCCURRENCE

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,600

I am working in 4.6C

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,600

Hi,

Use code, its working:


DATA : v_str(20) TYPE c VALUE '200,000,000,000.000'.

DATA : v_c_str(20) TYPE c.

DATA itab TYPE TABLE OF string WITH HEADER LINE.

START-OF-SELECTION.

  SPLIT v_str AT ',' INTO TABLE itab.

  LOOP AT itab.
    IF v_c_str IS INITIAL.
      v_c_str = itab.
    ELSE.
      CONCATENATE v_c_str '.' itab INTO v_c_str.
    ENDIF.
  ENDLOOP.

END-OF-SELECTION.

  WRITE : v_c_str.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,600

try

replace ALL OCCURRENCES OF.....

Thanks

RJ

Read only

former_member222860
Active Contributor
0 Likes
1,600

u tried with

REPLACE ALL OCCURRENCES OF

Read only

0 Likes
1,600

I am working in 4.6C

Read only

0 Likes
1,600

>

> I am working in 4.6C

So isn't replace all occurances of statement available to you?

then u can try like this

do.

use ur replace statement here then check sy subrc.

if sy-subrc ne 0.

exit.

endif.

enddo.

кu03B1ятu03B9к

Read only

dev_parbutteea
Active Contributor
0 Likes
1,600

Hi,

Do as below:

DATA : v_char TYPE char30 VALUE '200,000,000.00000'.

REPLACE ALL OCCURRENCES OF ',' in v_char WITH '.'.

WRITE : v_char.

Regards.

Read only

Former Member
0 Likes
1,600

Hi,

please check this code

data : wa type CEPC_BUKRS,
         itab type table of CEPC_BUKRS.
 
loop at itab into wa.
  case wa-bukrs.
    when 'PTUS' or 'HQUS' or 'CTCA'.
         replace all occurences of '-' in wa with '.'.
         modify itab from wa index sy-tabix.
  endcase.
endloop.

Thanks and regards

Durga.K

Read only

0 Likes
1,600

I am working in 4.6C

Read only

Former Member
0 Likes
1,600

Hi,

Write 'REPLACE ALL OCCURENCE' statement

Regards,

Jyothi CH.

Read only

Former Member
0 Likes
1,600

you can try this,

REPLACE ALL OCCURRENCES OF ',' IN field1 WITH '.'

Regards,

Joan

Read only

Former Member
0 Likes
1,600

Have you tried the REPLACE .....ALL OCCURRENCES OF option?

Which SAP version are you using?

Another option you have is Overlay < var> with '.................' only ','.

Mathews.

Read only

Former Member
0 Likes
1,600

Hi There,

data: lv_num(20) type c ,

lv_num1(10) type c,

lv_num2(10) type c,

lv_num3(10) type c.

if lv_num ca ','.

split lv_num at ',' into lv_num1 lv_num2 lv_num3.

concatenate lv_num1 lv_num2 lv_num3 into lv_num seperated by '.'.

Edited by: BrightSide on Mar 16, 2009 9:04 AM

Read only

Former Member
0 Likes
1,600

Hi,

data: num(20) type c value '200,000,000.00000',

num1(10) type c,

num2(10) type c,

num3(10) type c.

split num at ',' into num1 num2 num3.

concatenate num1 '.' num2 '.' num3 into num.

Hope this might help you out.

Pooja

Read only

Former Member
0 Likes
1,600

hey

Defenitely working.

DATA lv_char(20) TYPE c .

DATA lv_num(10) TYPE c.

lv_char = '200,000,000.000'.

DO.

IF lv_char CA ','.

REPLACE ',' WITH '.' INTO lv_char.

else.

EXIT.

endif.

ENDDO.

write: lv_char.

regardz

Read only

Former Member
0 Likes
1,600

Its solved using DO. REPLACE.ENDDO.