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

REPLACE ALL OCCURRENCES ?

Former Member
0 Likes
2,003

hi,

i have a character-field containing

"18.08.2003: Typenschein; Typenscheintausch; Rechnung Autohaus Brunner"

Now i want to replace all the ; with ,

I have done:

REPLACE ALL OCCURRENCES OF ';' IN satz-text WITH ','.

The result now is:

"18.08.2003: Typenschein, Typenscheintausch; Rechnung Autohaus Brunner"

WHY only the FIRST ; is replaced and not the second ????????????????????

reg, Martin

11 REPLIES 11
Read only

Former Member
0 Likes
1,298

No idea why it doesn't work unless the second ';' is not really a ';'.

But try it with :

translate satz-text using ';,'.

Read only

Former Member
0 Likes
1,298

Hi Martin,

DATA : CHAR(300) TYPE c VALUE '18.08.2003: Typenschein; Typenscheintausch; Rechnung Autohaus Brunner'.

REPLACE ALL OCCURRENCES OF ';' in char with ','.

write: / char.

The output I get is

18.08.2003: Typenschein, Typenscheintausch, Rechnung Autohaus Brunner

Which is correct.

Check the declaration for the field you have provided for satz-text

Sujay

Read only

0 Likes
1,298

coding looks like this. satz is a internal table:

DATA:     BEGIN OF satz OCCURS 0,                     "Ausgabestruktur
             krednr(8) TYPE n,                        "Kreditaktennummer
             doktyp(2) TYPE c,
             ardate TYPE d,
             pfad(100) TYPE c,
             text(150) TYPE c,
             url(200) TYPE c,                     "URL für Verbindung
END OF satz.
.
.
.
.
 LOOP AT satz.

    REPLACE ALL OCCURRENCES OF ';' IN satz-text WITH ','.          "01a

Read only

0 Likes
1,298

Hi ,

i tried this it is working fine ..

My Code

-


DATA : lv_char TYPE char300.

lv_char = '18.08.2003: Typenschein; Typenscheintausch; Rechnung; Autohaus; Brunner'.

WRITE : lv_char.

REPLACE ALL OCCURRENCES OF ';' IN lv_char WITH ','.

WRITE : lv_char.

-


and Result is

18.08.2003: Typenschein; Typenscheintausch; Rechnung; Autohaus; Brunner

18.08.2003: Typenschein, Typenscheintausch, Rechnung, Autohaus, Brunner

Regards

JK

Read only

0 Likes
1,298

Just maybe the entire text is not within satz-text field.

I dont see any reason why this wouldn't work.

Read only

0 Likes
1,298

Hi,

probably you did not modify your itab correctly.

Try

fields-symbols:
  <satz> like satz.
 LOOP AT satz assigning <satz>.
 
    REPLACE ALL OCCURRENCES OF ';' IN  <satz>-text WITH ','.

This is still far from state of the art (internal tables with header line declared wit OCCURS are obsolete) but use of a field-symbol will speed up the process.

Regards,

Clemens

Read only

Former Member
0 Likes
1,298

Hi,

I tried it & it is working fine, so no idea why it is not working at your end.

If you do not have any other option then try this :

Split the string at ; into 3 variables and then concatenate it seperated by ,.

This should work.

Rgds,

Sameer

Read only

0 Likes
1,298

guys,

thanks for your help but i stil don't get it.

i have tried it with 'normal' declaration of the char-field.

COULD it be the problem that the field is part of the structure of the internal table and not an 'standalone-field' ?

reg, Maritn

DATA:     BEGIN OF satz occurs 0,                     "Ausgabestruktur
             krednr(8) TYPE n,                        "Kreditaktennummer
             doktyp(2) type c,
             ardate type d,
             pfad(100) TYPE c,
             text(150) TYPE c,
             url(200) TYPE c,

Read only

che_eky
Active Contributor
0 Likes
1,298

Try this:

TRANSLATE satz-text USING ';,'.

Che

Read only

ThomasZloch
Active Contributor
0 Likes
1,298

Was suggested already, please read the replies before posting.

REPLACE ALL OCCURRENCES does work as well under normal circumstances, there might be some goofy code page problem or whatever, I assume the information presented here so far does not allow finding the root cause.

Thomas

Read only

Former Member
0 Likes
1,298

Hi,

Just a guess!!

If you have copy pasted the below text from some other editor, maybe the semicolon is not recognised by abap editor. Try deleting this message and type in again in your editor and check if it works. This happens sometimes with apostrophe.

"18.08.2003: Typenschein; Typenscheintausch; Rechnung Autohaus Brunner"

Regds,

Senthil