天天看點

TEXT_EDITOR應用

很多時候我們需要在自己做的dialog上放置一個文本編輯器,用于操作長文本  ,通常做法是做一個text_editor 

暫時上傳不了圖檔

源碼摘錄:

module frm_1018_text_edit output.

  data: texttable type table of textline .

  create object editor_container

    exporting

      container_name              = 'TC_TEXT'

    exceptions

      cntl_error                  = 1

      cntl_system_error           = 2

      create_error                = 3

      lifetime_error              = 4

      lifetime_dynpro_dynpro_link = 5.

  create object text_editor

    exporting

      parent                     = editor_container

      wordwrap_mode              = cl_gui_textedit=>wordwrap_at_fixed_position

      wordwrap_position          = line_length

      wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

  clear g_name.

  g_name = wa_vbak-vbeln.

  call function 'READ_TEXT'

    exporting

    client                        = sy-mandt

      id                            = 'Z006'

      language                      = sy-langu

      name                          = g_name

      object                        = 'VBBK'

*   ARCHIVE_HANDLE                = 0

*   LOCAL_CAT                     = ' '

* IMPORTING

*   HEADER                        =

    tables

      lines                         = tline[]

 exceptions

   id                            = 1

   language                      = 2

   name                          = 3

   not_found                     = 4

   object                        = 5

   reference_check               = 6

   wrong_access_to_archive       = 7

   others                        = 8

            .

  if sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  endif.

  call function 'CONVERT_ITF_TO_STREAM_TEXT'

    exporting

      language    = sy-langu

    tables

      itf_text    = tline[]

      text_stream = texttable.

  call method text_editor->set_text_as_stream

    exporting

      text            = texttable

    exceptions

      error_dp        = 1

      error_dp_create = 2

      others          = 3.

  call method text_editor->set_readonly_mode

    exporting

      readonly_mode = '1'.

繼續閱讀