Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Text Editor in Dialog Programming

Former Member
0 Likes
3,327

Hi All,

I want to create a text editor to capture long text in dialog programming. How can i do that?

Thanx in advance

6 REPLIES 6
Read only

former_member156446
Active Contributor
0 Likes
1,117

try using : FM's

TXW_TEXTNOTE_EDIT

TERM_CONTROL_EDIT

also check cl_gui_textedit or Refer to the Demo SAPSCRIPT_DEMO_NOTE_EDITOR.

Read only

Former Member
0 Likes
1,117

Using abap objects you can achieve this.

Use these two classes cl_gui_custom_container and cl_gui_textedit.

Some hints are as follows -

Declarations req.

  • Text Editor

" Container For Text Display

DATA : w_txtobj TYPE tdobname,

w_container_disp TYPE REF TO cl_gui_custom_container,

w_editor_disp TYPE REF TO cl_gui_textedit.

TYPES: w_line_ty(132) TYPE C. "(1)

DATA: t_text_tab TYPE STANDARD TABLE OF w_line_ty, "(1)

w_line_tab_ds TYPE w_line_ty, "(1)

w_text_tab_ds TYPE w_line_ty.

CONSTANT: c_txtcn(9) TYPE c VALUE 'W_GC_DISP'.

Create a screen say 9007

Put a Container on it say ''W_GC_DISP'

Now in flow logic -

PROCESS BEFORE OUTPUT.

MODULE STATUS_9007.

MODULE pbo_text_editor.

PROCESS AFTER INPUT.

MODULE exit_command_9007 AT EXIT-COMMAND.

MODULE user_command_9007.

In side module pbo_text_editor.

CREATE OBJECT: W_CONTAINER_DISP

EXPORTING container_name = c_txtcn,

W_EDITOR_DISP

EXPORTING parent = w_container_disp.

REFRESH: t_text_tab[].

  • Displaying stream text

CALL METHOD W_EDITOR_DISP->SET_TEXT_AS_STREAM

EXPORTING

TEXT = T_TEXT_TAB.

REFRESH: T_TEXT_TAB[].

In user command -

MODULE USER_COMMAND_9007 INPUT.

CALL METHOD w_editor_disp->get_text_as_stream

IMPORTING

text = t_text_tab.

In ur user command if you want to save -

you may require fm 'RKD_WORD_WRAP'.

Or export for editor object the following two -

wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

Hope this will be helpful

Thanks,

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,117

HI,

Yes, you can add using TEXT AREA control. Insert a custom control area in the screen and create a object of the text editor.

Check this code for PBO and PAI.

TEDITOR is the custom contorl area name on screen:-


MODULE PBO OUTPUT.
  IF EDITOR IS INITIAL.
 
*   set status
SET pf-status '1111'.
 
*   create control container
    CREATE OBJECT TextEdit_Custom_Container
        EXPORTING
            CONTAINER_NAME = 'TEDITOR'
        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.
    mycontainer = 'TEDITOR'.
 
*   create calls constructor, which initializes, creats and links
*   TextEdit Control
    create object editor
          exporting
           parent = TextEdit_Custom_Container
           WORDWRAP_MODE =
*               cl_gui_textedit=>wordwrap_off
              cl_gui_textedit=>wordwrap_at_fixed_position
*              cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER
           WORDWRAP_POSITION = line_length
           wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
 
*   to handle different containers
    container_linked = 1.
 
    refresh mytable.
 
  ENDIF.
 
ENDMODULE.                 " PBO  OUTPUT
 
 
MODULE pai INPUT.
case ok_code.
 
WHEN 'SAVE'.
*   retrieve table from control
clear: txt.
      call method editor->get_text_as_r3table
              importing table = mytable.
 
      loop at mytable into wa.
 
         concatenate txt wa into txt
         separated by '|'.
      endloop.
 
      shift txt left.
      length = strlen( txt ).
 
      ztext-CLUSTR = length.
      ztext-text   = txt.
 
      modify ztext.
 
      clear: ztext.
      refresh: mytable.
        call method editor->set_text_as_r3table
              exporting table = mytable.
      Message s000(zwa).
 
when 'DISP'.
  
      select single * from
      ztext
      where fund = ztext-fund.
 
      SPLIT ztext-text AT '|' INTO TABLE mytable.
 
      call method editor->set_text_as_r3table
             exporting table = mytable.
 
endcase.
 
clear: ok_code.
 
ENDMODULE.                 " pai  INPUT

Also you can refer:-

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,117

Hi,

Simplest would be:

*

DATA: objtxt like SOLISTI1 occurs 0 with header line.

*

start-of-selection.

editor-call for objtxt.

*

I hope his helps,

Regards

Raju Chitale

Read only

Former Member
0 Likes
1,117

Hi SAPPIEN,

I think the experts have given you the solutions how to code for text editor.But that require OOPS concept.

If you are not so good in that then you can opt for a different way to call function module i.e. EDIT_TEXT.

It will open you a standard EDITOR which will take care of every thing.

Because in any way you have to save the text aganist a Text object in any ways . So you can go for this Function Module .Just go through Function Module Documentation .

Hope this might help you.

Read only

I066686
Product and Topic Expert
Product and Topic Expert
0 Likes
1,117

Hi,

If you don't want to use the oops concept... then you can use the follwing FM's Create_text , Edit_text, read_text, save_text which is simple to use. I hope this will help you solving the problem.

For this you want to create one Text object and text id in se75.

If you use the FM EDIT_TEXT, text editor will be opened through which you can enter the data required.Even you can open the editor in MS-WORD ,other than line editor.

By using SAVE_TEXT you can save the data in text id.For saving you need to pass the unique Name in the type THEAD-TDNAME.

By using READ_TEXT you can reterive the data from text id by passing the textobject, text id and unique name.

Just check this FM's in se37.

with thanks and regards,

Kiruba.

Edited by: kirubakaran.t38 on Jun 21, 2009 3:45 PM

Edited by: kirubakaran.t38 on Jun 21, 2009 3:53 PM