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: 

Text Editor

Former Member
0 Kudos

Hi all,

I am trying to get the text from text editor using the method (get_text_as_stream) from the class (cl_gui_textedit).

Code :

when 'SAVE'.

CALL METHOD g_editor->get_text_as_stream

EXPORTING

ONLY_WHEN_MODIFIED = 1

IMPORTING

TEXT = gt_text[]

IS_MODIFIED = lc_x

EXCEPTIONS

ERROR_DP = 1

ERROR_CNTL_CALL_METHOD = 2

others = 3

While saving first time it is working fine. But when i click the save button twice or editing the text it is not fetching the text from the text editor. Can anyone tell me about it?

1 ACCEPTED SOLUTION

former_member209217
Active Contributor
0 Kudos

Hi Dharma,

Try using this one.

call method g_editor->set_text_as_r3table

exporting

table = tabtext which is of type(g_tabtext(line_length) type c occurs 0,)

exceptions

error_dp = 1

error_dp_create = 2

others = 3.

Hope it will be useful.

Regards,

Lakshman.

7 REPLIES 7

former_member209217
Active Contributor
0 Kudos

Hi Dharma,

Try using this one.

call method g_editor->set_text_as_r3table

exporting

table = tabtext which is of type(g_tabtext(line_length) type c occurs 0,)

exceptions

error_dp = 1

error_dp_create = 2

others = 3.

Hope it will be useful.

Regards,

Lakshman.

0 Kudos

Hi lakshman ,

I have used the method that you have send .Since I am facing same problem.

Former Member
0 Kudos

i think you can use READ_TEXT f.m here it can do it easily !!!

http://abaplovers.blogspot.com/2008/02/function-modules-create-text-and-read.html

Former Member
0 Kudos

To get text from text editor, its always recommended to use 'SAVE_TEXT'. For that you need the Text id. For your reference, in transaction SO10, try opening some text and in Menu you can locate the properties like 'Text ID' etc. The texts are stored in STXH table if i remember it correctly.

Former Member
0 Kudos

Hi,

You can use READ_TEXT function module, below example reads the text from the customer master...

CONCATENATE lv_kunnr '9000' '20' 'XY' INTO lv_name.

*--Read notes from the customer master

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = 'Z955'

language = sy-langu

name = lv_name

object = 'KNVV'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

lines = gt_text

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc <> 0.

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

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

ENDIF.

Similarly, based on what data you are reading you need to use, respective ID name and object.

alternatively, you can tell us what data you are reading, for example Sales order, PO etc.. then we need to set ID, name and obect accordingly.

Cheers,

Srini.

Former Member
0 Kudos

Hi,

have a look at this piece of code. Hope it helps:

Declarations:

data: mycontainer(30) type c, " string for the containers

editor type ref to cl_gui_textedit,

TextEdit_Custom_Container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

MYTABLE(line_length) TYPE C occurs 0 ,

MYTABLE1(line_length) TYPE C occurs 0 with header line ,

MYTABLE2 like LINE of MYTABLE1,

repid like sy-repid.

In PBO:

MODULE PBO OUTPUT.

IF EDITOR IS INITIAL.

  • create control container

CREATE OBJECT TextEdit_Custom_Container

EXPORTING

CONTAINER_NAME = 'TEXTEDITOR'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

mycontainer = 'TEXTEDITOR'.

  • create calls constructor, which initializes, creats and links

  • TextEdit Control

create object editor

exporting

parent = TextEdit_Custom_Container

WORDWRAP_MODE =

cl_gui_textedit=>wordwrap_at_fixed_position

WORDWRAP_POSITION = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

    • to handle different containers

  • container_linked = 1.

refresh mytable. " to initialize table upon OK_CODE 'BACK' at PAI

ENDIF.

call method TextEdit_Custom_Container->link

exporting

repid = repid

CONTAINER = mycontainer.

  • just for better visualization of the different dynpros

  • don't show toolbar and statusbar on this screen

call method editor->SET_TOOLBAR_MODE

exporting

TOOLBAR_MODE = editor->false.

call method editor->SET_STATUSBAR_MODE

exporting

STATUSBAR_MODE = editor->false.

REFRESH mytable1.

mytable2 = zev_s_afacturer-zdata.

APPEND mytable2 to mytable1.

mytable = mytable1[].

IF sy-ucomm EQ 'VISU'.

call method editor->SET_READONLY_MODE

exporting READONLY_MODE = '1'.

ELSE.

call method editor->SET_READONLY_MODE

exporting READONLY_MODE = ' '.

ENDIF.

call method editor->set_text_as_r3table

exporting table = mytable.

call method editor->SET_WORDWRAP_BEHAVIOR

EXPORTING WORDWRAP_MODE = 2

WORDWRAP_POSITION = 28.

  • finally flush

call method cl_gui_CFW=>FLUSH

exceptions

others = 1.

ENDMODULE. " PBO OUTPUT

In PAI:

FORM update_remarks.

IF sy-ucomm EQ 'UPDATE' OR ( w_answer EQ '1' AND sy-ucomm EQ 'OPT1' ).

CALL METHOD editor->get_text_as_r3table

IMPORTING table = mytable.

mytable1[] = mytable.

CLEAR mytable2.

LOOP AT mytable1 INTO mytable1.

CONCATENATE mytable2 mytable1 INTO mytable2.

ENDLOOP.

zev_s_afacturer-zdata = mytable2.

ENDIF.

ENDFORM. " update_remarks

Former Member
0 Kudos

hi

use fm READ_TEXT

pass the parameter as per the requirements

regards

sachhi