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

insert ' as a character into string

Former Member
0 Likes
5,897

Hi everyone,

I am trying to insert the character ' into a string, but I don't know how I can put that because it is a special character.

Any ideas?

Thanks!

7 REPLIES 7
Read only

Laszlo_B
Product and Topic Expert
Product and Topic Expert
3,043

Dear Marta,

two apostrophe characters represent one apostrophe on the output.

This means: if you put '' in the string, it will be interpreted as a single ' .

Best regards,

Laszlo

Read only

raphael_almeida
Active Contributor
0 Likes
3,043

Hi Marta,

You can exemplify best at what time you want to place "?

I ask this because the procedure is quite simple in some situations, such as concatenate I show below:



DATA: a      TYPE string,
       b      TYPE string,
       string TYPE string.

a = 'CONCATENATE'.
b = 'TEST'.

CONCATENATE '"' a '"' b INTO string SEPARATED BY space.

WRITE: / string.


I await your considerations.

Read only

0 Likes
3,043

Exactly, I want to split at symbol ', so i need that this symbols not works as special character.

Read only

0 Likes
3,043

So, create a constant that has this value and use the split, as I show below:


CONSTANTS c_quot VALUE `'`.


CLEAR: a, b.
SPLIT string AT c_quot INTO a b c.


BR,


Raphael Pacheco.

Read only

0 Likes
3,043

this solution not works because when I put:

a type string value ''' (three apostrophe characters), the first open the string, the second close the string, and the thirst open again as we would want to put onether one. But I want to put this character in the string.

I mean, I need the symbol which means "ignore this character", as the symbol \ in java.

Read only

0 Likes
3,043

The solution is used the characters `` and put inside the another ', because the open symbol is diferent and the program search the same symbol, so you can put inside the another symbol.

I dont know if I explain well but this is the solution.

Thanks.

Read only

VijayaKrishnaG
Active Contributor
0 Likes
3,043

Hi Marta,

Two single quotes represent one single quote for such purposes. So, you need to mention four single quotes in a row.

Example:

DATA : L_VA1 TYPE C LENGTH 8,

            L_VA2 TYPE C LENGTH 8.

CONSTANTS : L_QT TYPE C LENGTH 1 VALUE ''''.

SPLIT P_CHAR AT L_QT INTO L_VA1 L_VA2.


" Assume P_CHAR contains string like VIJAY'KRIS.


Result: VIJAY

            KRIS



Regards,

Vijay