[选择画面]根据不同的radion button显示不同的选择条件实例

本文介绍在ABAP中如何使用radiobutton控制不同条件的选择,并通过设置必输项检查来验证用户输入。文章详细展示了如何根据不同选择显示特定的输入条件,如download条件下显示plant和salesDocument,而Upload条件下仅显示Filename。同时,提供了具体的ABAP代码示例,解释了如何设置屏幕字段的必输属性,以实现自定义的输入验证。
摘要由CSDN通过智能技术生成

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

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

2017-02-13_10-20-47

<img class="alignnone size-full wp-image-2911" src="http://www.baidusap.com/wp-content/uploads/2017-02-13_10-20-47.png" alt="2017-02-13_10-20-47" width="732" height="284" />

选择Upload,显示File name,

2017-02-13_10-21-21

<img class="alignnone size-full wp-image-2912" src="https://i-blog.csdnimg.cn/blog_migrate/a139ecbfb1e48daa29c3ba910bd32a7e.png" alt="2017-02-13_10-21-21" width="695" height="246" />

实现代码,

注意:屏幕字段必输属性设置时,要赋值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://www.cnblogs.com/datie/p/11435878.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值