[英]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:最小可重现示例:
SE93
, so that it calls the program ZPRG1
SE93
创建事务代码ZCALL_ZPRG1 ,使其调用程序ZPRG1
REPORT zprg1.
PARAMETERS test AS CHECKBOX.
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( ).
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 控件:
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 TRANSACTION
或SUBMIT
)。
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 屏幕:
ZPRG2
handles it (everything is done by ZPRG2, you don't need ZPRG1)ZPRG2
处理它(一切都由 ZPRG2 完成,您不需要 ZPRG1)ZPRG2
, and you include a subscreen from ZPRG1
which handles all the initializations and interactions of the subscreen.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.
你最终会得到一个比这个复杂得多的程序。
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.
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.
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的具有相同名称的全局变量)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.