通过程序实现切换Smartforms的文本编辑模式

一言不合上代码:

REPORT  ZSWITCH_EDIT_MODE.
************************************************************************
* 定义选择屏幕
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.    "选择文本编辑模式
PARAMETER:p_text RADIOBUTTON GROUP g1 USER-COMMAND c1 DEFAULT 'X', "以TEXT模式显示SMARTFORMS编辑文本
          p_msword RADIOBUTTON GROUP g1.                           "以WORD模式显示SMARTFORMS编辑文本
SELECTION-SCREEN END OF BLOCK bk1.


SELECTION-SCREEN BEGIN OF BLOCK bk2 WITH FRAME TITLE text-002. "注意事项
SELECTION-SCREEN  BEGIN  OF LINE.
SELECTION-SCREEN: COMMENT 1(79) warning1.
SELECTION-SCREEN  END  OF LINE.
SELECTION-SCREEN END OF BLOCK bk2.


************************************************************************
* Initialization
************************************************************************
INITIALIZATION.


  warning1 = '【注意】请退出当前SMARTFORMS事务代码,重新进入!'.


************************************************************************
* START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
  PERFORM switch_edit_mode.
*&---------------------------------------------------------------------*
*&      Form  SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
*       转换SMARTFORMS文本编辑模式
*----------------------------------------------------------------------*
FORM switch_edit_mode .
*更改SMARTFORMS编辑模式为TXT编辑模式
  IF p_text = 'X'.
    CALL METHOD cl_i18n_system_settings=>maintain_tcp0i
      EXPORTING
        im_history = space
        im_name    = cl_i18n_system_settings=>c_tcp0i_name_smartforms_editor
        im_value   = ''.


    IF sy-subrc = 0.
      MESSAGE 'SMARTFORMS编辑模式已转换为TEXT模式' TYPE 'S'.
    ENDIF.
  ENDIF.


*更改SMARTFORMS编辑模式为MSWord模式
  IF p_msword = 'X'.
    CALL METHOD cl_i18n_system_settings=>maintain_tcp0i
      EXPORTING
        im_history = space
        im_name    = cl_i18n_system_settings=>c_tcp0i_name_smartforms_editor
        im_value   = 'MSWord'.


    IF sy-subrc = 0.
      MESSAGE 'SMARTFORMS编辑模式已转换为MSWord模式' TYPE 'S'.
    ENDIF.


  ENDIF.
ENDFORM.                    " SWITCH_EDIT_MODE

执行情况如图:


image.png

你可能感兴趣的:(通过程序实现切换Smartforms的文本编辑模式)