1

我的要求是在选择屏幕中有两个单选按钮。执行后,应基于单选按钮调用报告。

单击后退按钮时不执行,它仍然打开report1。按 F3 键或返回键与预期不同。

SELECTION-SCREEN BEGIN OF SCREEN 100 TITLE title.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
PARAMETER: ZREP_2 RADIOBUTTON GROUP rad  DEFAULT 'X' USER-COMMAND frad,
           ZREP_3 RADIOBUTTON GROUP rad .                            ##SEL_WRONG
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 100.
 CALL SELECTION-SCREEN '100'.

AT SELECTION-SCREEN OUTPUT.

* Toggle the selection screens based on radio buttons
  LOOP AT SCREEN.
    IF zrep_2 = 'X' AND screen-group1 = 'SC2'.
      PERFORM modify_screen. "Calling subroutine
    ELSEIF zrep_3 = 'X' AND screen-group1 = 'SC1'.
      PERFORM modify_screen. "Calling subroutine
    ENDIF.
  ENDLOOP.

FORM modify_screen.
  screen-active = 0.
  MODIFY SCREEN.
ENDFORM.

START-OF-SELECTION.
  CASE 'X'.
    WHEN zrep_2.

      SUBMIT zpp_scrap_report AND RETURN.

      CALL SELECTION-SCREEN 100.
    WHEN  zrep_3.

      SUBMIT zpp_scrap_report_material_doc AND RETURN.
      CALL SELECTION-SCREEN 100.

  ENDCASE.
4

1 回答 1

0

正如 Sandra 所说,有几种方法可以解决此问题,您应该彻底阅读有关选择屏幕事件的帮助:它们中的哪些是PAI,什么是PBO以及它们之间的区别。

在selscreen帮助中你可能会找到一个关于功能码的概念,当你在PAI选择屏幕事件中封装一些逻辑时,你需要经常检查功能码。在你的情况下,你必须检查CRET你有自定义的 selscreen,对于标准的,它是ONLI.

实际上,您可以通过显式返回屏幕LEAVE TO

SELECTION-SCREEN BEGIN OF SCREEN 100 TITLE title.
...
SELECTION-SCREEN END OF SCREEN 100.

AT SELECTION-SCREEN.
  CHECK sy-ucomm = 'CRET'.
  CASE 'X'.
    WHEN zrep_2.
      SUBMIT zpp_scrap_report AND RETURN.
      LEAVE TO SCREEN 100.
    WHEN  zrep_3.
      SUBMIT zpp_scrap_report_material_doc AND RETURN.
      LEAVE TO SCREEN 100.
   ENDCASE.

FORM modify_screen.
 screen-active = 0.
 MODIFY SCREEN.
ENDFORM.   

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF zrep_2 = 'X' AND screen-group1 = 'SC2'.
      PERFORM modify_screen.
    ELSEIF zrep_3 = 'X' AND screen-group1 = 'SC1'.
      PERFORM modify_screen.
    ENDIF.
  ENDLOOP.

START-OF-SELECTION.
  CALL SELECTION-SCREEN '100'.

为了像你一样进行屏幕修改,使用 PBO 事件更合乎逻辑AT SELECTION-SCREEN OUTPUT

这种方式很简单,但更漂亮的是完全摆脱了自定义选择屏幕,在这种情况下,您不需要任何 LEAVE TO 也不需要显式 START-OF-SELECTION

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
...

AT SELECTION-SCREEN.
  CHECK sy-ucomm = 'ONLI'.
      CASE 'X'.
    WHEN zrep_2.
      SUBMIT zpp_scrap_report AND RETURN.
    WHEN  zrep_3.
      SUBMIT zpp_scrap_report_material_doc AND RETURN.
  ENDCASE.

AT SELECTION-SCREEN OUTPUT.
 LOOP AT SCREEN.
  ...
  ENDIF.
ENDLOOP.
于 2022-02-03T16:34:42.760 回答