‎2008 Aug 29 8:25 AM
Dear All,
I have one string which contains '#' in between. And I want to replace all these '#' with ' ' (ie blank SPACE)..
For this I am using:-
REPLACE ALL OCCURRENCES OF '#' IN L_TEXT WITH ' '.
But to my greatest surprise, its not able to replace it saying sy-subrc = 4 ie its not able to locate '#'.
I have observed following:-
1. Suppose L_TEXT = 'corrective action## is that# to be #taken'
then replace all fails.
2. But suppose L_TEXT = 'corrective action # # is that # to be # taken'
then its works.
I tried the option of
REPLACE ALL OCCURRENCES OF REGEX '#*' IN L_TEXT WITH ' '.
But its putting ''#" after every character !!!
And the same functionality works with CRM4.0's ABAP editor but now when i am using it in CRM2007's ABAP editor, its not woking.
I have tried it in ABAP editors of other systems like PRD n all. Its working there too.
Can anybody please shed some light on this?
regards,
Amey Mogare
‎2008 Aug 29 8:34 AM
Hi Amey,
Try This.
REPLACE ALL OCCURRENCES OF '#' IN L_TEXT WITH SPACE.
Regards,
Chandra Sekhar
‎2008 Aug 29 8:30 AM
Hi Amey,
try it with space :
REPLACE ALL OCCURRENCES OF '#' IN L_TEXT WITH SPACE.With luck,
Pritam.
‎2008 Aug 29 8:34 AM
Hi Amey,
Try This.
REPLACE ALL OCCURRENCES OF '#' IN L_TEXT WITH SPACE.
Regards,
Chandra Sekhar
‎2008 Aug 29 8:46 AM
Nope...
As per mentioned in the my question post, SY-SUBRC is 4 which means that system is not able to locate character '#'...
And same piece of code is working if i separate the # with leading and trailing spaces !!!
regards,
Amey
‎2008 Aug 29 8:52 AM
Are you sure it's #?
SAP display undisplayable characters, like TAB as #.
In debugger, you can find the hex for the character represented as #. E.g. x10 is TAB. Then you should use, CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB as the string to replace.
matt
‎2008 Aug 30 4:29 AM
Yes Matt,
I suspect its not the actual character "#". !!!!
Actually in one of the CRM transaction GUI, there is a Text Box where user can enter his Survey details. In this, if he enters a newline then in FM i'm getting it as "#"... What I mean is if I write :-
Heading 2: h2.
Containment text
is as follows
line 1
line2
Heading 2: h2.
Then in FM's field its represented as
Heading 2: h2.
Containment text# is as follows# line 1# line2
Heading 2: h2.
But this is getting messed up in when we dump it into excel sheet.
So how do i replace these with Spaces?
sample code line would be very helpful.
Thanks a lot for pointing this out.
regards,
Amey
‎2008 Aug 30 4:51 AM
there is a Little modification Matt's suggestion , that '#' is coming from New line, So you can replace all New lines using this code.
Using CL_ABAP_CHAR_UTILITIES=>NEWLINE we can replace that '#'.
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE IN WA_REC WITH SPACE.
‎2008 Aug 30 5:22 AM
Thank you so much Vijay and Matt...
Thank you very much...
regards,
Amey Mogare
‎2008 Aug 29 8:36 AM
hi,
you can try this
Data:
w_char type c.
REPLACE ALL OCCURRENCES OF REGEX w_char IN L_TEXT WITH space.
Regards
Sumit Agarwal