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 Folks,

Our requirement is in a report, we have to keep a button. On clicking this button, a text editor must get opened. User shall enter some texts related to a particular document say a sale order. When he presses the save button, the entered text shall get saved.

In the future, whenever we call that sale order, these texts must be present there in the editir. Can anybody throw some light on this.

JLN

11 REPLIES 11

Former Member
0 Kudos

Hi

Use fm EDIT_TEXT to do that or see the code used by SO10 (include MSSCEI00).

Max

gopi_narendra
Active Contributor
0 Kudos

see the sample program RM07METI which will give u the functionality u require, ammending it into the report is all what u need to handle

Regards

- Gopi

0 Kudos

Hi,

I have seen replies from you and Max.

Thankx for your suggestions.

I have done this technique already. The reqt is like we need to implement this text editor using Classes & Methods instead using function modules like edit_text, read_text.

Hope you got it. If you all have any solution please let me know.

JLN

0 Kudos

Hi

Try to see the program demo RSDEMO_DRAG_DROP_EDIT_TREE

Here it should find an example on how to use the class cl_gui_textedit.

Max

Former Member
0 Kudos

Hi

Why dont you use a subscreen to do the same

you can use the class <b>cl_gui_textedit</b> which will give you many options to do various operations on the subscreen

Also use READ_TEXT and SAVE_TEXT to update the text based on your requirement.

Ulli_Hoffmann
Contributor
0 Kudos

Hi,

have a look into function group STXD. The function modules, which you need are:

init_text, save_text, delete_text, read_text.

In your SO you will save an object ID, which will be used to retrieve the text when the SO is displayed.

regards, Ulli

Former Member
0 Kudos

Hi Jagan,

Check out the sample code:

&----


*& <b> Include </b> YSW_CIC_CacctL_TOP *

&----


CONSTANTS: line_length TYPE i VALUE 256.

CONSTANTS : c_object LIKE thead-tdobject VALUE 'ZSW_NOTES',

c_objectid LIKE thead-tdid VALUE 'ZCO'.

DATA:

  • reference to wrapper class of control

g_editor TYPE REF TO cl_gui_textedit,

  • reference to custom container: necessary to bind TextEdit Control

g_editor_container TYPE REF TO cl_gui_custom_container,

g_repid LIKE sy-repid,

g_ok_code LIKE sy-ucomm, " return code from screen

g_relink TYPE c, " to manage relinking

g_mytable(line_length) TYPE c OCCURS 0,

g_mytable1(line_length) TYPE c OCCURS 0,

wa_table(line_length),

wa_table1(line_length),

g_mycontainer(30) TYPE c, " string for the containers

g_container_linked TYPE i. "#EC NEEDED

" container to which control is linked

  • necessary to flush the automation queue

CLASS cl_gui_cfw DEFINITION LOAD.

DATA : ws_cacct LIKE thead-tdname.

DATA : ws_cont_acct LIKE thead-tdname.

DATA : ws_thead LIKE thead.

DATA : it_line TYPE STANDARD TABLE OF tline WITH HEADER LINE.

DATA : it_final_line TYPE STANDARD TABLE OF tline WITH HEADER LINE.

DATA : lwa_line TYPE tline .

DATA : ws_lines TYPE i.

DATA : ws_lines1 TYPE i.

DATA : ws_lines2 TYPE i.

DATA : ws_history_line TYPE tline-tdline.

DATA : flg_history_line.

<b>INCLUDE zsw_cic_contract_acct_top.</b>

PARAMETERS : p_cacct LIKE fkkvkp-vkont.

START-OF-SELECTION.

CALL SCREEN 100.

************************************************************************

  • P B O

************************************************************************

MODULE pbo OUTPUT.

DATA : ws_flg.

IF g_editor IS INITIAL.

  • set status

SET PF-STATUS 'MAIN100'.

SET TITLEBAR 'TITLE-100'.

  • create control container

CREATE OBJECT g_editor_container

EXPORTING

container_name = 'TEXTEDITOR1'

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.

g_mycontainer = 'TEXTEDITOR1'.

*Read the Previous Text :

