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

unicode error...

Former Member
0 Likes
1,074

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 ?

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
995

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 .

9 REPLIES 9
Read only

Former Member
0 Likes
995

Hi,

You must add the IN BYTE MODE option while using X type field (SINGLE_QUOTE) for REPLACE.

Hope this will help you,

Issa

Read only

0 Likes
995

Hi Issa ,

The solution given by you is not working.

Read only

0 Likes
995

define single_quote as

DATA : single_quote(1) TYPE c VALUE '''' .

Read only

0 Likes
995

Hi Pawan ,

Changing defination of the single_quote is not the right solution.

Read only

Pawan_Kesari
Active Contributor
0 Likes
996

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 .

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
995

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

Read only

Former Member
0 Likes
995

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.

Read only

Former Member
0 Likes
995

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...

Read only

Former Member
0 Likes
995

This message was moderated.