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

modifying a string

Former Member
0 Likes
1,003

Hi

I have a string whoose value is '00789567 but i want to modivy this value to 00789567 . Look for inverted comma. How i can do this in abap.

How i can replace a inverted comma as when i write this inverted comma as string it show error.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
970

Hi,

In your case first place value is '. So, u can clear in this way....

For example...

The STR variable contains the value '00425879

Now in the above variable STR, first place i.e STR+0(1) contains the value '

WRITE '' TO STR+0(1).

Then it will replace ' as empty and now the variable STR contains the value 00425879

Regards,

Shankar.

8 REPLIES 8
Read only

Former Member
0 Likes
970

REPLACE is an ABAP command. You have answered your own question.

Read only

Former Member
0 Likes
970

Hi,

u can try like below:

DATA: text(20) TYPE C.

text = 'ABCDEF'.

REPLACE 'A' IN text WITH 'XXXX'.

modify it according to ur rqmnt.

Rgds,

Pavan

Read only

Former Member
0 Likes
970

Hi,

Try like this,



data: c_quote(4) type c value ''''.
data: var type string.

REPLACE ALL OCCURRENCES OF c_quote WITH space INTO var.

Regards,

Vikranth

Read only

Former Member
0 Likes
971

Hi,

In your case first place value is '. So, u can clear in this way....

For example...

The STR variable contains the value '00425879

Now in the above variable STR, first place i.e STR+0(1) contains the value '

WRITE '' TO STR+0(1).

Then it will replace ' as empty and now the variable STR contains the value 00425879

Regards,

Shankar.

Read only

0 Likes
970

Hi

The value is coming from internal table and, it is not sure that when will have this special character at begining .

then i can not go any of these solutions.

pls help

Read only

0 Likes
970

Hi,

Try like below. It will work in all cases.

DATA: str TYPE string.

str = '''123''3'.

REPLACE ALL OCCURRENCES OF '''' IN str WITH space.

Thanks,

Read only

0 Likes
970

Hi,

You only telling that it's coming from internal table right.

Go through this code....

REPORT  ZSHAN_COMMA.

data: BEGIN OF itab occurs 0,
        str(10) type c,
      END OF itab.

data: wa_str LIKE itab.

MOVE '''10' TO itab-str.
APPEND itab.
MOVE '20' TO itab-str.
APPEND itab.
MOVE '30' TO itab-str.
APPEND itab.
MOVE '''40' TO itab-str.
APPEND itab.

LOOP AT itab INTO wa_str.
write:/ wa_str-str.
ENDLOOP.

LOOP AT itab INTO wa_str.
IF wa_str-str+0(1) EQ ''''.
WRITE '' TO wa_str-str+0(1).
MODIFY itab FROM wa_str INDEX SY-TABIX.
ENDIF.
ENDLOOP.

LOOP AT itab INTO wa_str.
write:/ wa_str-str.
ENDLOOP.

Regards,

Shankar.

Read only

Former Member
0 Likes
970

Hi

check this

DATA str TYPE string VALUE '''00789567'.
write str.
REPLACE FIRST OCCURRENCE OF regex '''' in str with ' '.
write :/ str.

cheers

shibu