ws_cacct = p_cacct.

ws_cont_acct = p_cacct.

SHIFT ws_cacct LEFT DELETING LEADING '0'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = c_objectid

language = sy-langu

name = ws_cont_acct

object = c_object

TABLES

lines = it_line

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.

  • SHIFT ws_Cacct LEFT DELETING LEADING '0'.

LOOP AT it_line INTO lwa_line.

APPEND lwa_line-tdline TO g_mytable.

CLEAR : lwa_line.

ENDLOOP.

IF NOT g_mytable[] IS INITIAL.

DESCRIBE TABLE g_mytable LINES ws_lines.

ELSE.

ws_flg = 'X'.

ENDIF.

APPEND space TO g_mytable.

DESCRIBE TABLE g_mytable LINES ws_lines2.

  • create calls constructor, which initializes, creats and links

  • TextEdit Control

CREATE OBJECT g_editor

EXPORTING

parent = g_editor_container

wordwrap_mode =

  • cl_gui_textedit=>wordwrap_off

cl_gui_textedit=>wordwrap_at_fixed_position

  • cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER

wordwrap_position = 75

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

  • to handle different containers

g_container_linked = 1.

ENDIF.

CALL METHOD g_editor->set_text_as_r3table

EXPORTING

table = g_mytable.

IF ws_flg NE 'X'.

CLEAR ws_flg.

CALL METHOD g_editor->select_lines

EXPORTING

from_line = 1

to_line = ws_lines.

CALL METHOD g_editor->protect_selection

EXPORTING

protect_mode = 1.

ws_lines1 = ws_lines + 1.

  • DESCRIBE TABLE g_mytable LINES ws_lines.

CALL METHOD g_editor->select_lines

EXPORTING

from_line = ws_lines1

to_line = ws_lines2.

CALL METHOD g_editor->protect_selection

EXPORTING

protect_mode = 0.

ENDIF.

CALL METHOD g_editor->set_selection_pos_in_line

EXPORTING

line = '1'

pos = '1'

EXCEPTIONS

error_cntl_call_method = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

  • CALL METHOD g_editor->set_wordwrap_behavior

  • EXPORTING

  • wordwrap_mode = 1

  • wordwrap_position = 50

    • wordwrap_to_linebreak_mode = bool_initial

  • EXCEPTIONS

  • error_cntl_call_method = 1

  • OTHERS = 2.

  • IF sy-subrc <> 0.

*

  • ENDIF.

ENDMODULE. " PBO

************************************************************************

  • P A I

************************************************************************

MODULE pai INPUT.

DATA : ws_lines4 TYPE i.

CASE g_ok_code.

WHEN 'BACK'.

PERFORM back_program.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN 'BREAK'.

PERFORM exit_program.

WHEN 'SAVE'.

g_mytable1[] = g_mytable[].

  • retrieve data from control

CALL METHOD g_editor->get_text_as_r3table

IMPORTING

table = g_mytable.

LOOP AT g_mytable INTO wa_table.

READ TABLE it_line WITH KEY tdline = wa_table.

IF sy-subrc <> 0.

*This creates a new history line (TimedateUser Stamp):

IF flg_history_line <> 'X'.

CALL FUNCTION 'ZTEXT_CREATE_HISTORY_LINE'

IMPORTING

history_line = ws_history_line.

MOVE ws_history_line TO it_final_line-tdline.

APPEND it_final_line.

ENDIF.

flg_history_line = 'X'.

ENDIF.

MOVE wa_table TO it_final_line-tdline.

APPEND it_final_line.

ENDLOOP.

ws_thead-tdname = ws_cont_acct .

ws_thead-tdid = 'ZCO'.

ws_thead-tdspras = sy-langu.

ws_thead-tdobject = 'ZSW_NOTES'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = ws_thead

savemode_direct = 'X'

TABLES

lines = it_final_line

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc EQ 0.

ENDIF.

REFRESH it_line.

CLEAR it_line.

PERFORM exit_program.

WHEN 'LOAD'.

  • send table to control

CALL METHOD g_editor->set_text_as_r3table

