Skip to Content
author's profile photo Former Member
Former Member

Protecting Line (Non Editable Line) in Text Editor

HI all,

I m having requirement of showing text in Editor window, where user can add new data/lines but he cannt edit the existing text.

We are managing text written on editor window thru long text. When ever any user will open the text box OLD data will come in NON-Editable mode but he can add his comments at end of exiting text.

I developed a code every thing on screen is non-editable.

following is the sample code:

I have created a container thru SE51 (CON)

TYPES: BEGIN OF SOURCE,

LINE LIKE RSSOURCE-LINE,

END OF SOURCE.

TYPES: SOURCE_TABLE TYPE SOURCE OCCURS 0.

TYPES: BEGIN OF SCR_TEXT_LINE,

LINE(72) TYPE C,

END OF SCR_TEXT_LINE.

data:

  • lt_txttab_prot type table of tline,

lt_txttab_prot TYPE TABLE OF SCR_TEXT_LINE,

wa_txttab_prot type tline,

lt_stream_text_prot type table of tdline,

lt_SELECTED_TEXT TYPE SOURCE_TABLE.

DATA BEGIN OF LTXTTAB2 OCCURS 10.

DATA TLINE TYPE TLINE-TDLINE . "Zeile

DATA TFORMAT TYPE TLINE-TDFORMAT."Format

DATA END OF LTXTTAB2.

DATA: H_TABIX LIKE SY-TABIX,

H_TABIX2 LIKE SY-TABIX,

H_TABIX3 LIKE SY-TABIX.

CREATE OBJECT EDITOR_CONTAINER

EXPORTING

CONTAINER_NAME = 'CON'.

CREATE OBJECT CON

EXPORTING

PARENTID = EDITOR_CONTAINER

WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION

WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.

CALL METHOD CON->SET_TOOLBAR_MODE

EXPORTING

TOOLBAR_MODE = CL_GUI_TEXTEDIT=>TRUE.

CALL METHOD CON->SET_STATUSBAR_MODE

EXPORTING

STATUSBAR_MODE = CL_GUI_TEXTEDIT=>TRUE.

  • dummy Text for Editor Screen

CLEAR: lt_txttab_prot, WA_txttab_prot.

wa_txttab_prot-TDLINE = 'Hi this is First line'.

append wa_txttab_prot to lt_txttab_prot.

wa_txttab_prot-TDLINE = 'Hi this is Second line'.

append wa_txttab_prot to lt_txttab_prot.

CALL METHOD CON->set_text_as_r3table

EXPORTING

table = lt_txttab_prot.

H_TABIX = lines( lt_txttab_prot ).

CALL METHOD CON->SELECT_LINES

EXPORTING

FROM_LINE = 1

TO_LINE = H_TABIX.

CALL METHOD CON->PROTECT_SELECTION

EXPORTING

PROTECT_MODE = 1.

H_TABIX2 = H_TABIX + 1.

H_TABIX3 = H_TABIX2.

CALL METHOD CON->SELECT_LINES

EXPORTING

FROM_LINE = H_TABIX2

TO_LINE = H_TABIX3.

  • NON protected data.

CALL METHOD CON->PROTECT_SELECTION

EXPORTING

PROTECT_MODE = 0.

CALL METHOD CON->SET_SELECTION_POS

EXPORTING

FROM_LINE = 0 " YOCX_TEXT-FROM_LINE

FROM_POS = 0 " YOCX_TEXT-FROM_POS

TO_LINE = 0 " YOCX_TEXT-TO_LINE

TO_POS = 0. " YOCX_TEXT-TO_POS.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

  • Display an error message

Pls assist.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 11:49 AM

    its Done

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.