写完后如何用f12离开程序

时间:2018-10-09 12:52:04

标签: abap

一旦我离开ABAP的选择屏幕,例如通过写:如何重写取消按钮的行为?在下面的缩短代码中,每次单击执行然后取消时,我都回到选择屏幕:(而不是这种行为,我想在单击写入输出时完全离开程序红色按钮。

    PARAMETERS p_output AS CHECKBOX DEFAULT ' '.

    SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK such WITH FRAME TITLE text-001.
    "...
    SELECTION-SCREEN END OF BLOCK such.
    SELECTION-SCREEN END OF SCREEN 101.

    SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK such2 WITH FRAME TITLE text-002.
    "...
    SELECTION-SCREEN END OF BLOCK such2.
    SELECTION-SCREEN END OF SCREEN 102.


    SELECTION-SCREEN BEGIN OF TABBED BLOCK searchtab FOR 20 LINES.
    SELECTION-SCREEN TAB (15) expert USER-COMMAND ucomm1
    DEFAULT SCREEN 101.
    SELECTION-SCREEN TAB (17) common USER-COMMAND ucomm2
    DEFAULT SCREEN 102.
    SELECTION-SCREEN END OF BLOCK searchtab.

    INITIALIZATION.
      expert = text-001.
      common = text-002.
      searchtab-prog = sy-repid.
      searchtab-dynnr = 101.
      searchtab-activetab = 'EXPERT_SEARCH'.

      "...
       AT SELECTION-SCREEN ON EXIT-COMMAND.

      CASE sy-dynnr.
        WHEN 1000."main screen number
          CASE sy-ucomm.
            WHEN 'ECAN'.
               LEAVE PROGRAM.
            WHEN 'DBAC' OR 'ENDE'. "execute go back
               LEAVE TO SCREEN 1000." SELECTION-SCREEN 1000.
            WHEN 'UCOMM1'.
               searchtab-dynnr = 101."subscreen number 1
               searchtab-activetab = 'EXPERT'.
            WHEN 'UCOMM2'.
              searchtab-dynnr = 102."subscreen number 2
              searchtab-activetab = 'COMMON'.
            ENDCASE.
        WHEN Others.
            CASE sy-ucomm.
               WHEN 'ECAN'.
              LEAVE PROGRAM.
             WHEN 'DBAC' OR 'ENDE'. "execute go back
                LEAVE TO SCREEN 1000." SELECTION-SCREEN 1000.
              ENDCASE.
        ENDCASE.

        START-OF-SELECTION.
        PERFORM say_hello.

     FORM say_hello .
        WRITE: 'from the write output screen I want to navigate by Cancel button or key f12', 
       'not back to selection screen but leave the program entirely.'.
      ENDFORM.                    " SAY_HELLO

1 个答案:

答案 0 :(得分:1)

这是有效的方法,不是很好。

  1. 将GUI状态INLI从程序SAPMSSY0复制到您自己的程序
  2. 更改“取消”按钮的“确定”代码。要使用示例代码,请将其更改为ECAN。还要在“编辑”菜单中将其更改为完整
  3. 作为START-OF-SELECTION使用中的第一个命令 SET PF-STATUS 'INLI'.这是假设您使用相同的名称
  4. AT SELECTION-SCREEN更改为AT USER-COMMAND
  5. 激活,测试并惊讶

之所以起作用,是因为它删除了列表的标准行为,并用您自己的行为替换了它,仅针对您的取消按钮。在不更改OK代码以取消的情况下,标准的SAP代码将接管您,并且您无法控制行为。