‎2010 Oct 01 5:41 PM
Hello Experts,
I have one application which accepts long text(text editor control) and save it to the Ztable by dividing into char255. It stores into Ztable in the form of stream, as the control have that method to read & write long text as stream.
Now for reporting purpose. When I want to display the data it displays '##' wherever 'ENTER' or 'NEW-LINE' has been written.
I wanted to replace that ## with new line.
I tried using
REPLACE ALL OCCURANCES OF '##' IN p_str WITH cl_abap_char_utilities=>newline.but its not working for me.
Please suggest how to replace this ## with newline character in string. Or is there any FM available to convert stream to string directly?
<< Removed >>
I appriciate your time and Thanks in advance.
Regards,
bh_hir
Edited by: Rob Burbank on Oct 1, 2010 1:32 PM
‎2010 Oct 01 10:12 PM
if you need to keep the format for show it in a smartform, you can create a text element instead of saving it in a 255 char lines.
You can create the text with the FM 'CREATE_TEXT'
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'ZDET'
flanguage = sy-langu
fname = p_nomb
fobject = 'ZOBJ'
save_direct = 'X'
fformat = '*'
TABLES
flines = t_txt
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.the second step is create a text element in your smartform, but declaring type "I" .
hope it helps (sorry about my english)
Edited by: Sebastian Bustamante on Oct 1, 2010 11:12 PM
‎2010 Oct 01 6:15 PM
When you convert your text from the control, you need to do it as follows:
CALL METHOD ctrl_notes->get_text_as_stream
IMPORTING
text = lt_text_table
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = lt_text_table
itf_text = lt_itf_text.
‎2010 Oct 01 8:05 PM
Hi Brad,
Thanks for the reply.
From control, I am storing stream to the database. So while I will retrieve data for reports, I dont have to use
ctrl_notes->get_text_as_streamOnly thing I do is, I wanted to print that lines (char255), but it has ## when I pressed enter. In report/Smarform display I dont want that ##, and needed newline there.
and I have to store the long text as stream to the ztables only, because if I convert it to the string then again I have to convert it to the table and then store, In table I dont want to save blank lines, there ## is good.
In reporting part only I want to replace ## with newline. plz help.
Thanks & Regards,
bh_hir
‎2010 Oct 01 10:22 PM
I agree with Sebastian - sounds like you're working against the standard instead of using it. 'Work smarter, not harder' is my motto...
‎2010 Oct 01 10:12 PM
if you need to keep the format for show it in a smartform, you can create a text element instead of saving it in a 255 char lines.
You can create the text with the FM 'CREATE_TEXT'
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'ZDET'
flanguage = sy-langu
fname = p_nomb
fobject = 'ZOBJ'
save_direct = 'X'
fformat = '*'
TABLES
flines = t_txt
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.the second step is create a text element in your smartform, but declaring type "I" .
hope it helps (sorry about my english)
Edited by: Sebastian Bustamante on Oct 1, 2010 11:12 PM
‎2010 Oct 04 11:22 AM
‎2010 Oct 04 1:24 PM
‎2010 Oct 04 1:49 PM
‎2010 Oct 04 2:41 PM
Hi Maen / Raul,
the hex value for ## is : 0D0A in my string!
I have tried using
REPLACE ALL OCCURRENCES OF REGEX '\Q#\E' in p_line
WITH cl_abap_char_utilities=>newlinebut its not working for me! am I doing anything wrong here? Plz suggest..
Example:
This is Descr text .##hello 1234##this is tesing##
I want this string to be displayed as below.
This is Descr text .
hello 1234
this is tesingThanks & Regards,
bh_hir
Edited by: bh_hir on Oct 4, 2010 3:42 PM
‎2010 Oct 04 2:46 PM
‎2010 Oct 04 3:02 PM
DATA: itab TYPE TABLE OF string,
wa LIKE LINE OF itab.
data : l_text type string.
l_text = 'abc#xyz'.
SPLIT l_text AT '#' INTO TABLE itab.
loop at itab into wa.
write:/ wa.
endloop.
Output
abc
xyz
You can try out above code, probably that is your solution.
‎2010 Oct 04 3:25 PM
Hi Maen,
Yes it partially solved my problem, It was not newline, it was cr_lf.
so I did replaced cl_abap_char_utilities=>CR_LFwith ' ' In my string. It seems that ## will not come now. but is there any way I can really display
This is Descr text .
hello 1234
this is tesingInstead of
This is Descr text .hello 1234this is tesing
although there is way by spliting it at cl_abap_char_utilities=>CR_LF , but If we can just replace the char which will directly can do the above thing, then I do not have to process on many strings.
Plz suggest!
Thanks & Regards,
bh_hir
‎2010 Oct 04 3:28 PM
Where are you displying the text? ABAP list? ALV? Smartform?
‎2010 Oct 04 3:30 PM
ALV & Smarform.
ALV it doesn't matter if its in one line.
But in smartform I have to display as they have entered.
Descr text .
hello text
testing
‎2010 Oct 04 3:34 PM
First thing that comes to mind it pass it as separate lines in an internal table to your smartform, loop over that internal table in your smartform and print the lines.
Maybe there are more elegant solutions but this is the first that came to mind.
‎2010 Oct 04 3:39 PM
‎2010 Oct 04 4:37 PM
Hi bh_hir,
Have you tried the code I have given?
It will require very minor changes to implement into your code.
because as per your scenarion I think split is the best way.
‎2010 Oct 04 11:06 PM
Yeah, Thanks everyone for your time.
@Sabestian, am going with your suggestion. Thanks again!
‎2010 Oct 04 3:27 PM