在拆分器容器中显示呼叫交易屏幕

时间:2019-07-07 10:37:12

标签: sap abap docking splitter

我有一个程序,该程序显示具有两列的拆分器容器:

  • 左侧显示一个控制树(可以)

  • 右侧应显示一个自定义的TCode(不确定如何执行此操作)

在双击树节点时,它调用一个事务,该事务打开一个屏幕,但在新窗口中打开。

如何在右侧窗口中打开屏幕?

最小的可复制示例:

  • 通过SE93创建交易代码 ZCALL_ZPRG1 ,以便它调用程序ZPRG1
  • 创建程序 ZPRG1 (最小化屏幕):
REPORT zprg1.
PARAMETERS test AS CHECKBOX.
  • 创建程序 ZPRG2 (拆分器和树):
    REPORT zprg2.
    CLASS lcl_app DEFINITION.
      PUBLIC SECTION.
        METHODS:
          pbo,
          on_node_double_click FOR EVENT node_double_click OF cl_gui_simple_tree.
        DATA:
          tree     TYPE REF TO cl_gui_simple_tree,
          itab     TYPE TABLE OF mtreesnode,
          splitter TYPE REF TO cl_gui_splitter_container.
    ENDCLASS.
    CLASS lcl_app IMPLEMENTATION.
      METHOD pbo.
        CHECK tree IS NOT BOUND.
        CREATE OBJECT splitter
          EXPORTING
            parent  = cl_gui_container=>screen0
            rows    = 1
            columns = 2.
        itab = VALUE #(
        ( node_key = '1'
          text     = 'Double-click me' ) ).
        CREATE OBJECT tree
          EXPORTING
            parent              = splitter->get_container( row = 1 column = 1 )
            node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single.
        tree->add_nodes(
              table_structure_name = 'MTREESNODE'
              node_table           = itab ).
        SET HANDLER on_node_double_click FOR tree.
        DATA events TYPE cntl_simple_events.
        CALL METHOD tree->set_registered_events
          EXPORTING
            events = VALUE #( ( eventid = tree->eventid_node_double_click ) )
          EXCEPTIONS
            OTHERS = 4.
      ENDMETHOD.
      METHOD on_node_double_click.
        CALL TRANSACTION 'ZCALL_ZPRG1'.
      ENDMETHOD.
    ENDCLASS.

    DATA: app TYPE REF TO lcl_app.

    PARAMETERS dummy.

    INITIALIZATION.
      CREATE OBJECT app.

    AT SELECTION-SCREEN OUTPUT.
      app->pbo( ).

    AT SELECTION-SCREEN ON EXIT-COMMAND.
      app->splitter->free( ).
  • 运行ZPRG2
  • 双击树节点

1 个答案:

答案 0 :(得分:0)

在SAP GUI中,可以通过以下方式将dynpro技术的屏幕和GUI controlsSAP Control Framework的屏幕混合在一起:

  • 屏幕和Docking Containers;这些容器可以显示在屏幕的四个侧面中的任何一个
    • 可以在这些容器中放置GUI控件(包括拆分器容器)
  • 包含所谓的Custom Container区域的屏幕,可以在其中放置GUI控件(包括拆分器容器)
  • 弹出窗口可以显示在任何dynpro屏幕或GUI控件上;这些弹出窗口可能还包含任何(其他)dynpro屏幕或GUI控件;它们与下面的屏幕完全独立。弹出窗口也可能显示在弹出窗口上。

无法以任何方式将dynpro屏幕嵌入GUI控件(包括容器)中。

因此,对于您而言,唯一的解决方案是在dynpro屏幕左侧使用停靠容器。但是仅允许显示dynpro屏幕的程序“添加”停靠容器(即,不能使用CALL TRANSACTIONSUBMIT)。

因此,ZPRG2必须同时处理GUI控件和dynpro屏幕。您有两种选择来处理dynpro屏幕:

  1. ZPRG2处理(一切由ZPRG2完成,您不需要ZPRG1)
  2. 或者您仅在ZPRG2的dynpro屏幕内定义一个subscreen area,并包括ZPRG1的子屏幕,该子屏幕处理该子屏幕的所有初始化和交互。

