关于选择屏幕的一些常用功能例子,
一、选择屏幕上按选择内容设置元素的可用性,当用户选择 RADIOBUTTON时,依据选择的不同设置选择屏幕上不同的条件可见性。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1. PARAMETERS: PAR1 RADIOBUTTON GROUP RA1 USER-COMMAND SCR DEFAULT 'X'. SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: S_WERKS1 FOR MARC-WERKS MODIF ID ABC . *SELECTION-SCREEN COMMENT 52(50) NAME1 MODIF ID ABC. SELECT-OPTIONS: S_MATNR1 FOR MARC-MATNR MODIF ID ABC. *SELECTION-SCREEN COMMENT 52(50) MAKTX1 MODIF ID ABC. SELECTION-SCREEN END OF BLOCK B1. PARAMETERS: PAR2 RADIOBUTTON GROUP RA1. SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002. SELECT-OPTIONS: S_ASORT2 FOR WRS1-ASORT MODIF ID DEF . *SELECTION-SCREEN COMMENT 52(50) NAME2 MODIF ID DEF. SELECT-OPTIONS: S_MATNR2 FOR MARC-MATNR MODIF ID DEF. *SELECTION-SCREEN COMMENT 52(50) MAKTX2 MODIF ID DEF. SELECTION-SCREEN END OF BLOCK B2. PARAMETERS: PAR3 RADIOBUTTON GROUP RA1. SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003. SELECT-OPTIONS: S_MATNR3 FOR MARC-MATNR MODIF ID HIJ. *SELECTION-SCREEN COMMENT 52(50) MAKTX3 MODIF ID HIJ. SELECTION-SCREEN END OF BLOCK B3. PARAMETERS: P_CHARG AS CHECKBOX . *SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004. *PARAMETERS: P_MATNR4 TYPE MCHA-MATNR MODIF ID KLM. *SELECTION-SCREEN COMMENT 52(50) MAKTX4 MODIF ID KLM. *SELECT-OPTIONS: S_CHARG FOR MCHA-CHARG MODIF ID KLM NO-EXTENSION . *SELECTION-SCREEN END OF BLOCK B4. SELECTION-SCREEN END OF BLOCK BL1. AT SELECTION-SCREEN OUTPUT. * COMM1 = '1'. LOOP AT SCREEN. IF PAR1 = 'X'. IF SCREEN-GROUP1 = 'ABC'. SCREEN-ACTIVE = '1'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'DEF' . SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'HIJ'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'KLM'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ENDIF. ELSEIF PAR2 = 'X'. IF SCREEN-GROUP1 = 'ABC'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'DEF' . SCREEN-ACTIVE = '1'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'HIJ'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'KLM'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ENDIF. ELSEIF PAR3 = 'X' . IF SCREEN-GROUP1 = 'ABC'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'DEF' . SCREEN-ACTIVE = '0'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'HIJ'. SCREEN-ACTIVE = '1'. MODIFY SCREEN. ELSEIF SCREEN-GROUP1 = 'KLM'. SCREEN-ACTIVE = '0'. MODIFY SCREEN. ENDIF. ENDIF. ENDLOOP. |
二、选择屏自定义搜索帮助(SELECT生成帮助)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR SE_ZNO.
PERFORM ZNO_GET.
FORM ZNO_GET .
DATA:ll_rowcount TYPE INT2.
DATA: BEGIN OF GT_ZNO OCCURS 0 ,
ZMM062NO TYPE ZMM062NO,
CREATEDATA TYPE ZCREATEDATA,
CREATEUSER TYPE ZCREATEUSER,
END OF GT_ZNO .
SELECT DISTINCT ZMM062NO CREATEDATA CREATEUSER
INTO TABLE GT_ZNO
FROM ZTMM062
.
ll_rowcount = lines( GT_ZNO ) .
IF ll_rowcount > 0. “多个他们,显示帮助
CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
retfield = ‘ZMM062NO’ “大写,可选值内表的字段名
value_org = ‘S’ “就写’S’
dynpprog = SY-REPID “返回的输入框所在的main program
dynpnr = SY-DYNNR “返回的输入框所在屏幕
dynprofield = ‘SE_ZNO’ “返回的输入框名
TABLES
value_tab = GT_ZNO “可选值的内表,此值在PBO中读取
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
else. ” 没找到仓位,(WM进货记录)
SE_ZNO = ”.
* MESSAGE s072(zhxmsg) .
ENDIF.
ENDFORM. ” ZNO_GET
三、选择屏的文件名选择参数。
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM FILENAME_GET.
FORM FILENAME_GET .
CALL FUNCTION ‘WS_FILENAME_GET’
EXPORTING
DEF_FILENAME = P_FILE
DEF_PATH = ‘*.TXT’
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
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. ” FILENAME_GET
四、在选择屏上加一个功能按钮
SELECTION-SCREEN: FUNCTION KEY 5.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
parameters: P_TYPE LIKE ZTMM062_CON-ZMMTYPE DEFAULT ‘A001’ NO-DISPLAY ,”操作类型
P_NO LIKE ZSMM062-ZMM062NO OBLIGATORY MEMORY ID 62NO, “批次
P_FILE LIKE
RLGRAP-FILENAME OBLIGATORY .
* DEFAULT ‘E:\u24037?作\u24320?发需求\u25209?量导入商品主数据模板\u21830?品主数据1.xls’.
* parameters: P_NEW AS CHECKBOX DEFAULT ‘X’ .
SELECTION-SCREEN ULINE /1(70).
SELECTION-SCREEN COMMENT /1(70) TEXT-001.
SELECTION-SCREEN COMMENT /1(70) TEXT-002.
INITIALIZATION.
sscrfields-functxt_05 = ‘下载EXCEL模板’.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = ‘FC05’.
PERFORM frm_down_excel_template USING g_path
g_formkey
‘ZMM071’
‘.XLS’.
ENDIF.
五、单一输入框,但可用IN查询
SELEct-OPTIONS:S_BUKRS for T001-BUKRS NO-EXTENSION NO INTERVALS OBLIGATORY
MEMORY ID BUK.”可输入多个值
SELEct-OPTIONS:S_BUKRS for T001-BUKRS NO INTERVALS OBLIGATORY
MEMORY ID BUK. “只能输入一个值
六、选择变式,并显示
SELECTION-SCREEN BEGIN OF BLOCK BLOCK2 WITH FRAME TITLE TEXT-002.
*SELECT-OPTIONS: S_WERKS FOR MCHB-WERKS OBLIGATORY MEMORY ID WER.
PARAMETER: P_VARI TYPE SLIS_VARI.
SELECTION-SCREEN END OF BLOCK BLOCK2.
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
PERFORM F4_FOR_VARIANT USING SY-CPROG P_VARI .
FORM F4_FOR_VARIANT USING P_REPORT P_VARI.
*
DATA: LT_VARIANT LIKE DISVARIANT,
LT_CANCEL(1).
LT_VARIANT-REPORT = P_REPORT.
* CALL FUNCTION ‘REUSE_ALV_VARIANT_F4’
* EXPORTING
* is_variant = lt_variant
* i_save = ‘A’
* IMPORTING
* e_exit = lt_cancel
* es_variant = lt_variant
* EXCEPTIONS
* NOT_FOUND = 1
* PROGRAM_ERROR = 2
* OTHERS = 3
CALL FUNCTION ‘REUSE_ALV_VARIANT_F4’
EXPORTING
IS_VARIANT = LT_VARIANT
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
* IT_DEFAULT_FIELDCAT =
* I_SAVE = ‘ ‘
* I_DISPLAY_VIA_GRID = ‘ ‘
IMPORTING
E_EXIT = LT_CANCEL
ES_VARIANT = LT_VARIANT
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 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.
IF SY-SUBRC 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_VARI = LT_VARIANT-VARIANT.
* GS_VARIANT = LT_VARIANT.
ENDFORM. “f4_for_variant
PERFORM SET_VARIANT USING P_VARI.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = F_REPID
I_CALLBACK_PF_STATUS_SET = ‘SET_PF’
I_CALLBACK_USER_COMMAND = ‘USER_COM’
I_GRID_TITLE = F_TITLE
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = IT_FIELDS
IT_EVENTS = GT_EVENTS[]
IS_VARIANT = GS_VARIANT
TABLES
T_OUTTAB = IT_DATA_I.
FORM SET_VARIANT USING I_VARI TYPE SLIS_VARI.
GS_VARIANT-REPORT = SY-CPROG.
GS_VARIANT-VARIANT = I_VARI .
ENDFORM. ” SET_VARIANT
七、只有显示年月,但要有日期的search help
*需求:只有显示年月,但要有日期的search help
PARAMETERS
_MONTH(6) TYPE c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MONTH.
DATA:l_date TYPE sy-datum.
CALL FUNCTION’F4_DATE’
EXPORTING
date_for_first_month = sy-datum
IMPORTING
select_date = l_date
EXCEPTIONS
calendar_buffer_not_loadable = 1
date_after_range =2
date_before_range =3
date_invalid =4
factory_calendar_not_found = 5
holiday_calendar_not_found = 6
parameter_conflict =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.
P_MONTH = l_date+0(6).