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: 

Text within single quotes

Former Member
0 Kudos
1,900

Hello Everybody,

I have a requirement wherein i need to take out text which exists within single quotes.

For eg:

string1 = Hi ' I am within single quotes' .

here i need to take the text which is inside single quotes aside.

Kindly provide me a solution.

Thanks and Regards

Manish

8 REPLIES 8

Former Member
0 Kudos
987

try this


data : text(40).

concatenate 'Hi'  '''I am within single quotes'''  into text separated by space.

regards

shiba dutta

Former Member
0 Kudos
987

Use SPLIT.

TYPES: BEGIN OF ITAB_TYPE,

WORD(20),

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.

SPLIT 'Hi '' I am within single quotes''' AT '''' INTO TABLE ITAB.

So you will have the entire string in the second record of the table.

Note that working with single quotes in ABAP makes you use twice single quotes, in order to avoid ending the string.

Message was edited by:

Angel Garcia

0 Kudos
754

Thanks..

Former Member
0 Kudos
987

hi Manish,

do this way

concatenate 'Hi' ' ' I am within single quotes' ' into string1 separated by space.

Regards,

Santosh

Former Member
0 Kudos
987

sorry for half answer.


data : text(40).
data : textsp(40).
data : text1(15),text2(15),text3(15).
data : spaces(2) value '  '.
concatenate 'Hi'  '''I am within single quotes'''  into text separated by space.
split text at '''' into text1 text2 text3.
write : / text2.

regards

shiba dutta

Former Member
0 Kudos
987

Hi Angel,

Just tried wht the same...

got an error saying 'Literals that take up more than one line not permitted.'.

I am working on ECC 6.0.

The actual requirement is

A field of an internal table wud be having an ABAP report line.

for eg

wg_report-line = AUTHORITY-CHECK OBJECT 'V_VBAK_ATT'

(NOTE: This wont be within Quotes while processing )

I need to take the value of the object out.

Thanks and Regards

Manish

Former Member
0 Kudos
987

again sorry just declare

data : text2(25).

because previously it was 15 so it is taking part of the string.

regards

shiba dutta

Former Member
0 Kudos
987

hi MAnish,

Please try the following logic:

data string1(100).
data lv_string(100).
string1 = 'Hi ''I am within single quotes'''. 
search string1 for ''''.
lv_string = string1+sy-fdpos.
lv_string = lv_string+1.
search lv_string for ''''.
lv_string = lv_string+0(sy-fdpos).

write:/ lv_string.

Hope this helps,

Sajan Joseph.