控制項之應用-建立Text Editor教程

來源:互聯網
上載者:User

標籤:

原文地址 http://www.baidusap.com/abap/dialog/16271, Text Editor介紹

不同於一般的螢幕欄位,Text Editor可以儲存多行文本,它是SAP各種憑證中常用的控制項之一,比如採購訂單中,憑證頭和行項目中都應用到text editor控制項,如下:

2, 建立text editor控制項

下面介紹如何在dailog程式中建立一個text editor控制項,

2.1, SE80建立dialog程式

Tcode:se80,建立一個dialog程式,並且添加一個螢幕100

2.2, 建立custom control

在螢幕100的layout上,建立一個custom control,並輸入名字Text_editor

2.3, 修改PBO代碼

PBO:

  • 建立pf status,詳細參照-->http://www.baidusap.com/abap/dialog/1516

  • 建立object container GO_EDITOR_CONTAINER. 然後再建立 text editor控制項對象go_editor

資料對象定義:

DATA:  go_editor           TYPE REF TO cl_gui_textedit,  go_editor_container TYPE REF TO cl_gui_custom_container,  ok_code             LIKE sy-ucomm.         " return code from screenCONSTANTS: c_line_length TYPE i VALUE 256.* 定義儲存長文本用的內表TYPES: BEGIN OF ty_mytable_line,         line(c_line_length) TYPE c,       END OF ty_mytable_line.DATA:git_mytable TYPE TABLE OF ty_mytable_line.* necessary to flush the automation queueCLASS cl_gui_cfw DEFINITION LOAD.

module pbo_0100中代碼如下:

  IF go_editor IS INITIAL.*   建立控制項容器    CREATE OBJECT go_editor_container      EXPORTING        container_name              = ‘TEXTEDITOR1‘      EXCEPTIONS        cntl_error                  = 1        cntl_system_error           = 2        create_error                = 3        lifetime_error              = 4        lifetime_dynpro_dynpro_link = 5.    IF sy-subrc NE 0.*      add your handling    ENDIF.*   將Text editor和控制項容器物件串連起來    CREATE OBJECT go_editor      EXPORTING        parent                     = go_editor_container        wordwrap_mode              = cl_gui_textedit=>wordwrap_at_fixed_position        wordwrap_to_linebreak_mode = cl_gui_textedit=>true      EXCEPTIONS        OTHERS                     = 1.  ENDIF.
2.4, 修改PAI代碼

PAI:建立Module user_command_0100

Module user_command_0100中的代碼:

  • 在退出程式的時候,free text editor控制項以及控制項容器的對象
  • 在儲存的時候讀取在text editor中輸入的長文內容到內表git_mytable中

代碼如下:

MODULE user_command_0100 INPUT.  CASE ok_code.    WHEN ‘&F03‘.      IF NOT go_editor IS INITIAL.        CALL METHOD go_editor->free          EXCEPTIONS            OTHERS = 1.*       free ABAP object also        FREE go_editor.      ENDIF.*     destroy container      IF NOT go_editor_container IS INITIAL.        CALL METHOD go_editor_container->free          EXCEPTIONS            OTHERS = 1.        IF sy-subrc <> 0.        ENDIF.*       free ABAP object also        FREE go_editor_container.      ENDIF.*     finally flush      CALL METHOD cl_gui_cfw=>flush        EXCEPTIONS          OTHERS = 1.      LEAVE PROGRAM.    WHEN ‘&DATA_SAVE‘.*     retrieve table from control      CALL METHOD go_editor->get_text_as_r3table        IMPORTING          table  = git_mytable        EXCEPTIONS          OTHERS = 1.      CALL METHOD cl_gui_cfw=>flush        EXCEPTIONS          OTHERS = 1.*   no flush here:*   the automatic flush at the end of PBO does the job  ENDCASE.ENDMODULE.

2.5, 建立Tcode

2.5, 運行測試

運行Tcode ztextedit, 在text editor控制項中輸入長文本,

點擊儲存按鈕,在debug模式中,可以看到內表git_mytable中輸入的內容line1,line2,line3.

以上。

 

控制項之應用-建立Text Editor教程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.