[选择画面]根据不同的radion button显示不同的选择条件实例详解编程语言

选择画面中有两个radio button,点击不同的radio button,显示不同的选择条件,并且做必输项检查,如下:

选择download,显示plant和sales Document两个条件

IT虾米网

选择Upload,显示File name,

IT虾米网

实现代码,

注意:屏幕字段必输属性设置时,要赋值2(screen-required ‘2’.),这样仅仅是外观显示有勾,当触发单选按钮的USER-COMMAND sel时,不触发系统的必输项检查。

REQUIRED各个值含义如下:

REQUIRED:控制文本框、下拉列表屏幕元素的必输性,使用此属性后会忽略OBLIGATORY选项。取值如下:

0:不必输,框中前面也没有钩
1:必输,框中前面有钩,系统会自动检验是否已输入,相当于OBLIGATORY选项
2:不必输,但框中前面有钩,系统不会检查是否已输入,此时需要手动检验

REPORT ztest_radiobutton. 
DATA:g_werks TYPE vbap-werks, 
g_vbeln TYPE vbak-vbeln. 
DATA:g_field(11) TYPE c. 
SELECTION-SCREEN  BEGIN  OF  BLOCK  blk1 WITH  FRAME  TITLE  text-001 . 
PARAMETERS: r_down  TYPE c RADIOBUTTON GROUP c1 USER-COMMAND sel DEFAULT  'X'.   "download 
PARAMETERS: r_upld TYPE c RADIOBUTTON GROUP c1.   "upload 
SELECTION-SCREEN  END    OF  BLOCK  blk1. 
* download condition 
SELECTION-SCREEN  BEGIN  OF  BLOCK  blk2 WITH  FRAME  TITLE  text-002 . 
SELECT-OPTIONS: s_werks FOR g_werks MODIF ID m1 NO INTERVALS.  "plant 
SELECT-OPTIONS: s_vbeln FOR g_vbeln MODIF ID m1.               "sales order 
SELECTION-SCREEN  END    OF  BLOCK  blk2. 
* upload condition 
SELECTION-SCREEN  BEGIN  OF  BLOCK  blk3 WITH  FRAME  TITLE  text-002 . 
PARAMETERS p_file TYPE rlgrap-filename MODIF ID m2. 
SELECTION-SCREEN  END    OF  BLOCK  blk3. 
AT SELECTION-SCREEN OUTPUT. 
* set screen fields attributes 
PERFORM frm_screen_output. 
AT SELECTION-SCREEN. 
* check mandatory input fields 
PERFORM frm_check_input. 
*&---------------------------------------------------------------------* 
*&      Form  FRM_SCREEN_OUTPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM frm_screen_output . 
LOOP AT SCREEN . 
CASE screen-group1. 
WHEN 'M1' . 
IF r_down =  'X' . 
screen-active = 1 . 
IF screen-name = 'S_WERKS-LOW'  OR "PLANT 
screen-name = 'S_VBELN-LOW' . 
screen-required = '2'.  "2-显示为必输项,但是系统不做检查,需要自己写检查逻辑 
ENDIF. 
ELSE . 
screen-active = 0 . 
ENDIF . 
WHEN 'M2' . 
IF r_upld = 'X' . 
screen-active = 1 . 
screen-required = '2'. 
ELSE . 
screen-active = 0 . 
ENDIF . 
ENDCASE . 
MODIFY SCREEN . 
ENDLOOP . 
* 设定光标 
CASE ''. 
WHEN s_werks-low. 
SET CURSOR FIELD 'S_WERKS-LOW'. 
WHEN s_vbeln-low. 
SET CURSOR FIELD 'S_VBELN-LOW'. 
ENDCASE. 
ENDFORM. 
*&---------------------------------------------------------------------* 
*&      Form  FRM_CHECK_INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM frm_check_input . 
IF sy-ucomm <> 'SEL' AND 
sy-ucomm <> '%011'. 
IF r_down = 'X'.  "download 
IF s_werks-low IS INITIAL. 
MESSAGE ID '00' TYPE 'S' NUMBER '55' DISPLAY LIKE 'E'. 
STOP. 
ENDIF. 
IF s_vbeln-low IS INITIAL. 
MESSAGE ID '00' TYPE 'S' NUMBER '55' DISPLAY LIKE 'E'. 
STOP. 
ENDIF. 
ELSE. 
IF p_file IS INITIAL.  "upload 
MESSAGE ID '00' TYPE 'S' NUMBER '55' DISPLAY LIKE 'E'. 
STOP. 
ENDIF. 
ENDIF. 
ENDIF. 
ENDFORM.

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/19208.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论