少年休闲海

少年休闲海的SAP世界

ABAP:关于文本(Read_text,Save_text)

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_editor105type ref to c_textedit_control。
b)创建控件 
if g_editor105 is initial.
    createobject g_editor105
     exporting
          repid           = l_repid
          dynnr           = l_dynnr
          dynpro_container = con_textedit_container105
   exceptions
       others = 1.
    if sy-subrcne 0.
     message s888 with 'EDITOR_CREATE' sy-subrc.
    endif.
  endif.  
  if l_dynnr <> g_link_dynnr105.
    call methodg_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 methodg_editor105->set_readonly_mode
     exporting
       readonly_mode = c_textedit_control=>false.
  else.
    call methodg_editor105->set_readonly_mode
     exporting
       readonly_mode = c_textedit_control=>true.
  endif.

  call methodg_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 methodg_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 methodg_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.

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

*  call methodg_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.
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhongguomao/article/details/6888878
文章标签: function header c
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