2012-01-06 6 views
1

cl_gui_texteditコンポーネントの中にファイルを表示したいときに、改行が入って問題が発生します。ファイルをASから改行でcl_gui_texteditにロード

私は、ファイルのバイナリデータは、このような利用できるのiXMLパッケージにいくつかのXML処理の後コンポーネント

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). 

を初期化するために、次のコードを使用しています:

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(). 

これが含まれている必要がありますもし私が正しいならば、改行。 ostreamオブジェクトには、デフォルトで「きれいな印刷」がオンになっています。

I参照を検索し、情報を渡すための唯一の方法は、文字の「標準テーブル」を期待

call method <c_textedit_control> - > set_text_as_stream 

を介してです。データを変換するか、コンポーネントに渡すにはどうすればよいですか?あなたがSTRINGにあなたのXMLドキュメントをレンダリングする場合

答えて

1

それはあなたが、あなたのCL_GUI_TEXTEDITコントロールに送ることができる、すぐに簡単です:

data xmlstring type string. 
data ostream type ref to if_ixml_ostream. 
ostream = streamfactory->create_ostream_cstring(xmlstring). 
document->render(ostream = ostream recursive = 'X'). 
... 
data textedit type ref to cl_gui_textedit. 
create object textedit 
    exporting 
    parent = container. 
textedit->set_textstream(xmlstring). 



あなたがバイナリデータにレンダリングする必要がある場合は、私がお勧めあなたはそのためのXSTRINGを使用します。

data xmlxstring type xstring. 
data ostream type ref to if_ixml_ostream. 
ostream = streamfactory->create_ostream_xstring(xmlxstring). 
document->render(ostream = ostream recursive = 'X'). 

あなたはその後、を使用して、バイナリデータを文字列に変換することができますSAPが提供するクラス:あなたはエンコードの問題に遭遇した場合に、あなたは上のエンコーディングを設定することができ

data textedit type ref to cl_gui_textedit. 
create object textedit 
    exporting 
    parent = container. 
textedit->set_textstream(xmlstring). 



注意:あなたがあなたのCL_GUI_TEXTEDIT制御に送信することができます

data converter type ref to cl_abap_conv_in_ce. 
converter = cl_abap_conv_in_ce=>create(input = xmlxstring). 
data xmlstring type string. 
converter->read(importing data = xmlstring). 

ostreamオブジェクトをレンダリングする前に、変換オブジェクトを使用してエンコーディングを指定することができます。

関連する問題