Mobile: 135 8576 5961 / WeChat: IM_WILLIAM_C / Mail: william.chen.cn@outlook.com /
分类: 其他平台
2013-01-29 18:36:11
我们通常在开发报表时,选择屏上自定义字段的描述通常是通过SE38代码编辑界面下菜单GOTO下Text element中去维护的,或者有必要时通过 SELECTION-SCREEN COMMENT 语句去声明,但这些都是静态的设置了描述。下面是一段动态控制选择屏幕上字段描述显示的代码:
*&---------------------------------------------------------------------*
*& Report ZJOI_TEST
*&
*&---------------------------------------------------------------------*
REPORT zjoi_test.
TABLES mara.
PARAMETER p_cb AS CHECKBOX USER-COMMAND uc1.
SELECTION-SCREEN COMMENT
PARAMETER p_test(10).
SELECT-OPTIONS: s_test FOR mara-matnr ,
s_matnr FOR mara-matnr .
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
PERFORM mod_sel_text USING sy-repid 'P' 'P_CB' '改变下面字段的描述'.
IF p_cb = 'X'.
PERFORM mod_sel_text USING sy-repid 'P' 'P_TEST' '我是Parameter,由代码控制'.
PERFORM mod_sel_text USING sy-repid 'S' 'S_TEST' '我是Select-option,由代码控制'.
ELSE.
PERFORM mod_sel_text USING sy-repid 'P' 'P_TEST' 'P_TEST'.
PERFORM mod_sel_text USING sy-repid 'S' 'S_TEST' 'P_TEST'.
ENDIF.
*&---------------------------------------------------------------------*
*& FORM MOD_SEL_TEXT
*&---------------------------------------------------------------------*
FORM mod_sel_text USING p_repid "the name of the current program
kind
parameter
text .
DATA sel TYPE rsseltexts OCCURS 1 WITH HEADER LINE.
REFRESH sel.
sel-name = parameter.
sel-kind = kind.
sel-text = text.
APPEND sel.
CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
EXPORTING
program = p_repid
TABLES
seltexts = sel
EXCEPTIONS
program_not_found = 1
program_cannot_be_generated = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "MOD_SEL_TEXT