Application Development 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: 

how to replace " ' " in string

deva_gembali2
Participant
0 Kudos

IF GT_REP-SERNR CA ' ' '.

REPLACE ' ' '' IN GT_REP-SERNR WITH SPACE.

ENDIF.

Can you please give me ur answers? i am getting syntax error.

i have to replace ' with space in '000123.

e.g : input = '000123

output = 000123

how to do in abap logic ?

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Try this way


Constants: c_quot(4)     type c value ''''.
IF GT_REP-SERNR CA c_quot.
     REPLACE c_quot IN GT_REP-SERNR WITH SPACE.
ENDIF.

5 REPLIES 5

former_member194669
Active Contributor
0 Kudos

Try this way


Constants: c_quot(4)     type c value ''''.
IF GT_REP-SERNR CA c_quot.
     REPLACE c_quot IN GT_REP-SERNR WITH SPACE.
ENDIF.

0 Kudos

Thanks for your reply . Do u mean is it single quote ?

0 Kudos

Yes

venkat_o
Active Contributor
0 Kudos

Hi, <li>Try this way.


REPORT ztest.
DATA: char_data TYPE c LENGTH 10 VALUE '''000123'.
DATA:off TYPE i.

WRITE char_data.
FIND '''' IN char_data MATCH OFFSET off.
char_data+off(1) = space.
WRITE:/ char_data.
Thanks Venkat.O

Former Member
0 Kudos

Hi,

You can do this using Hex Characters.

The hex value for Single Quote is '27'.

Sample Code:-

 
*== Declare a Hex Type Variable, Char Type Variable
DATA : LC_HEX TYPE X VALUE '27', LC_CHAR TYPE C,
            LR_CONV TYPE REF TO cl_abap_conv_in_ce.

*== USE THIS METHOD FOR HEX-CHAR CONVERSION
CALL METHOD cl_abap_conv_in_ce=>create
  EXPORTING
    encoding = 'UTF-8'
    input        = lc_hex
  RECEIVING
    conv       = LR_conv.

CALL METHOD LR_CONV->read
  EXPORTING
    n    = 1
  IMPORTING
    data = lc_char.           "-- AT this point, LC_CHAR will contain the value ' (single quote)

REPLACE FIRST OCCURRENCE OF lc_char IN lc_text  WITH space.

This will work, try it out.

Regards

Dedeepya C

Edited by: dedeepya reddy on Mar 23, 2010 6:25 AM