Application Development 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: 

creation of text controls

Former Member
0 Kudos

how to create a text control in module pools and the need is whatever typed in the text control should be internally saved in a text table.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Prabavathi,

You can use a TEXT_EDIT controls using a custom a container.

Look at this weblog which will explain the process.

You can use the methods of the class to get the data into the internal table.

/people/igor.barbaric/blog/2005/06/06/the-standard-text-editor-oo-abap-cfw-class

Regards,

Ravi

Note : please mark the helpful answers

7 REPLIES 7

Former Member
0 Kudos

Prabavathi,

You can use a TEXT_EDIT controls using a custom a container.

Look at this weblog which will explain the process.

You can use the methods of the class to get the data into the internal table.

/people/igor.barbaric/blog/2005/06/06/the-standard-text-editor-oo-abap-cfw-class

Regards,

Ravi

Note : please mark the helpful answers

former_member188685
Active Contributor
0 Kudos

Hi,

you need to use class <b>CL_GUI_TEXTEDIT</b>.

just check this sample module pool program...

*&---------------------------------------------------------------------*
*& Module pool       Z_TEST_TEXT                                       *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

*--  test program to display a text area thru a custom control

PROGRAM  z_test_text    .
DATA: txt     TYPE REF TO cl_gui_textedit,
      txt_con TYPE REF TO cl_gui_custom_container.
DATA: gt_text(100) OCCURS 10 WITH HEADER LINE.
DATA: BEGIN OF it_tab OCCURS 0,
      LINE(100),
      END OF it_tab.

start-of-selection.


*&---------------------------------------------------------------------*
*&      Module  STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_1000 OUTPUT.
  SET PF-STATUS 'TEXT'.
  SET TITLEBAR 'TEXT AREA'.
it_tab-line = 'aaaaaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.

it_tab-line = 'aaa'.
append it_tab.
it_tab-line = 'bbb'.
append it_tab.
it_tab-line = 'ccc'.
append it_tab.
it_tab-line = 'ddd'.
append it_tab.
*-- test display in text area
*  gt_text = 'aaa'.
*  APPEND gt_text.
*-- populating gt_text from it_tab.
 loop at it_tab.
    gt_text = it_tab-line.
    append gt_text.
 endloop.

ENDMODULE.                 " STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo_1000 OUTPUT.
  DATA: container(30).

  container = 'TEXT'.

  IF txt IS INITIAL.
    CREATE OBJECT txt_con
     EXPORTING
       container_name = container
     EXCEPTIONS
       OTHERS = 1.

    CREATE OBJECT txt
      EXPORTING
       parent = txt_con
       wordwrap_mode  = cl_gui_textedit=>wordwrap_at_fixed_position
       wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
  ENDIF.

  CALL METHOD txt_con->link
    EXPORTING
      repid     = sy-repid
      dynnr     = '1000'
      container = container.

  CALL METHOD txt->set_toolbar_mode
    EXPORTING
      toolbar_mode = txt->true.

  CALL METHOD txt->set_statusbar_mode
    EXPORTING
      statusbar_mode = txt->true.

  CALL METHOD txt->set_wordwrap_behavior
    EXPORTING
      wordwrap_mode = txt->true.

*-- set text -------------------------------------------
  IF gt_text[] IS INITIAL.

  ENDIF.

  CALL METHOD txt->set_text_as_r3table
    EXPORTING
      table = gt_text[].

  CALL METHOD txt->set_readonly_mode.

ENDMODULE.                 " pbo_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1000 INPUT.
  CASE sy-ucomm.
    WHEN  'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_1000  INPUT

retrieve the text from editor and save it using SAVE_TEXT.

Regards

vijay

Former Member
0 Kudos

Hi Prabhavathi,

I think your requirement can be satisfied using Text Edit control (similar to our ABAP Editor where we write our code). It can be implemented using Object Oriented technology.

You can find nice information from

http://www.sapgenie.com/abap/controls/textedit.htm

I can send a sample program to you if you want it.

Regards,

Sylendra.

0 Kudos

Hi,

Thanks a lot, if possible will u please send me sample code.

Regards,

Praba.

0 Kudos

Hi,

Send me your e-mail id, please.

Regards,

Sylendra.

0 Kudos

Prabavathi,

The blog I hvae refered has code as well as screen shots.

Regards,

Ravi

Note : Please mark the helpful answers.

0 Kudos

Hi Prabha,

This is a very simple way of creating Text editor control.

1) Create a custom control in your screen painter . Give it some name (say TEXT_EDIT)

2) In the variable declaration ,write the following

CLASS cl_gui_cfw DEFINITION LOAD.

DATA: obj_custom_container TYPE REF TO cl_gui_custom_container,

obj_textedit TYPE REF TO cl_gui_textedit.

DATA: s_data_line(132) TYPE C,

t_data_tab LIKE TABLE OF s_data_line WITH HEADER LINE.

DATA: ok_code type sy-ucomm.

3) In the PBO, following steps have to be made

a) Initialize the object of the container

b) Initialize the control, which is text editor control

That is it!!!!!!

This will create a text editor control for you...

The code is given below..

IF OBJ_CUSTOM_CONTAINER IS INITIAL.

create object obj_custom_container

exporting

  • PARENT =

container_name = 'DYNPRO_CONTAINER'

  • STYLE =

  • LIFETIME = lifetime_default

  • REPID =

  • DYNNR =

  • NO_AUTODEF_PROGID_DYNNR =

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

others = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

create object obj_textedit

exporting

  • MAX_NUMBER_CHARS =

  • STYLE = 0

  • WORDWRAP_MODE = WORDWRAP_AT_WINDOWBORDER

  • WORDWRAP_POSITION = -1

  • WORDWRAP_TO_LINEBREAK_MODE = FALSE

  • FILEDROP_MODE = DROPFILE_EVENT_OFF

parent = OBJ_CUSTOM_CONTAINER

  • LIFETIME =

  • NAME =

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

GUI_TYPE_NOT_SUPPORTED = 5

others = 6

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

4) Now we want some text written in the control to be stored in some internal table.

For that use the method GET_TEXT_AS_R3TABLE.

See the code here..

CALL METHOD obj_textedit->get_text_as_r3table

  • EXPORTING

  • ONLY_WHEN_MODIFIED = FALSE

IMPORTING

TABLE = T_DATA_TAB[]

  • IS_MODIFIED =

EXCEPTIONS

ERROR_DP = 1

ERROR_CNTL_CALL_METHOD = 2

ERROR_DP_CREATE = 3

POTENTIAL_DATA_LOSS = 4

others = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Now data will be stored in the internal table. You can access the table using loop ... endloop.

Hope your query is solved..

Regards,

Sylendra.