如何处理后续选择屏幕?

时间:2014-06-09 08:26:04

标签: abap

我尝试做以下事情:向用户显示带有两个按钮的选择屏幕,每个按钮依次打开它自己的选择屏幕,稍后启动一些处理并以某种方式显示结果。

我目前的代码如下:

REPORT ZREP.

TABLES sscrfields.

SELECTION-SCREEN:
    PUSHBUTTON 1(10) text-001 USER-COMMAND b1,
    PUSHBUTTON 15(10) text-001 USER-COMMAND b2.

SELECTION-SCREEN BEGIN OF SCREEN 1100.
    PARAMETERS p_param1 TYPE c.
SELECTION-SCREEN END OF SCREEN 1100.

SELECTION-SCREEN BEGIN OF SCREEN 1200.
    PARAMETERS p_param2 TYPE c.
SELECTION-SCREEN END OF SCREEN 1200.

AT SELECTION-SCREEN.

    CASE sscrfields.
        WHEN 'b1'.
            CALL SELECTION-SCREEN 1100.
        WHEN 'b2'.
            CALL SELECTION-SCREEN 1200.
    ENDCASE.

START-OF-SELECTION.

    " What do I do here?

随后的选择屏幕(1100和1200)在单击相应按钮时打开正常。但是,当我在任何屏幕上按F8时,都不会进行任何处理。相反,初始选择屏幕已打开,START-OF-SELECTION未被触发。

由于我对ABAP很陌生,我认为我的整个方法存在问题,所以如果有人能指出我正确的方向,那将非常感激。

2 个答案:

答案 0 :(得分:4)

作为替代方案,您可以定义一个没有显示区域的选择屏幕。

通过按钮,你可以(de)激活其他区域。

代码示例(可能有点过于复杂,但这是我能够构建的最快结果。):

REPORT  y_test.

PARAMETER:
  p_kunnr LIKE knmt-kunnr MODIF ID all, "maybe with option no-display ?
  p_vkorg LIKE mvke-vkorg,
  p_vtweg LIKE mvke-vtweg.

"Define a push button on selection screen
TABLES sscrfields.
SELECTION-SCREEN FUNCTION KEY 1.

INITIALIZATION.
  sscrfields-functxt_01 = 'Full selection'.

AT SELECTION-SCREEN. "PAI
  CASE sscrfields-ucomm. "pushbutton pressed
    WHEN 'FC01'.
      PERFORM selection_switch_all USING 'SET-SWITCH'.
  ENDCASE.
AT SELECTION-SCREEN OUTPUT.
  PERFORM selection_switch_all USING 'ALL'.


FORM selection_switch_all USING group.
  STATICS: flag_all.
  IF group = 'SET-SWITCH'.
    TRANSLATE flag_all USING ' XX '.
  ENDIF.
*
  IF flag_all = space.
    sscrfields-functxt_01 = 'Full selection'.
    LOOP AT SCREEN.
      IF screen-group1 = group.
        screen-invisible = 1.
        screen-input     = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    sscrfields-functxt_01  = 'Restricted selection'.
    LOOP AT SCREEN.
      IF screen-group1 = group.
        screen-invisible = 0.
        screen-input     = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDFORM. "selection_switch_all.

当你开始它时,你得到:

enter image description here

完整选择后,您将获得:

enter image description here


选择屏幕选项还允许使用ob标签。

这也是一个很好的解决方案。

答案 1 :(得分:1)

the documentation for SELECTION-SCREEN PUSHBUTTON所述,

  

选择屏幕上的按钮主要用于   动态修改选择屏幕而不是控制   该计划

我宁愿用一组单选按钮替换按钮。这使得用户更熟悉处理,并且为您节省了编码的麻烦:

REPORT zfoobar.

PARAMETERS p_b01 RADIOBUTTON GROUP cmd.
PARAMETERS p_b02 RADIOBUTTON GROUP cmd.

SELECTION-SCREEN BEGIN OF SCREEN 1100.
PARAMETERS p_einri TYPE einri OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 1100.

SELECTION-SCREEN BEGIN OF SCREEN 1200.
PARAMETERS p_bukrs TYPE bukrs OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 1200.

START-OF-SELECTION.
  IF p_b01 = abap_true.
    CALL SELECTION-SCREEN 1100.
    IF sy-subrc = 0.
      PERFORM processing_b01.
    ENDIF.
  ELSEIF p_b02 = abap_true.
    CALL SELECTION-SCREEN 1200.
    IF sy-subrc = 0.
      PERFORM processing_b02.
    ENDIF.
  ENDIF.