推荐第二种解决方案,因为它允许Separation Of Concerns"

下面的代码是演示其工作方式的最小示例,它使您可以调试和更好地理解;有太多事情需要解释,我更愿意让您在评论中提出问题(或新问题);请注意,不建议使用以下许多算法,语句和窍门,我之所以使用它们只是因为它们要短得多。您最终将获得比此程序复杂得多的程序。

  • 程序 ZPRG1 (右侧,显示/隐藏UI元素以对左侧双击进行反应):
REPORT zprg1.
DATA display TYPE abap_bool VALUE abap_false.

SELECTION-SCREEN BEGIN OF SCREEN 0100 AS SUBSCREEN.
PARAMETERS test AS CHECKBOX.
SELECTION-SCREEN END OF SCREEN 0100.

AT SELECTION-SCREEN OUTPUT.
  IF display = abap_false.
    LOOP AT SCREEN.
      screen-active = '0'.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

FORM toggle_display.
  IF display = abap_false.
    display = abap_true.
  ELSE.
    display = abap_false.
  ENDIF.
ENDFORM.
  • 程序 ZPRG2 (左侧树+右侧子屏幕区域的处理,包括ZPRG1屏幕):
REPORT zprg2.
DATA okcode TYPE syucomm. " global variable for dynpro 0200 "OKCODE" element

CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    METHODS:
      pbo,
      pai,
      on_node_double_click FOR EVENT node_double_click OF cl_gui_simple_tree.
    DATA:
      tree    TYPE REF TO cl_gui_simple_tree,
      itab    TYPE TABLE OF mtreesnode,
      docking TYPE REF TO cl_gui_docking_container.
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
  METHOD pbo.
    SET PF-STATUS space. " <=== trick to activate buttons in the system toolbar
    CHECK tree IS NOT BOUND.
    CREATE OBJECT docking
      EXPORTING
        repid     = sy-repid
        dynnr     = sy-dynnr
        side      = docking->dock_at_left
        extension = 400    " pixels
      EXCEPTIONS
        OTHERS    = 6.
    itab = VALUE #(
        ( node_key = '1'
          text     = 'Double-click me' ) ).
    CREATE OBJECT tree
      EXPORTING
        parent              = docking
        node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single.
    tree->add_nodes(
          table_structure_name = 'MTREESNODE'
          node_table           = itab ).
    SET HANDLER on_node_double_click FOR tree.
    DATA events TYPE cntl_simple_events.
    CALL METHOD tree->set_registered_events
      EXPORTING
        events = VALUE #( ( eventid = tree->eventid_node_double_click
                            appl_event = 'X' ) ) " <=== to trigger the PAI
      EXCEPTIONS
        OTHERS = 4.
  ENDMETHOD.
  METHOD on_node_double_click.
    PERFORM toggle_display IN PROGRAM zprg1.
  ENDMETHOD.
  METHOD pai.
    CASE okcode.
      WHEN 'BACK' OR 'RW' OR '%EX'. " one of the exit buttons in system toolbar
        docking->free( ). " free container and inner controls
        SET SCREEN 0. " to return after the current CALL SCREEN
    ENDCASE.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  DATA: app TYPE REF TO lcl_app.

  CREATE OBJECT app.
  CALL SCREEN 200.

MODULE status_0200 OUTPUT.
  app->pbo( ).
ENDMODULE.

MODULE user_command_0200 INPUT.
  app->pai( ).
ENDMODULE.
    程序 ZPRG2
  • Dynpro 0200
    • 布局中包含一个名为 SUBAREA 的巨大子屏幕区域,并且为 OKCODE 元素分配了名称 OKCODE < / strong>(映射到具有相同名称的ZPRG2的全局变量)
    • 流逻辑包含以下代码:
PROCESS BEFORE OUTPUT.
  MODULE status_0200.
  CALL SUBSCREEN subarea INCLUDING 'ZPRG1' '0100'.

PROCESS AFTER INPUT.
  CALL SUBSCREEN subarea.
  MODULE user_command_0200.