‎2009 May 20 1:22 PM
I am facing an error for the following syntax.
LOOP AT TAB.
REPLACE SINGLE_QUOTE WITH ' ' INTO TAB-DATA.
MODIFY TAB INDEX SY-TABIX.
Endloop.
The error is -
"SINGLE_QUOTE" must be a character-type data object (data type C, N, D,T or STRING). field string).
Single_quote is defined as -
Data : SINGLE_QUOTE(1) TYPE X VALUE '27'.
Tab is defined as -
DATA : BEGIN OF TAB OCCURS 10,
DATA(80) TYPE C,
END OF TAB.
What is the CL_ABAP_CHAR_UTILITIES=> for above hexadecimal ?
‎2009 May 20 2:14 PM
Why SINGLE_QUOTE is defined as X
Data : SINGLE_QUOTE(1) TYPE X VALUE '27'.See code below..
DATA : i_string TYPE string VALUE 'They say ''Hi''' .
DATA : single_quote(1) TYPE c VALUE '''' .
WRITE / i_string .
REPLACE ALL OCCURRENCES OF single_quote in i_string WITH ' ' .
WRITE / i_string .
‎2009 May 20 2:06 PM
Hi,
You must add the IN BYTE MODE option while using X type field (SINGLE_QUOTE) for REPLACE.
Hope this will help you,
Issa
‎2009 May 20 2:14 PM
‎2009 May 20 2:23 PM
define single_quote as
DATA : single_quote(1) TYPE c VALUE '''' .
‎2009 May 20 2:29 PM
Hi Pawan ,
Changing defination of the single_quote is not the right solution.
‎2009 May 20 2:14 PM
Why SINGLE_QUOTE is defined as X
Data : SINGLE_QUOTE(1) TYPE X VALUE '27'.See code below..
DATA : i_string TYPE string VALUE 'They say ''Hi''' .
DATA : single_quote(1) TYPE c VALUE '''' .
WRITE / i_string .
REPLACE ALL OCCURRENCES OF single_quote in i_string WITH ' ' .
WRITE / i_string .
‎2009 May 20 2:34 PM
Hello Narayan,
I find that the X field '27' corresponds to '(' in character mode.
Try like this:
DATA : SINGLE_QUOTE(1) TYPE C VALUE '('.
DATA : BEGIN OF TAB OCCURS 10,
DATA(80) TYPE C,
END OF TAB.
LOOP AT TAB.
REPLACE SINGLE_QUOTE WITH ' ' INTO TAB-DATA.
MODIFY TAB INDEX SY-TABIX.
ENDLOOP.Hope this solves your problem.
BR,
Suhas
‎2009 May 25 11:18 AM
Hi
You can use the method UCCP of the class CL_ABAP_CONV_IN_CE to convert hexadecimal to character type .
Just before using the replace statement,u can call this method and do the conversion.
data: single_quote1(1) type c.
CALL METHOD cl_abap_conv_in_ce=>uccp
EXPORTING
uccp = single_quote
receiving
char = single_quote1
Use single_quote1 further for the statements which uses the same variable.
Hope this helps.
‎2009 May 25 11:35 AM
Hi Narayan....
first declare a variable of type c and then use SCMS_BIN_TO_TEXT function module....
this function module converts Hex value to char value.....
the export parameter should be the hex variable and the import parameter should be the char variable...
i hope it helps...
‎2011 Sep 05 10:26 AM