Skip to content

Instantly share code, notes, and snippets.

@js1972
Created October 7, 2014 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save js1972/af9fb118bfd3d101c454 to your computer and use it in GitHub Desktop.
Save js1972/af9fb118bfd3d101c454 to your computer and use it in GitHub Desktop.
ABAP enhancements to function CATSXT_SIMPLE_TEXT_EDITOR so that the focus is initially set on the editor and that it appropriately returns no test on the cancel command.
function catsxt_simple_text_editor.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(IM_TITLE) TYPE SYTITLE
*" REFERENCE(IM_DISPLAY_MODE) TYPE XFELD DEFAULT SPACE
*" REFERENCE(IM_START_COLUMN) TYPE I DEFAULT 10
*" REFERENCE(IM_START_ROW) TYPE I DEFAULT 10
*" CHANGING
*" REFERENCE(CH_TEXT) TYPE CATSXT_LONGTEXT_ITAB
*"----------------------------------------------------------------------
create object ste
exporting
im_title = im_title
im_display_mode = im_display_mode
im_longtext_tab = ch_text.
call screen 400 starting at im_start_column
im_start_row.
ch_text = ste->get_text( ).
call method ste->free.
clear ste.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Function Module CATSXT_SIMPLE_TEXT_EDITOR, End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 Z_SIMPLE_EDITOR_HANDLE_EXIT. "active version
* This function incorrectly returns any entered text
* when the user clicks the cancel button. This enhancement
* simple clears the text if the CANCEL button was clicked.
if ok_code = 'CX_CANC'.
clear ch_text.
endif.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
endfunction.
method start.
create object container
exporting
container_name = 'LONGTEXT'
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
check sy-subrc is initial.
create object editor
exporting
parent = container
wordwrap_mode = '2'
wordwrap_position = '72'
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
others = 6.
check sy-subrc is initial.
if not display_mode is initial.
* Set control to display only
call method editor->set_readonly_mode
exporting
readonly_mode = editor->true.
endif.
call method editor->set_text_as_r3table
exporting
table = longtext_tab
exceptions
error_dp = 1
error_dp_create = 2
others = 3.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Class LCL_SIMPLE_TEXT_EDITOR, Method START, End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 Z_SIMPLE_EDITOR_SET_FOCUS. "active version
* Set the GUI focus to the text editor to save the user from
* having to click on it first with the mouse.
cl_gui_control=>set_focus( control = editor ).
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
endmethod. "start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment