Chinaunix首页 | 论坛 | 博客
  • 博客访问: 402393
  • 博文数量: 120
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 1266
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-16 16:04
文章分类

全部博文(120)

文章存档

2011年(4)

2010年(10)

2009年(38)

2008年(68)

我的朋友

分类:

2008-09-26 15:11:06

DATA: init(1) type c,
      CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      EDITOR    TYPE REF TO CL_GUI_TEXTEDIT.
DATA: L_TDID TYPE THEAD-TDID,
      L_TDNAME TYPE THEAD-TDNAME,
      L_TDOBJECT TYPE THEAD-TDOBJECT.
      IT_TAB TYPE TLINE OCCURS 0 WITH HEADER LINE,
      L_THEAD  TYPE THEAD.
DATA: LINE(132) TYPE C,
      TEXT_TAB LIKE STANDARD TABLE OF LINE,
      FIELD LIKE LINE.
 
***创建容器和TEXTEXIT
module pbo_100 output.
if init is initial.
    init = 'X'.
    CREATE OBJECT: CONTAINER EXPORTING CONTAINER_NAME = 'TEXTEDIT',
                   EDITOR    EXPORTING PARENT = CONTAINER.
endif.
endmodule.
 
***读长文本到TEXTEDIT
form get_advice using l_txtname type THEAD-TDNAME.
  L_TDID = 'ST'.
  L_TDNAME = L_TXTNAME."长文本的名字
  L_TDOBJECT = 'TEXT'.
  REFRESH IT_TAB.
  CLEAR IT_TAB.
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      ID                      = L_TDID
      LANGUAGE                = SY-LANGU
      NAME                    = L_TDNAME
      OBJECT                  = L_TDOBJECT
    TABLES
      LINES                   = IT_TAB
    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.
  ENDIF.
  LOOP AT IT_TAB.
    LINE = IT_TAB-TDLINE.
    APPEND LINE TO TEXT_TAB.
  ENDLOOP.
  CALL METHOD EDITOR->SET_TEXT_AS_STREAM
    EXPORTING
      TEXT = TEXT_TAB.
  REFRESH:TEXT_TAB,IT_TAB.
  CLEAR IT_TAB.
endform.
 
***TEXTEDIT内容保存到长文本
form set_advice using p_name type THEAD-TDNAME.
CALL METHOD EDITOR->GET_TEXT_AS_STREAM
    IMPORTING
      TEXT = TEXT_TAB.
  LOOP AT TEXT_TAB INTO FIELD.
    IT_TAB-TDLINE = FIELD.
    APPEND IT_TAB.
    CLEAR: FIELD,IT_TAB.
  ENDLOOP.
*** 保存长文本
  L_THEAD-TDOBJECT = 'TEXT'.
  L_THEAD-TDNAME   = P_NAME.
  L_THEAD-TDID     = 'ST'.
  L_THEAD-TDSPRAS  = SY-LANGU.
  CALL FUNCTION 'SAVE_TEXT'
    EXPORTING
      HEADER = L_THEAD
    TABLES
      LINES  = IT_TAB.
endform.
阅读(1197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~