2007 Mar 07 9:50 AM
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
2007 Mar 07 9:54 AM
try this
data : text(40).
concatenate 'Hi' '''I am within single quotes''' into text separated by space.
regards
shiba dutta
2007 Mar 07 9:54 AM
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
2024 Aug 24 6:08 PM
2007 Mar 07 10:00 AM
hi Manish,
do this way
concatenate 'Hi' ' ' I am within single quotes' ' into string1 separated by space.
Regards,
Santosh
2007 Mar 07 10:01 AM
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
2007 Mar 07 10:05 AM
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
2007 Mar 07 10:06 AM
again sorry just declare
data : text2(25).
because previously it was 15 so it is taking part of the string.
regards
shiba dutta
2007 Mar 07 10:11 AM
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.