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 edit control..

naveenvishal
Contributor
0 Likes
700

how to save data from text edit control to a db field with size 255..??

using std code for display,

-


CLASS event_handler DEFINITION.

PUBLIC SECTION.

METHODS: handle_f1 FOR EVENT f1 OF cl_gui_textedit

IMPORTING sender,

handle_f4 FOR EVENT f4 OF cl_gui_textedit

IMPORTING sender.

ENDCLASS.

DATA: ok_code LIKE sy-ucomm,

save_ok LIKE sy-ucomm.

DATA: init,

container TYPE REF TO cl_gui_custom_container,

editor TYPE REF TO cl_gui_textedit.

DATA: event_tab TYPE cntl_simple_events,

event TYPE cntl_simple_event.

DATA: line(256) TYPE c,

text_tab LIKE STANDARD TABLE OF line,

field LIKE line.

DATA handle TYPE REF TO event_handler.

  • Reporting Events ***************************************************

START-OF-SELECTION.

line = 'First line in TextEditControl'.

APPEND line TO text_tab.

line = '----


'.

APPEND line TO text_tab.

line = '...'.

APPEND line TO text_tab.

CALL SCREEN 100.

  • Dialog Modules *****************************************************

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

IF init is initial.

init = 'X'.

CREATE OBJECT:

container EXPORTING container_name = 'TEXTEDIT',

editor EXPORTING parent = container,

handle.

event-eventid = cl_gui_textedit=>event_f1.

event-appl_event = ' '. "system event

APPEND event TO event_tab.

event-eventid = cl_gui_textedit=>event_f4.

event-appl_event = 'X'. "application event

APPEND event TO event_tab.

CALL METHOD: editor->set_registered_events

EXPORTING events = event_tab.

SET HANDLER handle->handle_f1

handle->handle_f4 FOR editor.

ENDIF.

CALL METHOD editor->set_text_as_stream

EXPORTING text = text_tab.

ENDMODULE.

MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'INSERT'.

CALL METHOD editor->get_text_as_stream

IMPORTING text = text_tab.

WHEN 'F1'.

MESSAGE i888(sabapdocu) WITH text-001.

WHEN OTHERS.

MESSAGE i888(sabapdocu) WITH text-002.

CALL METHOD cl_gui_cfw=>dispatch.

ENDCASE.

SET SCREEN 100.

ENDMODULE.

  • Class Implementations **********************************************

CLASS event_handler IMPLEMENTATION.

METHOD handle_f1.

DATA row TYPE i.

MESSAGE i888(sabapdocu) WITH text-003.

CALL METHOD sender->get_selection_pos

IMPORTING from_line = row.

CALL METHOD sender->get_line_text

EXPORTING line_number = row

IMPORTING text = field.

CALL METHOD cl_gui_cfw=>set_new_ok_code

EXPORTING new_code = 'F1'.

CALL METHOD cl_gui_cfw=>flush.

ENDMETHOD.

METHOD handle_f4.

DATA row TYPE i.

MESSAGE i888(sabapdocu) WITH text-004.

CALL METHOD sender->get_selection_pos

IMPORTING from_line = row.

CALL METHOD sender->get_line_text

EXPORTING line_number = row

IMPORTING text = field.

CALL METHOD cl_gui_cfw=>flush.

ENDMETHOD.

ENDCLASS.

-


1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
600

Hi,

Use the function module CREATE_TEXT to save the text. For that u need to create text objects and ids using transaction SE75.

Pls refer the program SAPTEXTEDIT_TEST_1 to see the various text editor operations..

Regards,

Renjith Michael.

http://www.sourceveda.com/

3 REPLIES 3
Read only

Former Member
0 Likes
600

Hi!

You can use FMs SAVE_TEXT or COMMIT_TEXT to save long texts.

Cheers!

Read only

Former Member
0 Likes
601

Hi,

Use the function module CREATE_TEXT to save the text. For that u need to create text objects and ids using transaction SE75.

Pls refer the program SAPTEXTEDIT_TEST_1 to see the various text editor operations..

Regards,

Renjith Michael.

http://www.sourceveda.com/

Read only

Former Member
0 Likes
600

Hi NV,

where are you facing problem exactly.

i think your text_tab is getting populated in the MODULE user_command_0100 properly.

Do you want it to enter in the database table

just create a internal table of type the db table


data itab type table of DB_TAB with header line.
clear itab.

itab-field = text_tab.
append itab.
modify db_tab from table itab.

this should work out

please reward if useful.

Edited by: Sumesh Nair on Feb 15, 2008 11:06 AM