08-29-2006 6:13 PM
Hello,
We have a custom transaction that stores long text into table STXH, STXL using read_text, save_text, delete_text, etc..
Question: There is a need to retrieve these texts and place them into a report. However, I am unsure as to how to handle displaying the text with line breaks; so that a line break is on its own row in the report. Can this be done? Are there function modules that will take the long text and break it down into a type of table that contains an entry as a line of text?
Please advise.
Regards,
Anna-Liza
08-29-2006 6:15 PM
08-29-2006 6:17 PM
08-29-2006 6:19 PM
If you want to reformat the line size from the standard 72 to something less, you can do something like this.
report zrich_0001.
data: ilines type table of tline with header line.
call function 'READ_TEXT'
exporting
* CLIENT = SY-MANDT
id = 'Z001'
language = sy-langu
name = '999999'
object = 'ZPT_DET'
tables
lines = ilines.
<b>call function 'FORMAT_TEXTLINES'
exporting
* formatwidth = 72
linewidth = 10 "Reformat to lines of 10
tables
lines = ilines.</b>
loop at ilines.
write:/ ilines-tdline.
endloop.
Regards,
Rich Heilman
08-29-2006 6:39 PM
Hello Rich,
Thank you for the response.
When I tried the function format_textlines, it did break down the lines into the size of the line width. However, I still have the formatting symbols in the text that were retrieved from the read_text function. For example, I have 3 lines (sentences) each with a carriage return. The read text function return 2 lines in the table with symbol '##' in between the texts. When I use the format_textlines, these '##' still exists. How can I get rid of these editor symbols and just end up with the actual sentences, each on its own line?
thanks for your help.
Regards,
Anna-Liza
08-29-2006 6:47 PM
08-29-2006 6:51 PM
I'm really not sure why you are getting the CR to begin with. Maybe you can get rid of them like so.
report zrich_0001.
data: ilines type table of tline with header line.
call function 'READ_TEXT'
exporting
* CLIENT = SY-MANDT
id = 'Z001'
language = sy-langu
name = '999999'
object = 'ZPT_DET'
tables
lines = ilines.
<b>loop at ilines.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN ilines-tdline WITH space.
modify ilines.
endloop.</b>
call function 'FORMAT_TEXTLINES'
exporting
formatwidth = 72
linewidth = 10
tables
lines = ilines.
loop at ilines.
write:/ ilines-tdline.
endloop.
Regards,
RIch Heilman
08-29-2006 7:14 PM
Use fm CONVERT_TEXT to convert text from READ_TEXT to remove line breaks.
I think ## showing up because, new line characters are not converted properly to line breakes during SAVE_TEXT.
Try the following code:
data: tlines like tline occurs 0 with header line,
flines like tline occurs 0 with header line,
header like thead.
call function 'READ_TEXT'
exporting
* CLIENT = SY-MANDT
id = 'ST'
language = 'E'
name = 'ZTEST'
object = 'TEXT'
importing
header = header
tables
lines = tlines
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8
.
call function 'CONVERT_TEXT'
exporting
codepage = '0000'
direction = 'EXPORT'
formatwidth = 72
format_type = 'ASCII'
header = header
with_tab = 'X'
word_langu = sy-langu
tables
foreign = flines
itf_lines = tlines.
loop at flines.
write:/ flines.
endloop.
Regards
Sridhar
08-29-2006 7:18 PM
Hello,
FM RKD_WORD_WRAP did not remove the carriage returns (##). So, I cannot use this one.
We are on 4.6b and do not have class cl_abap_char_utilities=>cr_lf
Regards,
Anna-Liza
08-29-2006 7:20 PM
08-29-2006 8:15 PM
Hello,
thanks for the replies. Sridhar suggested that the save_text was not being done correctly. In a way he was correct. When I get the data into the container, the code was performing the method get_text_as_stream. I changed this to perform method get_text_as_r3table and did the save. This removed the CR and placed the text into a table format when I then do a read_text.
Thanks for all your help and suggestions.
Regards,
Anna-Liza