我有一个程序,该程序显示具有两列的拆分器容器:
左侧显示一个控制树(可以)
右侧应显示一个自定义的TCode(不确定如何执行此操作)
在双击树节点时,它调用一个事务,该事务打开一个屏幕,但在新窗口中打开。
如何在右侧窗口中打开屏幕?
最小的可复制示例:
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( ).
答案 0 :(得分:0)
在SAP GUI中,可以通过以下方式将dynpro技术的屏幕和GUI controls的SAP Control Framework的屏幕混合在一起:
无法以任何方式将dynpro屏幕嵌入GUI控件(包括容器)中。
因此,对于您而言,唯一的解决方案是在dynpro屏幕左侧使用停靠容器。但是仅允许显示dynpro屏幕的程序“添加”停靠容器(即,不能使用CALL TRANSACTION
或SUBMIT
)。
因此,ZPRG2
必须同时处理GUI控件和dynpro屏幕。您有两种选择来处理dynpro屏幕:
ZPRG2
处理(一切由ZPRG2完成,您不需要ZPRG1)ZPRG2
的dynpro屏幕内定义一个subscreen area,并包括ZPRG1
的子屏幕,该子屏幕处理该子屏幕的所有初始化和交互。推荐第二种解决方案,因为它允许Separation Of Concerns"。
下面的代码是演示其工作方式的最小示例,它使您可以调试和更好地理解;有太多事情需要解释,我更愿意让您在评论中提出问题(或新问题);请注意,不建议使用以下许多算法,语句和窍门,我之所以使用它们只是因为它们要短得多。您最终将获得比此程序复杂得多的程序。
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
的巨大子屏幕区域,并且为 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.