Control application-Creating the Text editor tutorial

Source: Internet
Author: User

Original address http://www.baidusap.com/abap/dialog/16271, text editor Introduction

Unlike normal screen fields, text editor can hold multiple lines of text, which is one of the commonly used controls in various SAP documents, such as purchase orders, which are applied to the text editor control in the voucher header and line items, as follows:

2, create the text editor control

The following describes how to create a text editor control in a Dailog program.

2.1, SE80 Create dialog program

TCODE:SE80, create a dialog program, and add a screen 100

2.2, create the custom control

On the layout of screen 100, create a custom control and enter the name Text_editor

2.3, modify the PBO code

Pbo:

    • Create PF status, detailed reference-->http://www.baidusap.com/abap/dialog/1516

    • Create an object container Go_editor_container. Then create the Text editor control object Go_editor

Data Object definition:

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.* defines the inner table for saving long text 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.

The code in module pbo_0100 is as follows:

  IF Go_editor is initial.*   creating a control container 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.*   connect the text editor and the control container object to    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, modify PAI code

PAI: Create Module user_command_0100

Code in Module user_command_0100:

    • When exiting a program, the free text editor control and the object of the control container
    • Read the long text entered in the text editor to the inner table git_mytable when saving

The code is as follows:

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_edit      Or.        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 the ' &data_save '. * Retrieve table from the control call METHOD go_editor->get_text_as_r3table importin      G table = git_mytable EXCEPTIONS OTHERS = 1. Call METHOD cl_gui_cfw=>flush EXCEPTIONS OTHERS = 1.* No flush here:* The automatic flush at the EN D of PBO does the job endcase. EndmoduLE. 

2.5, create Tcode

2.5, run the test

Run Tcode ztextedit, enter long text in the text editor control,

Click the Save button, in the debug mode, you can see the content entered in the table Git_mytable Line1,line2,line3.

Above.

Control application-Creating the Text editor tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.