简体   繁体   English

在拆分容器中显示呼叫事务屏幕

[英]Display call transaction screen in a Splitter-container

I have a program which displays a splitter-container with two columns:我有一个程序,它显示一个带有两列的拆分器容器:

  • Left side displays a control tree (this is OK)左侧显示一个控制树(这是可以的)

  • Right side should displays a custom TCode (not sure how to do this bit)右侧应显示自定义 TCode(不知道如何执行此操作)

On double-click of a tree node, it calls a transaction which opens a screen, but it opens in a new window.双击树节点时,它调用一个事务,打开一个屏幕,但它在一个新窗口中打开。

How to open the screen in the right-side window?如何在右侧窗口中打开屏幕?

Minimal reproducible example:最小可重现示例:

  • Create the transaction code ZCALL_ZPRG1 via SE93 , so that it calls the program ZPRG1通过SE93创建事务代码ZCALL_ZPRG1 ,使其调用程序ZPRG1
  • Create the program ZPRG1 (minimalist screen):创建程序ZPRG1 (极简屏幕):
REPORT zprg1.
PARAMETERS test AS CHECKBOX.
  • Create the program ZPRG2 (splitter and tree):创建程序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( ).
  • Run ZPRG2运行 ZPRG2
  • Double-click the tree node双击树节点

In the SAP GUI, it is possible to mix screens of dynpro technology and GUI controls of the SAP Control Framework in these ways:在 SAP GUI 中,可以通过以下方式混合使用dynpro技术的屏幕和SAP Control Framework 的GUI 控件

  • Screen and Docking Containers ;屏幕和对接容器 these containers may be displayed at any of the 4 sides of the screen这些容器可以显示在屏幕的 4 个侧面中的任何一个
    • In these containers can be placed GUI controls (including splitter containers)在这些容器中可以放置 GUI 控件(包括拆分器容器)
  • Screen containing a so-called Custom Container area in which can be placed GUI controls (including splitter containers)包含可放置 GUI 控件(包括拆分器容器)的所谓自定义容器区域的屏幕
  • Popups can be displayed over any dynpro screen or GUI control;弹出窗口可以显示在任何 dynpro 屏幕或 GUI 控件上; those popups may also contain any (other) dynpro screen or GUI control;这些弹出窗口还可能包含任何(其他)dynpro 屏幕或 GUI 控件; they are completely independent from the screen below.它们完全独立于下面的屏幕。 Popups may also be displayed over popups.弹出窗口也可以显示在弹出窗口之上。

It is not possible to embed a dynpro screen inside a GUI control (including containers) in any manner.无法以任何方式将 dynpro 屏幕嵌入 GUI 控件(包括容器)中。

So, in your case, the only solution is to use a docking container on the left of your dynpro screen.因此,就您而言,唯一的解决方案是使用 dynpro 屏幕左侧的对接容器 But only the program which displays the dynpro screen is allowed to "add" the docking container (ie CALL TRANSACTION or SUBMIT cannot be used).但只有显示 dynpro 屏幕的程序才允许“添加”停靠容器(即不能使用CALL TRANSACTIONSUBMIT )。

Consequently, ZPRG2 must handle both your GUI control and a dynpro screen.因此, ZPRG2必须同时处理您的 GUI 控制和 dynpro 屏幕。 You have two options to handle the dynpro screen:您有两个选项来处理 dynpro 屏幕:

  1. Either ZPRG2 handles it (everything is done by ZPRG2, you don't need ZPRG1)要么ZPRG2处理它(一切都由 ZPRG2 完成,您不需要 ZPRG1)
  2. Or you only define a subscreen area inside the dynpro screen of ZPRG2 , and you include a subscreen from ZPRG1 which handles all the initializations and interactions of the subscreen.或者你只定义屏幕区域的dynpro屏幕内ZPRG2 ,你包括从子屏幕ZPRG1负责处理所有的初始化和子画面的交互。

The second solution is recommended because it permits the Separation Of Concerns" .推荐使用第二种解决方案,因为它允许关注点分离”

The code below is a minimal example to demonstrate how it could work, that will allow you to debug and understand better;下面的代码是一个演示它如何工作的最小示例,它可以让您更好地调试和理解; there are so many things to explain that I prefer to let you ask questions in the comments (or new questions);有很多事情要解释,我更愿意让你在评论(或新问题)中提问; be aware that many of the algorithm, statements and tricks below are not advised, I use them just because they are much shorter.请注意,不建议使用下面的许多算法、语句和技巧,我使用它们只是因为它们更短。 You will end up with a much more complex program than this one.你最终会得到一个比这个复杂得多的程序。

  • Program ZPRG1 (right side, show/hide UI elements to react to double click at left side):程序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.
  • Program ZPRG2 (left side tree + handling of subscreen area at the right to include ZPRG1 screen):程序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.
  • Dynpro 0200 of program ZPRG2 :程序ZPRG2 的Dynpro 0200
    • The layout contains a huge subscreen area named SUBAREA , and the OKCODE element is to be assigned the name OKCODE (which is mapped to the global variable of ZPRG2 having the same name)布局包含名为一个巨大的子屏幕区域SUBAREA ,并且OKCODE元件将被分配的名称OKCODE (它被映射到ZPRG2的具有相同名称的全局变量)
    • The flow logic contains this code:流逻辑包含以下代码:
PROCESS BEFORE OUTPUT.
  MODULE status_0200.
  CALL SUBSCREEN subarea INCLUDING 'ZPRG1' '0100'.

PROCESS AFTER INPUT.
  CALL SUBSCREEN subarea.
  MODULE user_command_0200.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM