smartforms – deactivate Word as editor

The company I am working with works with SAP_BASIS 740 and SAP_ABA 740. For older versions, and for S4/HANA, it is possible to deactivate Microsoft Word as editor in smartforms – you could find lots of information about that using a search engine. But not for 740.

Why do I want to do that in 740 as well? Because every time when I tick a ’text’ in smartforms, and I forgot to choose another ’tab’, e.g. Conditions, it lasts some 10 seconds (I do not want to exaggerate…) before I have access to the ’text’; and usually, I just have to click through to the details editor. All together, a lot of time lost.

Hence, I was very eager to find a solution for 740, since I couldn’t find one out on the internet. And, I would not have written this post if I hadn’t found one myself.

Solution

Display SAPLSTXB, form CREATE_EDITOR_CONTROL.

Choose Program -> Enhance, then Edit -> Enhancement Operations -> Show Implicit Enhancement Operations.

Just under ‘form create_editor_control’, create your enhancement, name it e.g. ‘Z_EDITOR_NOT_WORD’.

Copy the text of the original form into your enhancement. Rename the fields l_* to lv_*, to prevent double definitions, adapt your code accordingly (fields l_adjustment and l_ret aren’t used…). Note the arrows (⇐) for the changes w.r.t. original code. Do not forget the ‘return’ at the end of your code. You could also just download my code and paste it at the correct place.

(Download the code.)

data: lv_adjustment type i,
lv_repid  like sy-repid,
lv_dynnr  like sy-dynnr,
lv_ret(1).

* initialization of control variables
lv_repid = sy-repid.
lv_dynnr = sy-dynnr.
noflush = true.

* create custom container object in dynpro
create object textedit_custom_container
exporting  container_name             = ‘EDITOR_CUSTOM_CONTROL’
exceptions cntl_error                  = 1
cntl_system_error           = 2
create_error                = 3
lifetime_error              = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message e101.
endif.

clear: word_error. “⇐

* check if Word must be used
if oi_ed_checked eq false or
word_error    eq true.
oi_editor  = false.
word_error = false.
try.
call function ‘NLS_WORD_ENABLE’
exporting
langu        = language
importing
ex_oi_editor = oi_editor.
catch cx_sy_dyn_call_illegal_func.
endtry.
oi_ed_checked = true.
endif.

clear: oi_editor, “⇐
word_error. “⇐
if oi_editor = true.
try.
create object word_editor
exporting
editor_container = textedit_custom_container
toolbar_visible  = true.

catch cx_word_sapscript_editor.
*      message e101.
*      screen_invisible ‘EDITOR_CUSTOM_CONTROL’.

endtry.
* TODO          Error handling
else.      ” PC Editor
*   create editor object and link the control to the custom container
create object text_editor
exporting
parent                 = textedit_custom_container
caption_list           = g_appl_captionlist
use_caption            = g_appl_use_caption
*       lifetime               =
*       style                  =
exceptions
error_cntl_create      = 1
others                 = 2.

if sy-subrc <> 0.
message e101.
endif.

*   Set drop handler for editor
set handler h_application->handle_symbol_drop for text_editor.
endif.
return. “⇐