初始画面
点击Data Collapse按钮后,下面的两个字段收起不显示
代码:
REPORT zdemo_016.
TYPE-POOLS icon.
TABLES mara.SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS p_werks TYPE werks_d.
SELECTION-SCREEN END OF BLOCK b1.SELECTION-SCREEN SKIP 1.SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 1(4) but1 USER-COMMAND button1 VISIBLE LENGTH 2.
SELECTION-SCREEN COMMENT 6(20) com1.
SELECTION-SCREEN END OF LINE.SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
SELECT-OPTIONS : s_matnr FOR mara-matnr MODIF ID bl1,s_groes FOR mara-groes MODIF ID bl1.
SELECTION-SCREEN END OF BLOCK b2.INITIALIZATION.
* 初始化expand按钮WRITE icon_data_area_expand AS ICON TO but1.com1 = 'Data Collapse'.AT SELECTION-SCREEN.
* 切换expand和Collapse按钮CASE sy-ucomm.WHEN 'BUTTON1'.IF but1 = '@K1@'.WRITE icon_data_area_collapse AS ICON TO but1.com1 = 'Data Expand'.ELSE.WRITE icon_data_area_expand AS ICON TO but1.com1 = 'Data Collapse'.ENDIF.ENDCASE.AT SELECTION-SCREEN OUTPUT.
* 隐藏group1中的字段LOOP AT SCREEN.IF but1 = '@K2@' AND screen-group1 = 'BL1'.screen-active = 0.MODIFY SCREEN.ENDIF.ENDLOOP.
效果图:
代码:
*&---------------------------------------------------------------------*
*& Report ZDEMO_0251
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdemo_0251.*******************************
*屏幕处理
*******************************
SELECTION-SCREEN BEGIN OF BLOCK selt WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) TEXT-004 FOR FIELD p_d1.
PARAMETERS p_d1(4) TYPE n .
PARAMETERS p_d2 TYPE char2 DEFAULT '1 天'AS LISTBOX VISIBLE LENGTH 5.
PARAMETERS p_d3(4) TYPE n .
PARAMETERS p_d4 TYPE char2 DEFAULT '2 月'AS LISTBOX VISIBLE LENGTH 5.
PARAMETERS p_d5(4) TYPE n .
PARAMETERS p_d6 TYPE char2 DEFAULT '3 年'AS LISTBOX VISIBLE LENGTH 5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) TEXT-003 FOR FIELD p_d1.
PARAMETERS p_d7(4) TYPE n .
PARAMETERS p_d8 TYPE char2 DEFAULT '1 天'AS LISTBOX VISIBLE LENGTH 5.
PARAMETERS p_d9(4) TYPE n .
PARAMETERS p_d10 TYPE char2 DEFAULT '2 月'AS LISTBOX VISIBLE LENGTH 5.
PARAMETERS p_d11(4) TYPE n.
PARAMETERS p_d12 TYPE char2 DEFAULT '3 年'AS LISTBOX VISIBLE LENGTH 5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK selt.INITIALIZATION.PERFORM frm_list.*&---------------------------------------------------------------------*
*& Form FRM_LIST
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_list ."下拉框定义DATA:vid1 TYPE vrm_id,list1 TYPE vrm_values,value1 LIKE LINE OF list1.REFRESH list1.list1 = VALUE #( ( key = '1' text = '年' )( key = '2' text = '月' )( key = '3' text = '天' ) ).**调用下拉框赋值函数CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D2' "对应选择屏幕上定义的名称values = list1.CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D4' "对应选择屏幕上定义的名称values = list1.CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D6' "对应选择屏幕上定义的名称values = list1.CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D8' "对应选择屏幕上定义的名称values = list1.CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D12' "对应选择屏幕上定义的名称values = list1.CALL FUNCTION 'VRM_SET_VALUES'EXPORTINGid = 'P_D10' "对应选择屏幕上定义的名称values = list1.
ENDFORM.
效果图:
代码:
*&---------------------------------------------------------------------*
*& Report ZDEMO_0251
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdemo_0251.*******************************
*屏幕处理
*******************************
TABLES: mseg,aufk,ekko.SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_p1 TYPE c RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND flag,p_p2 TYPE c RADIOBUTTON GROUP g1.SELECTION-SCREEN SKIP 1.PARAMETERS: p_werks TYPE marc-werks DEFAULT '3001' .
SELECT-OPTIONS: s_lgort FOR mseg-lgort MODIF ID m1,
s_matnr FOR mseg-matnr,
s_aufnr FOR aufk-aufnr MODIF ID m1,
s_ebeln FOR ekko-ebeln MODIF ID m2,
s_mblnr FOR mseg-mblnr,
s_bwart FOR mseg-bwart.
SELECTION-SCREEN END OF BLOCK b1.AT SELECTION-SCREEN OUTPUT.LOOP AT SCREEN.CASE screen-group1.WHEN 'M1'.IF p_p1 = 'X'.screen-active = '0'.ELSE.screen-active = '1'.ENDIF.WHEN 'M2'.IF p_p1 = 'X'.screen-active = '1'.ELSE.screen-active = '0'.ENDIF.WHEN OTHERS.ENDCASE.MODIFY SCREEN.ENDLOOP.
效果图:
代码:
TABLES:MARA.
PARAMETER P_A TYPE C LENGTH 10.
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.INITIALIZATION.
"变量参数:%_ + 屏幕选择字段变量 + _%_APP_%-TEXT%_P_A_%_APP_%-TEXT = '短文本'.%_S_MATNR_%_APP_%-TEXT = '对于屏幕字段备注测试的长文本'.
效果图:
代码:
PARAMETER p_a TYPE c LENGTH 10.INITIALIZATION.
p_a = '12'.
在选择屏幕菜单栏中添加按钮,big响应对应的事件
*&---------------------------------------------------------------------*
*& Report ZDEMO_050
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdemo_050.
TABLES: sscrfields."自定义按钮
SELECTION-SCREEN: FUNCTION KEY 1,FUNCTION KEY 2,FUNCTION KEY 3.
PARAMETERS: p_1 TYPE c. " 选择屏幕INITIALIZATION."初始化屏幕PERFORM frm_init_sel_screen.FORM frm_init_sel_screen .DATA: lv_functxt TYPE smp_dyntxt.DATA: lt_exclude TYPE TABLE OF sy-ucomm.lv_functxt-icon_id = icon_change.lv_functxt-icon_text = '手工维护'.sscrfields-functxt_01 = lv_functxt.lv_functxt-icon_id = icon_xls.lv_functxt-icon_text = '数据导入'.sscrfields-functxt_02 = lv_functxt.lv_functxt-icon_id = icon_xxl.lv_functxt-icon_text = '导入模板下载'.sscrfields-functxt_03 = lv_functxt.ENDFORM.AT SELECTION-SCREEN."响应选择屏幕的按钮功能PERFORM frm_excue_button.FORM frm_excue_button .CASE sscrfields-ucomm.WHEN 'FC01'.p_1 = 1 + ''.MESSAGE p_1 TYPE 'I'.WHEN 'FC02'.p_1 = 2 + ''.MESSAGE p_1 TYPE 'I'.WHEN 'FC03'.p_1 = 3 + ''.MESSAGE p_1 TYPE 'I'.WHEN OTHERS.ENDCASE.
ENDFORM.
执行结果:
在选择屏幕下方的内容中添加按钮并执行对应的逻辑
*&---------------------------------------------------------------------*
*& Report ZDEMO_050
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdemo_050.
data p_1 TYPE string. " 选择屏幕
SELECTION-SCREEN BEGIN OF BLOCK b1.SELECTION-SCREEN SKIP 1. "屏幕换行
SELECTION-SCREEN PUSHBUTTON 30(10) TEXT-001 USER-COMMAND pb1. "查询按钮
SELECTION-SCREEN SKIP 1. "屏幕换行
SELECTION-SCREEN PUSHBUTTON 30(10) TEXT-002 USER-COMMAND pb2. "发送按钮SELECTION-SCREEN END OF BLOCK b1.INITIALIZATION.AT SELECTION-SCREEN OUTPUT.START-OF-SELECTION.AT SELECTION-SCREEN.CASE sy-ucomm.WHEN 'PB1'.p_1 = '按钮1'.MESSAGE p_1 TYPE 'I'.WHEN 'PB2'.p_1 = '按钮2'.MESSAGE p_1 TYPE 'I'.ENDCASE.END-OF-SELECTION.
执行结果
效果图:
代码:
*&---------------------------------------------------------------------*
*& Report ZDEMO03
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdemo03.PARAMETERS: p_spmon TYPE mcs1-spmon DEFAULT sy-datum+0(6) OBLIGATORY. " 导入年月AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.PERFORM frm_spmon_f4.FORM frm_spmon_f4.DATA: BEGIN OF ls_dynpfields.INCLUDE STRUCTURE dynpread.DATA: END OF ls_dynpfields,lt_dynpfields LIKE TABLE OF ls_dynpfields.DATA: lv_returncode LIKE sy-subrc,lv_monat LIKE isellist-month,lv_hlp_repid LIKE sy-repid.GET CURSOR FIELD ls_dynpfields-fieldname.APPEND ls_dynpfields TO lt_dynpfields.lv_hlp_repid = sy-repid.DO 2 TIMES.CALL FUNCTION 'DYNP_VALUES_READ'EXPORTINGdyname = lv_hlp_repiddynumb = sy-dynnrTABLESdynpfields = lt_dynpfieldsEXCEPTIONSinvalid_abapworkarea = 01invalid_dynprofield = 02invalid_dynproname = 03invalid_dynpronummer = 04invalid_request = 05no_fielddescription = 06undefind_error = 07.IF sy-subrc = 3.lv_hlp_repid = 'SAPLALDB'.ELSE.READ TABLE lt_dynpfields INTO ls_dynpfields INDEX 1.TRANSLATE ls_dynpfields-fieldvalue USING '_ '.EXIT.ENDIF.ENDDO.IF sy-subrc = 0.CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'EXPORTINGinput = ls_dynpfields-fieldvalueIMPORTINGoutput = lv_monatEXCEPTIONSerror_message = 1.IF lv_monat IS INITIAL.lv_monat = sy-datlo(6).ENDIF.CALL FUNCTION 'POPUP_TO_SELECT_MONTH'EXPORTINGactual_month = lv_monatIMPORTINGselected_month = lv_monatreturn_code = lv_returncodeEXCEPTIONSfactory_calendar_not_found = 01holiday_calendar_not_found = 02month_not_found = 03.IF sy-subrc = 0 AND lv_returncode = 0.CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'EXPORTINGinput = lv_monatIMPORTINGoutput = ls_dynpfields-fieldvalue.COLLECT ls_dynpfields INTO lt_dynpfields.CALL FUNCTION 'DYNP_VALUES_UPDATE'EXPORTINGdyname = lv_hlp_repiddynumb = sy-dynnrTABLESdynpfields = lt_dynpfieldsEXCEPTIONSinvalid_abapworkarea = 01invalid_dynprofield = 02invalid_dynproname = 03invalid_dynpronummer = 04invalid_request = 05no_fielddescription = 06undefind_error = 07.ENDIF.ENDIF.ENDFORM.
效果图:
代码:
DATA: l_code LIKE sy-subrc.
DATA:lv_ny TYPE ISELLIST-MONTH . "这个定义自己要注意下SELECTION-SCREEN BEGIN OF BLOCK bl01 WITH FRAME TITLE TEXT-001.SELECT-OPTIONS: s_ny FOR lv_ny OBLIGATORY."年月
SELECTION-SCREEN END OF BLOCK bl01.INITIALIZATION .AT SELECTION-SCREEN OUTPUT .lv_ny = sy-datum+0(6).AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ny-low. "对SELECT-OPTIONS第一个值进行搜索帮助CALL FUNCTION 'POPUP_TO_SELECT_MONTH'EXPORTINGactual_month = lv_ny "默认值:当前年月language = sy-langustart_column = 8start_row = 5IMPORTINGselected_month = s_ny-low "选择完成之后赋值给S_NY的low值return_code = l_codeEXCEPTIONSfactory_calendar_not_found = 1holiday_calendar_not_found = 2month_not_found = 3OTHERS = 4.AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ny-high.CALL FUNCTION 'POPUP_TO_SELECT_MONTH'EXPORTINGactual_month = lv_nylanguage = sy-langustart_column = 8start_row = 5IMPORTINGselected_month = s_ny-highreturn_code = l_codeEXCEPTIONSfactory_calendar_not_found = 1holiday_calendar_not_found = 2month_not_found = 3OTHERS = 4.START-OF-SELECTION.
效果图:
代码:
INITIALIZATION.DATA it_exclude TYPE TABLE OF sy-ucomm."隐藏执行按钮APPEND 'ONLI' TO it_exclude.CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'EXPORTINGp_status = sy-pfkeyTABLESp_exclude = it_exclude.
效果图:
代码:
DATA: gv_str TYPE c.SELECTION-SCREEN BEGIN OF BLOCK bk2 WITH FRAME TITLE t2.PARAMETERS:p_1 AS CHECKBOX USER-COMMAND flg1 MODIF ID m3, "p_2 AS CHECKBOX USER-COMMAND flg1 MODIF ID m4. "
SELECTION-SCREEN END OF BLOCK bk2.AT SELECTION-SCREEN OUTPUT.
*只能选择一项IF p_1 EQ 'X'.IF gv_str IS INITIAL.CLEAR p_2.gv_str = 'X'.ELSE.IF p_2 EQ 'X'.CLEAR p_1.ENDIF.CLEAR gv_str.ENDIF.ELSE.IF p_2 EQ 'X'.CLEAR p_1.ENDIF.ENDIF.AT SELECTION-SCREEN.
效果图:
代码:
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:s_werks FOR ekbe-werks,s_lifnr FOR ekko-lifnr,s_matnr FOR ekbe-matnr,s_budat FOR ekbe-budat,s_bsart FOR ekko-bsart,s_ebeln FOR ekbe-ebeln.
PARAMETERS:p_status TYPE char4 AS LISTBOX VISIBLE LENGTH 20 DEFAULT 'A' MODIF ID m3.
PARAMETERS:p_all AS CHECKBOX .
SELECTION-SCREEN SKIP.
PARAMETERS:p_bldat TYPE ekbe-budat .
SELECTION-SCREEN END OF BLOCK b1.
效果图:
代码:
SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME TITLE TEXT-102." 添加物料类型Z005 BY HAND 20221101 BEGIN OF "
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) TEXT-004 FOR FIELD p_mtart.
PARAMETERS:p_mtart TYPE mara-mtart DEFAULT 'Z001'. " ---物料类型默认Z001
PARAMETERS:p_mtart2 TYPE mara-mtart DEFAULT 'Z005'. " ---物料类型默认Z001
SELECTION-SCREEN END OF LINE.
" 添加物料类型Z005 BY HAND 20221101 END OF "SELECTION-SCREEN END OF BLOCK blk01.*&---------------------------------------------------------------------*
*& INITIALIZATION/选择屏幕前初始化 *
*&---------------------------------------------------------------------*
INITIALIZATION.
*&---初始化选择屏幕值
*&---初始化变量*&---------------------------------------------------------------------*
*& at selection-screen/选择屏幕开始 *
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
* //为控件页签单击事件, 选择不同页签显示不同子屏幕.
*定义触发事件*&---------------------------------------------------------------------*
*& at selection-screen output/选择屏幕输出 *
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
*&---数据处理,数据输出(AVL/LIST/WRITE),功能应用LOOP AT SCREEN.IF screen-name = 'P_MTART' OR screen-name = 'P_MTART2'.screen-input = 0.ELSE.screen-input = 1.ENDIF.MODIFY SCREEN.ENDLOOP.
效果图:
代码:
SELECTION-SCREEN BEGIN OF TABBED BLOCK tabb1 FOR 9 LINES.SELECTION-SCREEN TAB (15) TEXT-001 USER-COMMAND ucomm1DEFAULT SCREEN 101.SELECTION-SCREEN TAB (15) TEXT-002 USER-COMMAND ucomm2DEFAULT SCREEN 102.SELECTION-SCREEN TAB (17) TEXT-003 USER-COMMAND ucomm3DEFAULT SCREEN 103.
SELECTION-SCREEN END OF BLOCK tabb1.
SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.PARAMETER: p_matnr TYPE matnr.
SELECTION-SCREEN END OF SCREEN 101.
SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.PARAMETER: p_mlbnr TYPE mblnr.
SELECTION-SCREEN END OF SCREEN 102.
SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN.PARAMETER: p_ebeln TYPE ebeln.
SELECTION-SCREEN END OF SCREEN 103.
代码:
REPORT Z31667_DEMO.
TABLES: mara.
SELECTION-SCREEN BEGIN OF SCREEN 9000 AS WINDOW TITLE l_window.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE l_title.
SELECT-OPTIONS s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 9000.INITIALIZATION.l_window = 'window'.l_title = '选择条件'.START-OF-SELECTION.CALL SELECTION-SCREEN 9000 STARTING AT 10 5 ENDING AT 100 15.
上一篇:pikachu靶场-暴力破解
下一篇:C/C++指针与数组(三)