I want to display a file inside a cl_gui_textedit component with line breaks which causes me problems.
I am using the following code to initialize the component
DATA: lo_c_errorviewer TYPE REF TO cl_gui_custom_container.
CREATE OBJECT lo_c_errorviewer
EXPORTING
container_name = 'C_ERROR_MSG'.
CREATE OBJECT go_error_textedit
EXPORTING parent = lo_c_errorviewer.
go_error_textedit->set_toolbar_mode( 0 ).
go_error_textedit->set_statusbar_mode( 0 ).
After some XML processing with the iXML package the binary data of the file is available like this:
types: begin of xml_line,
data(256) type x,
end of xml_line.
data: xml_table type table of xml_line,
xml_size type i.
ostream = streamFactory->create_ostream_itable( xml_table ).
document->render( ostream = ostream recursive = 'X' ).
xml_size = ostream->get_num_written_raw( ).
This should contain line breaks if I am right. The ostream object has “pretty printing” turned on by default.
I searched the reference and the only way to pass the information is via
call method <c_textedit_control> - > set_text_as_stream
which expects a “Standard Table” of characters. How do I convert the data or pass it to the component?
It’s easier if you render your XML document into a
STRINGstraight away, which you can then send to yourCL_GUI_TEXTEDITcontrol:If you must render into binary data, then I suggest you use an
XSTRINGfor that:You can then convert the binary data to a string, using the
CL_ABAP_CONV_IN_CEclass provided by SAP:Which you can send to your
CL_GUI_TEXTEDITcontrol:Note that in case you run into encoding issues, you can set the encoding on the ostream object before rendering, and the converter object allows you to specify encoding when you create it.