REPORT z18_05 MESSAGE-ID tree_control_msg. "refrence to
.
TYPES: item_table_type LIKE STANDARD TABLE OF mtreeitm
WITH DEFAULT KEY.
DATA : con1_ref TYPE REF TO cl_gui_custom_container,
tree_con_ref TYPE REF TO cl_gui_custom_container.
DATA : g_tree TYPE REF TO cl_gui_list_tree.
DATA : grid1 TYPE REF TO cl_gui_alv_grid,
gs_variant LIKE disvariant,
gs_cs_variant LIKE disvariant,
gs_layout TYPE lvc_s_layo,
gs_toolbar TYPE ui_functions,
gt_sort TYPE lvc_t_sort,
gt_sflight TYPE TABLE OF sflight.
* Fields on Dynpro 100
DATA: g_event(30),
g_node_key TYPE tv_nodekey,
g_item_name TYPE tv_itmname,
g_header_name TYPE tv_hdrname.
DATA BEGIN OF gt_carrid OCCURS 0.
DATA carrid LIKE sflight-carrid.
DATA seatsocc LIKE sflight-seatsocc.
DATA seatsocc_b LIKE sflight-seatsocc_b.
DATA seatsocc_f LIKE sflight-seatsocc_f.
DATA END OF gt_carrid.
DATA : gs_carrid LIKE gt_carrid.
TYPE-POOLS: icon.
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
METHODS : handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
METHODS : handle_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
LEAVE TO SCREEN 0.
ENDMETHOD. "handle_double_click
*-- Add ToolBar
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
ls_toolbar-butn_type = 3.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ls_toolbar-function = 'RESH'.
ls_toolbar-icon = icon_refresh.
ls_toolbar-quickinfo = 'Refresh'.
ls_toolbar-text = ' '.
ls_toolbar-disabled = ' '.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_command.
DATA : l_scroll TYPE lvc_s_stbl.
CASE e_ucomm.
*- REFRESH
WHEN 'RESH'.
SELECT * FROM sflight INTO TABLE gt_sflight.
l_scroll-row = 'X'.
l_scroll-col = 'X'.
CALL METHOD grid1->refresh_table_display
EXPORTING
i_soft_refresh = ''
is_stable = l_scroll.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* CLASS LCL_APPLICATION DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_list_tree
IMPORTING node_key,
handle_header_click
FOR EVENT header_click
OF cl_gui_list_tree
IMPORTING header_name,
handle_expand_no_children
FOR EVENT expand_no_children
OF cl_gui_list_tree
IMPORTING node_key,
handle_item_double_click
FOR EVENT item_double_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_button_click
FOR EVENT button_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_link_click
FOR EVENT link_click
OF cl_gui_list_tree
IMPORTING node_key item_name,
handle_checkbox_change
FOR EVENT checkbox_change
OF cl_gui_list_tree
IMPORTING node_key item_name checked.
ENDCLASS. "LCL_APPLICATION DEFINITION
*---------------------------------------------------------------------*
* CLASS LCL_APPLICATION IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.
METHOD handle_node_double_click.
SELECT * FROM sflight INTO TABLE gt_sflight
WHERE carrid = node_key.
PERFORM refresh_grid.
ENDMETHOD. "HANDLE_NODE_DOUBLE_CLICK
METHOD handle_header_click.
" this method handles header click event of the tree
" control instance
" show the name of the clicked header in a dynpro field
g_event = 'HEADER_CLICK'.
g_header_name = header_name.
CLEAR: g_node_key, g_item_name.
ENDMETHOD. "HANDLE_HEADER_CLICK
METHOD handle_item_double_click.
" this method handles the item double click event of the tree
" control instance
" show the key of the node and the name of the item
" of the double clicked item in a dynpro field
g_event = 'ITEM_DOUBLE_CLICK'.
g_node_key = node_key.
g_item_name = item_name.
CLEAR g_header_name.
ENDMETHOD. "HANDLE_ITEM_DOUBLE_CLICK
METHOD handle_link_click.
" this method handles the link click event of the tree
" control instance
" show the key of the node and the name of the item
" of the clicked link in a dynpro field
g_event = 'LINK_CLICK'.
g_node_key = node_key.
g_item_name = item_name.
CLEAR g_header_name.
ENDMETHOD. "HANDLE_LINK_CLICK
METHOD handle_button_click.
SELECT * FROM sflight INTO TABLE gt_sflight
WHERE carrid = node_key.
PERFORM refresh_grid.
ENDMETHOD. "HANDLE_BUTTON_CLICK
METHOD handle_checkbox_change.
" this method handles the checkbox_change event of the tree
" control instance
" show the key of the node and the name of the item
" of the clicked checkbox in a dynpro field
g_event = 'CHECKBOX_CHANGE'.
g_node_key = node_key.
g_item_name = item_name.
CLEAR g_header_name.
ENDMETHOD. "HANDLE_CHECKBOX_CHANGE
METHOD handle_expand_no_children.
DATA: node_table TYPE treev_ntab,
node TYPE treev_node,
item TYPE mtreeitm,
item_table TYPE item_table_type.
IF node_key = 'Child1'. "#EC NOTEXT
SELECT carrid
SUM( seatsocc ) AS seatsocc
SUM( seatsocc_b ) AS seatsocc_b
SUM( seatsocc_f ) AS seatsocc_f
INTO CORRESPONDING FIELDS OF TABLE gt_carrid
FROM sflight
GROUP BY carrid.
LOOP AT gt_carrid INTO gs_carrid.
CLEAR node.
node-node_key = gs_carrid-carrid. "#EC NOTEXT
node-relatkey = 'Child1'.
node-last_hitem = '1'.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.
CLEAR item.
item-node_key = gs_carrid-carrid.
item-item_name = '1'. "#EC NOTEXT
item-class = cl_gui_list_tree=>item_class_button.
item-text = gs_carrid-carrid. "#EC NOTEXT
item-length = 4. " the width of the item is 4 characters
item-ignoreimag = 'X'.
item-usebgcolor = 'X'. " item has light grey
APPEND item TO item_table.
*
CLEAR item.
item-node_key = gs_carrid-carrid.
item-item_name = '2'. "#EC NOTEXT
item-text = gs_carrid-seatsocc. "#EC NOTEXT
CONDENSE item-text NO-GAPS.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_left.
item-length = 4.
item-ignoreimag = 'X'.
item-usebgcolor = 'X'.
APPEND item TO item_table.
* CLEAR item.
* item-node_key = gs_carrid-carrid.
* item-item_name = 'SEATSOCC_F'. "#EC NOTEXT
* item-text = gs_carrid-seatsocc_f. "#EC NOTEXT
* item-class = cl_gui_list_tree=>item_class_text.
* item-length = 4.
* APPEND item TO item_table.
ENDLOOP.
CALL METHOD g_tree->add_nodes_and_items
EXPORTING
node_table = node_table
item_table = item_table
item_table_structure_name = 'MTREEITM'.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF.
ENDIF.
ENDMETHOD. "HANDLE_EXPAND_NO_CHILDREN
ENDCLASS. "LCL_APPLICATION IMPLEMENTATION
DATA :event_receiver TYPE REF TO lcl_event_receiver.
DATA: g_application TYPE REF TO lcl_application.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE gt_sflight.
CREATE OBJECT g_application.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE init_con OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE init_con OUTPUT.
IF con1_ref IS INITIAL.
CREATE OBJECT con1_ref
EXPORTING container_name = 'CON1'.
CREATE OBJECT grid1
EXPORTING
i_parent = con1_ref.
PERFORM setting_layout.
PERFORM setting_toolbar.
PERFORM setting_sort.
PERFORM setting_event.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
i_save = 'A'
is_variant = gs_variant " variant display
i_default = ' '
is_layout = gs_layout
it_toolbar_excluding = gs_toolbar
CHANGING
it_outtab = gt_sflight
it_sort = gt_sort.
ENDIF.
ENDMODULE. " init_con OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'G100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form setting_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_LAYOCAT text
*----------------------------------------------------------------------*
FORM setting_layout .
*- General display options
gs_layout-cwidth_opt = 'X'.
* TITLE BAR
gs_layout-grid_title = 'LIST TREE TEST'.
* Selection modes for SEL_MODE
gs_layout-sel_mode = 'D'.
* Grid pattern
gs_layout-zebra = 'X'.
ENDFORM. " setting_layout
*&---------------------------------------------------------------------*
*& Form setting_toolbar
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_TOOLBAR text
*----------------------------------------------------------------------*
FORM setting_toolbar.
DATA: l_exclude TYPE ui_func.
l_exclude = cl_gui_alv_grid=>mc_fc_save_variant.
APPEND l_exclude TO gs_toolbar.
l_exclude = cl_gui_alv_grid=>mc_fc_maintain_variant.
APPEND l_exclude TO gs_toolbar.
ENDFORM. " setting_toolbar
*&---------------------------------------------------------------------*
*& Form setting_sort
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_sort .
DATA : ls_sort TYPE lvc_s_sort.
ls_sort-spos = '1'.
ls_sort-fieldname = 'CARRID'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO gt_sort.
ENDFORM. " setting_sort
*&---------------------------------------------------------------------*
*& Form setting_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM setting_event .
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid1.
SET HANDLER event_receiver->handle_command FOR grid1.
ENDFORM. " setting_event
*&---------------------------------------------------------------------*
*& Module init_tree OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE init_tree OUTPUT.
DATA: node_table TYPE treev_ntab,
item_table TYPE item_table_type,
events TYPE cntl_simple_events,
event TYPE cntl_simple_event.
DATA : l_header_text TYPE treev_hhdr,
l_list_text TYPE treev_lhdr.
IF g_tree IS INITIAL.
CREATE OBJECT tree_con_ref
EXPORTING
" the container is linked to the custom control with the
" name 'TREE_CONTAINER' on the dynpro
container_name = 'TREE_CONTAINER'.
* l_header_text = 'Header TEXT'.
l_header_text-heading = 'Header TEXT'.
l_header_text-width = '30'.
l_list_text-heading = 'LIST TEXT'.
CREATE OBJECT g_tree
EXPORTING
parent = tree_con_ref
node_selection_mode = cl_gui_list_tree=>node_sel_mode_single
item_selection = 'X'
hierarchy_header = l_header_text
list_header = l_list_text
with_headers = 'X'.
event-eventid = cl_gui_list_tree=>eventid_node_double_click.
event-appl_event = 'X'. "
APPEND event TO events.
" item double click
event-eventid = cl_gui_list_tree=>eventid_item_double_click.
event-appl_event = 'X'.
APPEND event TO events.
" expand no children
event-eventid = cl_gui_list_tree=>eventid_expand_no_children.
event-appl_event = 'X'.
APPEND event TO events.
" link click
event-eventid = cl_gui_list_tree=>eventid_link_click.
event-appl_event = 'X'.
APPEND event TO events.
" button click
event-eventid = cl_gui_list_tree=>eventid_button_click.
event-appl_event = 'X'.
APPEND event TO events.
" checkbox change
event-eventid = cl_gui_list_tree=>eventid_checkbox_change.
event-appl_event = 'X'.
APPEND event TO events.
CALL METHOD g_tree->set_registered_events
EXPORTING
events = events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF.
* assign event handlers in the application class to each desired event
SET HANDLER g_application->handle_node_double_click FOR g_tree.
SET HANDLER g_application->handle_item_double_click FOR g_tree.
SET HANDLER g_application->handle_expand_no_children FOR g_tree.
SET HANDLER g_application->handle_link_click FOR g_tree.
SET HANDLER g_application->handle_button_click FOR g_tree.
SET HANDLER g_application->handle_checkbox_change FOR g_tree.
PERFORM build_node_and_item_table USING node_table item_table.
CALL METHOD g_tree->add_nodes_and_items
EXPORTING
node_table = node_table
item_table = item_table
item_table_structure_name = 'MTREEITM'.
*
*
** Column2
* CALL METHOD g_tree->add_column
* EXPORTING
* name = 'SEATSOCC'
* width = 15
* header_text = 'Economy Class'.
*
*
* CALL METHOD g_tree->add_column
* EXPORTING
* name = 'SEATSOCC_B'
* width = 15
* alignment = cl_gui_column_tree=>align_right
* header_text = 'Business Class'.
*
*
* CALL METHOD g_tree->add_column
* EXPORTING
* name = 'SEATSOCC_F'
* width = 15
* alignment = cl_gui_column_tree=>align_right
* header_text = 'First Class'.
*
*
*
* CALL METHOD g_tree->expand_node
* EXPORTING
* node_key = 'Root'.
*
ENDIF.
ENDMODULE. " init_tree OUTPUT
*&---------------------------------------------------------------------*
*& Form BUILD_NODE_AND_ITEM_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NODE_TABLE text
* -->P_ITEM_TABLE text
*----------------------------------------------------------------------*
FORM build_node_and_item_table
USING
node_table TYPE treev_ntab
item_table TYPE item_table_type.
DATA: node TYPE treev_node,
item TYPE mtreeitm.
* Build the node table.
* Caution: The nodes are inserted into the tree according to the order
* in which they occur in the table. In consequence, a node must not
* must not occur in the node table before its parent node.
* Node with key 'Root'
node-node_key = 'Root'.
CLEAR node-relatkey. " Special case: A root node has no parent
CLEAR node-relatship. " node.
node-hidden = ' '. " The node is visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder.
node-last_hitem = '1'.
CLEAR node-n_image.
CLEAR node-exp_image.
APPEND node TO node_table.
* Node with key 'Root'
CLEAR item.
item-node_key = 'Root'.
item-item_name = '1'. " Item with name '1'
item-class = cl_gui_list_tree=>item_class_text. " Text Item
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = 'AIRPLANE'. "#EC NOTEXT
APPEND item TO item_table.
* Node with key 'Child1'
CLEAR node.
node-node_key = 'Child1'.
node-relatkey = 'Root'.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder = 'X'.
node-expander = 'X'.
APPEND node TO node_table.
* Node with key 'Child1'
CLEAR item.
item-node_key = 'Child1'.
item-item_name = '1'.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = 'CARR ID'. "#EC NOTEXT
APPEND item TO item_table.
ENDFORM. " build_node_and_item_table
*&---------------------------------------------------------------------*
*& Form refresh_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM refresh_grid .
DATA : l_scroll TYPE lvc_s_stbl.
l_scroll-row = 'X'.
l_scroll-col = 'X'.
CALL METHOD grid1->refresh_table_display
EXPORTING
i_soft_refresh = ''
is_stable = l_scroll.
ENDFORM. " refresh_grid
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
671 | 직원 데이터 [1] | sapjoy | 2024.07.02 | 244 |
670 | REPORT Z99_24. | sapjoy | 2024.05.21 | 84 |
669 | REPORT Z06_01. | sapjoy | 2024.04.21 | 61 |
668 | REPORT z05_36 | sapjoy | 2023.02.08 | 271 |
667 | API | sapjoy | 2022.11.03 | 351 |
666 | z15_21_drag | sapjoy | 2022.02.24 | 307 |
665 | Z18_06_DRAGCLASS | sapjoy | 2022.02.23 | 334 |
664 | REPORT Z21_01 | sapjoy | 2015.10.28 | 2276 |
663 | subroutine pool | sapjoy | 2013.11.16 | 3314 |
662 | REPORT Z20_01. | sapjoy | 2012.08.02 | 5097 |
661 | REPORT Z19_02. | sapjoy | 2012.08.02 | 3953 |
660 | REPORT z19_01. | sapjoy | 2012.08.02 | 3559 |
659 | REPORT z18_06. | sapjoy | 2012.08.02 | 3195 |
» | REPORT z18_05 | sapjoy | 2012.08.02 | 3384 |
657 | REPORT z18_04 . | sapjoy | 2012.08.02 | 3388 |
656 | REPORT z18_03. | sapjoy | 2012.08.02 | 4598 |
655 | REPORT z18_02. | sapjoy | 2012.08.02 | 3124 |
654 | REPORT z18_01. | sapjoy | 2012.08.02 | 3152 |
653 | REPORT z17_23 | sapjoy | 2012.08.02 | 2539 |
652 | REPORT z17_22 | sapjoy | 2012.08.02 | 2307 |