2010 Feb 01 11:53 AM
Hi all,
i am facing a problem to remove ## symbol from string field.
i am using following different ways to remove it , it is not working.
data : text1 TYPE string.
text1 = ' ## He completed ## successful'.
1) REPLACE all occurrences of '##' IN:
text1 WITH ' ' .
2) TRANSLATE text1 using '## '.
3) find is also not working to find the ##.
always subrc = 0.
can any boady help to sole the issue.
Regards,
Kishan
Hi all,
i am facing a problem to remove ## symbol from string field.
i am using following different ways to remove it , it is not working.
data : text1 TYPE string.
text1 = ' ## He completed ## successful'.
1) REPLACE all occurrences of '##' IN:
text1 WITH ' ' .
2) TRANSLATE text1 using '## '.
3) find is also not working to find the ##.
always subrc = 0.
can any boady help to sole the issue.
Regards,
Kishan
2010 Feb 01 11:57 AM
Hi,
Replace # with horizontal tab
Local Constants
CONSTANTS : lc_tab(1) TYPE c VALUE "Horizontal Tab
cl_abap_char_utilities=>horizontal_tab.
Regards,
Prashant
2010 Feb 01 11:57 AM
This is because ## is actually some garbage character. You should search the forum for CL_ABAP_CHAR_UTILITIES=>CR_LF.
BR,
Suhas
2010 Feb 01 12:02 PM
Hi,
symbol is used for new line carried feed variable. It can be replaced with the following code.
Replace all occurances of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in string with spaceor
Replace all occurances of CL_ABAP_CHAR_UTILITIES=>NEWLINE in string with space.Manas M.
2010 Feb 01 12:04 PM
>
> # symbol is used for new line carried feed variable.
You should re-phrase it as :
symbol is generally used as a replacement character for new line carried feed variable.
BR,
Suhas
2010 Feb 01 2:56 PM
> Suhas Saha wrote:
> > Kumar Manas Mishra wrote:
> > # symbol is used for new line carried feed variable.
>
> You should re-phrase it as :
>
>> # symbol is generally used as a replacement character for new line carried feed variable.
>
> BR,
> Suhas
Hi Suhas,
That is because Kumar mindlessly copy&pasted it from Abhii's post in this thread:
Kumar's user ID will be deleted for repeatedly violating the forum rules and ignoring moderator requests / warnings.
Cheers,
Julius
2010 Feb 01 2:59 PM
Not again.
How long will the Guest-o-blaster take for charging up ?
2010 Feb 01 3:05 PM
Almost unbelievable persistence!
We are warming up the guest-o-blaster and documenting a few things...
Cheers,
Julius
2010 Feb 01 12:03 PM
2010 Feb 02 5:43 AM
hi,
try this sample code.
data: p_string TYPE string VALUE 'ABC##DE##F#G',
l1 TYPE i,
l2 TYPE C,
l3 TYPE string,
l4(2) TYPE c VALUE ' ' .
l1 = strlen( p_string ).
DO l1 TIMES.
l1 = l1 - 1.
l2 = p_string+l1(1).
if l2 ca 'QWERTYUIOPLKJHGFDSAZXCVBNM0987654321 '.
CONCATENATE l2 l3 INTO l3.
else.
REPLACE l2 WITH l4 INTO l2.
CONCATENATE l2 l3 INTO l3 SEPARATED BY space.
ENDIF.
ENDDO.
WRITE: l3.
2010 Feb 02 6:44 AM
Hi
You can use the following code as an example:
data l_string type string VALUE `## The replacement ## was sucessful !!!`.
replace ALL OCCURRENCES OF REGEX '(##)' in l_string with ''.
CONDENSE l_string.Please read the following article for further detail on Regular expressions:
[Regex Toy- Testing Regular Expressions In ABAP|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1f9cd701-0b01-0010-87b8-f86f9b7b823f]
Regards
2010 Feb 02 7:51 AM
Hi Faaiez Sallie ,
Thanks for your reply.
it is working fine when i write a test program.
but when i am using the same in my code it is not wotking.
please see my code below.
loop at lt_content1 into ls_content1.
w_string = ls_content1-line.
replace ALL OCCURRENCES OF REGEX '(##)' in w_string with ' '.
*CONDENSE w_string.
ls_content1-line = w_string.
*modify lt_content from ls_content1.
endloop.
i am surprised. please let me know what could be the reason.
regards,
Kishan
2010 Feb 02 8:44 AM
Right, it's time to ask a really silly and basic question. How do you know that hash characters exist in the string?. In previous posts it's already been pointed out that unprintable characters like line-feed and carriage returns will show as Hash characters when displayed/printed.
You can't use REPLACE all occurances of '##' unless there physically are hash characters in the string, which by all accounts sounds like there are not.
If is a carriage-return/line-feed in the string you can remove it like this, as alrwady pointed out:
DATA: v_crlf(2) type X value '0D0A'.
REPLACE ALL OCCURRENCES OF v_crlf IN str WITH SPACE.
Jason
2010 Feb 02 8:51 AM
use replace keyword in loop statement . definitly it will work as per your requirement
2010 Feb 02 9:37 AM
2010 Feb 02 12:38 PM
Hi all,
i am bale to get the text without ## symbol in test program.
w_string = ' ##He completed successful delivery of ##NanoTime cons. ##He did '.
split w_string at '.' into w_string1 w_string2.
CALL FUNCTION 'SSM_REPLACE_CHAR_BY_SPACE'
EXPORTING
INPUT_STRING = w_string1
CHAR = '#'
IMPORTING
OUTPUT_STRING = w_string1 .
CALL FUNCTION 'SSM_REPLACE_CHAR_BY_SPACE'
EXPORTING
INPUT_STRING = w_string2
CHAR = '#'
IMPORTING
OUTPUT_STRING = w_string2.
write : w_string1.
write : w_string2.
but when i use same code in my development it is not working.
my origibnal code is as below:
split ls_instr3 at '. ' into w_str1 w_str2 w_str3 w_str4. +++> here ls_instr3 is with text from FM output.
CALL FUNCTION 'SSM_REPLACE_CHAR_BY_SPACE'
EXPORTING
INPUT_STRING = w_str2
CHAR = '#'
IMPORTING
OUTPUT_STRING = w_str2.
but in debugging mode when i change the text with copy paste. I mean just copying the same text from w_str2 and pasting in debugging mode.
then it working.
I am not getting why this not working. as per my observation, when we hardcode the text it is working. when getting the text from FM and passing it to CALL FUNCTION 'SSM_REPLACE_CHAR_BY_SPACE' it is not working.
how to solve the above issue.
even below one :::--->
data l_string type string VALUE `## The replacement ## was sucessful !!!`.
replace ALL OCCURRENCES OF REGEX '(##)' in l_string with ''.
CONDENSE l_string.
write : l_string.
having the same problem. In test program it is working. in my original development it is not working.
REgards,
Kishan
2010 Feb 02 1:08 PM
Hi Kishan,
Iam not sure if you already tried with the class attributes.
Check this once:
DATA:c_tab VALUE cl_abap_char_utilities=>HORIZONTAL_TAB,
text1 TYPE string.
REPLACE ALL OCCURRENCES OF c_tab IN text1 WITH space.
if it is not working check with new line attribute as well.
DATA: c_new value cl_abap_char_utilities=>newline,
text1 TYPE string.
REPLACE ALL OCCURRENCES OF c_new IN text1 WITH space.
Regards,
Swarna Munukoti
2010 Feb 02 3:44 PM
Hi Swarna,
Thanks for your reply.
I already tried with the same . No use..
REgards,
Kishan
2010 Sep 16 10:34 AM
2010 Sep 16 11:43 AM
Last post 16-sept. Post before that: 2-feb.
It took you that long to solve it? I do hope you didn't remove the characters manually...
2010 Dec 16 5:05 AM
Hi all
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>CR_LF in Text WITH space.
Try this one......works well
Thank you.
Guruprasad.G
2012 Jun 27 2:10 PM
2010 Feb 02 11:28 AM
Hi,
find the test code below.
DATA: hex1(1) TYPE x VALUE 'A0'.
DATA: hex2(1) TYPE x VALUE '20'.
DATA: uhex1(2) TYPE x VALUE '00A0'.
DATA: uhex2(2) TYPE x VALUE '0020'.
DATA: char1(1) TYPE c.
DATA: test_string TYPE string VALUE 'Stuff in here'.
DATA: test_xstring TYPE xstring.
****Convert the Character String to Binary String
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = test_string
IMPORTING
buffer = test_xstring.
IF cl_abap_char_utilities=>charsize = 1.
REPLACE ALL OCCURENCES OF hex1 IN test_xstring WITH hex2 IN BYTE MODE.
ELSE.
REPLACE ALL OCCURENCES OF uhex1 IN test_xstring WITH uhex2 IN BYTE MODE.
ENDIF.
CLEAR test_string.
DATA:
convin TYPE REF TO cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = test_xstring
RECEIVING
conv = convin.
CALL METHOD convin->read
IMPORTING
data = test_string.
WRITE: / test_string.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |