08-01-2008 11:37 AM
What is the right expression for line feed .
Below command is not correctly. How can I express
line feed CR_LF .
REPALCE ALL OCCURENCES OF '#' WITH CR_LF
IN s_test .
I intend to replace
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
reagrds
sas
08-01-2008 4:20 PM
I am using release SAP ECC 6.0.
Yes this class is existing but I dont understand what you mean
exactly.
Pablo to sum up:
I need a way on how to replace # with new line
or line feed.
I have the following command but it returns not the
correctly result.
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.
result:
afafdfd##retretertre##vmnmnmnmmnbnm##
08-01-2008 11:42 AM
'#' means may be horizontal tab or New Line.
REPALCE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB WITH CR_LF
IN s_test .
REPALCE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>NEW_LINE WITH CR_LF
IN s_test .
08-01-2008 11:57 AM
Vijay Babu Dudla thank you.
But I get the message-> WITH CR_LF is not expected
at the simple coding below.
REPORT ZTEST19.
data hg type string.
hg = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
*REPLACE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
*WITH CR_LF IN s_test .
REPLACE ALL OCCURENCES OF CL_ABAP_CHAR_UTILITIES=>NEW_LINE WITH CR_LF
IN s_test .
08-01-2008 12:00 PM
Try using CL_ABAP_CHAR_UTILITIES=>CR_LF.
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPALCE ALL OCCURENCES OF '#' WITH CL_ABAP_CHAR_UTILITIES=>CR_LF
IN s_test .
Regards,
Joy.
08-01-2008 12:11 PM
I am sooryy but I get also here the same message
WITH CL_ABAP_CHAR_UTILITIES=>CR_LF
is ot expected
I am using release SAP ECC 6.0
What is wrong
08-01-2008 12:33 PM
Hi,
Try this:
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF
in character mode.
Regards,
Joy.
08-01-2008 12:35 PM
you have to turn the WITH and IN operators around, then it should work.
>REPLACE ... OF ... IN ... WITH ...
08-01-2008 12:42 PM
Hi freineds
thank you all. The syntax problem is solved
but result is NOT OK.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.
result:
afafdfd##retretertre##vmnmnmnmmnbnm##
08-01-2008 1:22 PM
Hi,
have you declared the class thus?
*----------------------------------------------------------------------*
* Classes *
*----------------------------------------------------------------------*
* direct definition of CR, LF etc. Alternatively use HLP_CR, HLP_LF etc.
* to fill the separators in payment files!
class cl_abap_char_utilities definition load.
Best regards.
08-01-2008 1:33 PM
hi pablo casamayor thank you very much for your kindly hint reagrding the class.
Can you please explain me that more detailed.
Regards
sas
08-01-2008 2:03 PM
Hi,
in your development after the TABLES declaration do:
e.g.
This is the tables declaration
TABLES: spfli.
This is the class declaration
class cl_abap_char_utilities definition load.
Best regards.
08-01-2008 3:44 PM
pablo casamayor this is not what I am asking for.
Is it necessary to implement the class although
CL_ABAP_CHAR_UTILITIES is a SAP class.
If so can you please describe or show how must it
impelmented and overwrited ?
Regards
sas
08-01-2008 3:57 PM
Not Necessarily. you can do it this way as well.
REPORT ztest.
TYPE-POOLs: abap.
CONSTANTS: horizontal_tab TYPE abap_char1 VALUE %_HORIZONTAL_TAB,
cr_lf TYPE abap_cr_lf VALUE %_CR_LF.
DATA s_test TYPE string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURENCES OF horizontal_tab IN s_test WITH cr_lf.
Hope this Helps.
A
08-01-2008 4:07 PM
Hi,
go to transaction SE24 and see if class CL_ABAP_CHAR_UTILITIES exists.
If it does exist then it´s only necessary to declare the class.
By the way, what´s your SAP System version?
Best regards.
08-01-2008 4:20 PM
I am using release SAP ECC 6.0.
Yes this class is existing but I dont understand what you mean
exactly.
Pablo to sum up:
I need a way on how to replace # with new line
or line feed.
I have the following command but it returns not the
correctly result.
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF '#' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.
result:
afafdfd##retretertre##vmnmnmnmmnbnm##
08-01-2008 4:28 PM
Hi,
have a look at this:
http://www.sap-img.com/abap/string-handling-in-abap-removing-unwanted-char.htm
This is another option:
e.g.
l_input = '12345678'. l_regex = '([0-9])(?=([0-9]{3})+(?![0-9]))'. l_new = '$1.'.
REPLACE ALL OCCURRENCES OF REGEX l_regex IN l_input WITH l_new.
This will insert a thousandu2019s separator
Best regards.
Edited by: pablo casamayor on Aug 1, 2008 5:49 PM
Edited by: pablo casamayor on Aug 1, 2008 5:56 PM
08-01-2008 5:15 PM
Hi,
try something like:
report ztest.
data s_test(255) type c.
data : ln type i.
data : pos type i.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
ln = strlen( s_text ).
do ln times.
pos = sy-index - 1 .
if s_text+pos(1) = '#'.
s_text+pos(1) = CL_ABAP_CHAR_UTILITIES=>CR_LF.
endif.
enddo.
write 😕 s_test.
Best regards.
Edited by: pablo casamayor on Aug 1, 2008 6:15 PM
08-01-2008 6:12 PM
I think CL_ABAP_CHAR_UTILITIES=>CR_LF have a value # then in that case why you are replacing the # with #
For testing this try to change all "a" in the string with cr_lf.
data s_test type string.
s_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
REPLACE ALL OCCURRENCES OF 'a' IN s_test WITH CL_ABAP_CHAR_UTILITIES=>CR_LF.
write: s_test.
a®
08-01-2008 6:23 PM
a®s
thanks a lot of this clarification. Is it really true
that # is line feed.
If so how can I remove # and anyhow linefeeds.
The Requirement is to remove cross hatch without
deleting the linefeeds. Because if you have e.g. such
a text:
Radovan Karadzic trying to submit a letter##to the war crimes tribunal alleging u201Cirregularitiesu201D in his##treatment. The text reads u201CWould the registrar##please take this?u201D
It is not looking nice. Is there no way solve this problem
08-01-2008 6:34 PM
As for as i know we could not differentiate the cross hash and line feed.
May be try to remove all # with space and split the string into multiple chunks
report zars.
data s_test type string.
constants : c_ash(2) type c value '##'.
s_test = 'Radovan Karadzic trying to submit a letter##to the war crimes tribunal alleging #irregularities# in his##treatment. The text reads #Would the registrar##please take this?#'.
replace all occurrences of c_ash in s_test with space.
write: s_test.
But then also your requirement will not fulfilled
a®s
Edited by: a®s on Aug 1, 2008 1:34 PM
08-01-2008 6:03 PM
pablo casamayor thanks but at your above given example
I get the same result as privous.
output is
afafdfd#retretertre#vmnmnmnmmnbnm#
nothing is replaced
08-01-2008 7:12 PM
Is it possible to do the foolowing:
Remove at first # and insert exactly there one linefeed.
Thus it is realized to not display ## and having also
linefeed. Can please illustriate that adjustment as
abap code ?
rgds
sas
08-02-2008 9:24 AM
I'm arriving late into this thread, but the # character you see could be one of several unprintable characters - SAP just prints the # to show this situation... (you can look in debug to see the actual hex value of the #)
One solution to the original question could be to do something like (not syntax checked):
data:
l_delimit(1) type c,
l_line(100) type c,
lt_line like l_line,
l_test type string.
l_delimit = '#'. "or set to CR-LF or whatever your # is
l_test = 'afafdfd#retretertre#vmnmnmnmmnbnm#'.
split l_test at l_delimit into table lt_line.
loop at lt_line into l_line.
write: / l_line.
endloop.
which should give something like
afafdfd
retretertre
vmnmnmnmmnbnm
... or did I miss the point of the question?
Jonathan
08-02-2008 9:44 AM
Hi Erdem,
Note:
The CR/LF characters cannot be displayed on ABAP lists or screens.
Check this sample code,
*------------------------------------------------------------------*
CLASS cl_abap_char_utilities DEFINITION LOAD.
TYPES:
BEGIN OF type_itab,
w_char(100) TYPE C,
END OF type_itab.
DATA:
itab TYPE TABLE OF type_itab WITH HEADER LINE.
itab = 'SIMPLE#TEST##EXAMPLE'.
REPLACE ALL OCCURRENCES OF '#' IN itab WITH
cl_abap_char_utilities=>cr_lf.
APPEND itab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'd emp est.txt'
filetype = 'ASC'
TABLES
data_tab = itab.
*Result:----------------------------------------------------------*
* SIMPLE
* TEST
*
* EXAMPLE
*-----------------------------------------------------------------*
For more info check you are previous thread,
link:
Regards
Adil