EXPORTING

table = g_mytable.

  • no flush here:

  • the automatic flush at the end of PBO does the job

ENDCASE.

CLEAR g_ok_code.

ENDMODULE. " PAI

************************************************************************

  • F O R M S

************************************************************************

&----


*& Form EXIT_PROGRAM

&----


FORM exit_program.

  • Destroy Control.

IF NOT g_editor IS INITIAL.

CALL METHOD g_editor->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

  • free ABAP object also

FREE g_editor.

ENDIF.

  • destroy container

IF NOT g_editor_container IS INITIAL.

CALL METHOD g_editor_container->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

  • free ABAP object also

FREE g_editor_container.

ENDIF.

  • finally flush

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

LEAVE PROGRAM.

ENDFORM. " EXIT_PROGRAM

&----


*& Form BACK_PROGRAM

&----


FORM back_program.

CASE sy-dynnr.

WHEN '0100'.

  • Destroy Control.

IF NOT g_editor IS INITIAL.

CALL METHOD g_editor->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

  • free ABAP object also

FREE g_editor.

ENDIF.

  • destroy container

IF NOT g_editor_container IS INITIAL.

CALL METHOD g_editor_container->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

  • add your handling

ENDIF.

  • free ABAP object also

FREE g_editor_container.

ENDIF.

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

LEAVE PROGRAM.

ENDCASE.

ENDFORM. " BACK_PROGRAM

&----


*& Form RELINK_CONTROL

&----


FORM relink_control.

  • toggle container which displays control

IF g_mycontainer EQ 'TEXTEDITOR1'.

g_mycontainer = 'TEXTEDITOR2'.

ELSE.

g_mycontainer = 'TEXTEDITOR1'.

ENDIF.

  • initiate relinking in PBO

g_relink = 'X'.

ENDFORM. " RELINK_CONTROL

&----


*& Form CHANGE_SCREEN

&----


FORM change_screen.

CASE sy-dynnr.

WHEN '0100'.

  • set screen

SET SCREEN 200.

LEAVE SCREEN.

WHEN '0200'.

  • set screen

SET SCREEN 100.

LEAVE SCREEN.

ENDCASE.

  • initiate relinking in PBO

g_relink = 'X'.

CLEAR g_ok_code.

ENDFORM. " CHANGE_SCREEN

Reward points if this helps.

Manish

0 Kudos

Hi Manish,

When I copied your code and activated its showing error in the following areas:

PARAMETERS : p_cacct LIKE fkkvkp-vkont.

Field "FKKVKP-VKONT" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

Also what does the INCLUDE zsw_cic_contract_acct_top contain.

Kindly help.

JLN

0 Kudos

Hi Manish,

Also send in the code for the FM : ZTEXT_CREATE_HISTORY_LINE.

JLN.

former_member184619
Active Contributor
0 Kudos

here is the way to save the data from <b>text editor</b> using <b>classes</b>into an Internal Table and then u can use it your own way..

***********************************************

report zsd_0001 .

data:

dockingleft type ref to cl_gui_docking_container,

text_editor type ref to cl_gui_textedit,

repid type syrepid.

data: textlines type table of tline-tdline,

wa_text type tline-tdline.

parameters: p_check.

at selection-screen output.

repid = sy-repid.

create object dockingleft

exporting repid = repid

dynnr = sy-dynnr

side = dockingleft->dock_at_left

extension = 1070.

create object text_editor

exporting

parent = dockingleft.

start-of-selection.

call method text_editor->get_text_as_r3table

importing

table = textlines

exceptions

others = 1.

loop at textlines into wa_text.

write:/ wa_text.

endloop.

*******************************************

Regards

-


Sachin Dhingra

reedtzj
Active Participant
0 Kudos

Hi,

There is an excellent Blog for this by Igor Barbaric some time ago.

Please see> <a href="/people/igor.barbaric/blog/2005/06/06/the-standard-text-editor-oo-abap-cfw-class Standard Text Editor (OO ABAP CFW class)</a>

I have implemented this class and used it for a sales order scenario. It does work perfectly.

Regards, Johan