关于文本(Read_text,Save_text)

来源:互联网 发布:js模块化 编辑:程序博客网 时间:2024/05/17 02:38

1 相关tCode ->Se75 
列出相关文本对象

2 相关函数
read_text

save_text

create_text
data: it_tlines like tline occurs 0 with header line,
      call function 'CREATE_TEXT'
        exporting
          fid         = 'Z01'
          flanguage   = '1'
          fname       = l_name
          fobject     = 'ZHTBZ'
          save_direct = 'X'
        tables
          flines      = it_tlines
        exceptions
          no_init     = 1
          no_save     = 2.

DELETE_TEXT

3 相关表
STXH :STXD SAPscript 文本文件抬头

stxl:STXD SAPscript 文本文件行

4、编辑长文本一般步骤
a)使用c_textedit_control类,如:   g_editor105 type ref to c_textedit_control。
b)创建控件 
if g_editor105 is initial.
    create object g_editor105
      exporting
           repid            = l_repid
           dynnr            = l_dynnr
           dynpro_container = con_textedit_container105
    exceptions
        others = 1.
    if sy-subrc ne 0.
      message s888 with 'EDITOR_CREATE' sy-subrc.
    endif.
  endif.  
  if l_dynnr <> g_link_dynnr105.
    call method g_editor105->link_to_screen
      exporting
        repid            = l_repid
        dynnr            = l_dynnr
        dynpro_container = con_textedit_container105.
    g_link_dynnr105 = l_dynnr.
  endif.
c)设置控件属性
 "设置读写性
  if g_state = 2 or g_state = 4.
    call method g_editor105->set_readonly_mode
      exporting
        readonly_mode = c_textedit_control=>false.
  else.
    call method g_editor105->set_readonly_mode
      exporting
        readonly_mode = c_textedit_control=>true.
  endif.

  call method g_editor105->set_wordwrap_behavior
    exporting
      wordwrap_mode              = c_textedit_control=>wordwrap_at_fixed_position
      wordwrap_position          = l_textedit_wrappos
      wordwrap_to_linebreak_mode = c_textedit_control=>true
    exceptions
      others                     = 1.

  call method g_editor105->set_focus_to_control.       
c)读取文本内容并设置控件文本
      call function 'READ_TEXT'
        exporting
          id        = 'Z01'
          language  = '1'
          name      = l_name
          object    = 'ZHTBZ'
        importing
          header    = gs_textedit_header105
        tables
          lines     = it_tlines
        exceptions
          not_found = 01.

      if it_tlines[] is not initial.
        loop at it_tlines.
          append it_tlines-tdline to gt_textedit_lines105.
        endloop.
      endif.

      call method g_editor105->set_text_as_r3table
        exporting
          table = gt_textedit_lines105.
d)读取控件的文本并保存文本
  if g_editor105 is not initial.
    call method g_editor105->get_text_as_r3table
      exporting
        only_when_modified = c_textedit_control=>true
      importing
        table              = gt_textedit_lines105
        is_modified        = l_text_modified_status
      exceptions
        others             = 1.

    "设置文本修改状态
    if l_text_modified_status eq c_textedit_control=>true .
      g_moditext105 = 'X'.
    endif.
  endif.

*  call method g_editor105->get_textedit_handle
*    importing
*      handle = g_editor105handle.

* call function 'CONTROL_SET_PROPERTY'
*   exporting
*     h_control  = g_editor105handle
*     property   = 'TextModified'
*     value      = c_textedit_control=>true
*   exceptions
*     cntl_error = 1.
      "创建新的长文本
      it_tlines-tdformat = '* '.
      loop at gt_textedit_lines105 into it_tlines-tdline.
        append it_tlines.
      endloop.

      call function 'CREATE_TEXT'
        exporting
          fid         = 'Z01'
          flanguage   = '1'
          fname       = l_name
          fobject     = 'ZHTBZ'
          save_direct = 'X'
        tables
          flines      = it_tlines
        exceptions
          no_init     = 1
          no_save     = 2.



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1401954


原创粉丝点击