ALV Tree Control
CL_GUI_ALV_TREE
效果:
自定义函数调用,在函数里画屏幕定义树控件显示
FUNCTION ZFI_YSYWLX_HELP_NEW .
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(S_BS_CODE) TYPE /SDF/IVIS_DC_SELTAB OPTIONAL
*" REFERENCE(S_YTBM) TYPE /SDF/IVIS_DC_SELTAB OPTIONAL
*" REFERENCE(S_HKONT) TYPE /SDF/IVIS_DC_SELTAB OPTIONAL
*" REFERENCE(I_BUKRS) TYPE BUKRS OPTIONAL
*" EXPORTING
*" REFERENCE(E_CANC) TYPE C
*" TABLES
*" ET_DATA TYPE ZFI_T_YSYWLX_HELP_YB
*"----------------------------------------------------------------------
DATA LS_ALV_TREE_SEL TYPE TY_ALV_TREE.
DATA LS_DATA TYPE ZFI_S_YSYWLX_HELP_YB.
DATA LS_ZTFI0005_1 TYPE ZTFI0005_1.
DATA LS_YTBM TYPE /SDF/IVIS_DC_SELTAB_ITEM.
DATA LT_YTBM TYPE /SDF/IVIS_DC_SELTAB.
FIELD-SYMBOLS <LF_ALV_TREE> TYPE TY_ALV_TREE.
REFRESH: GT_ALV_TREE,GT_FIELDCATALOG,GT_ALV_TREE_YB,GT_ALV_TREE_SEL.
CLEAR: G_CANC.
"公司关联到业态
LT_YTBM[] = S_YTBM[].
IF S_YTBM[] IS INITIAL AND I_BUKRS IS NOT INITIAL.
SELECT SINGLE *
FROM ZTFI0005_1
INTO LS_ZTFI0005_1
WHERE BUKRS = I_BUKRS.
IF LS_ZTFI0005_1-YWLX1 IS NOT INITIAL.
LS_YTBM-SIGN = 'I'.
LS_YTBM-OPTION = 'EQ'.
LS_YTBM-LOW = LS_ZTFI0005_1-YWLX1.
APPEND LS_YTBM TO LT_YTBM.
ENDIF.
IF LS_ZTFI0005_1-YWLX2 IS NOT INITIAL.
LS_YTBM-SIGN = 'I'.
LS_YTBM-OPTION = 'EQ'.
LS_YTBM-LOW = LS_ZTFI0005_1-YWLX2.
APPEND LS_YTBM TO LT_YTBM.
ENDIF.
IF LS_ZTFI0005_1-YWLX3 IS NOT INITIAL.
LS_YTBM-SIGN = 'I'.
LS_YTBM-OPTION = 'EQ'.
LS_YTBM-LOW = LS_ZTFI0005_1-YWLX3.
APPEND LS_YTBM TO LT_YTBM.
ENDIF.
ENDIF.
* IF lt_ytbm[] IS NOT INITIAL AND s_hkont[] IS INITIAL.
"添加通用业态
LS_YTBM-SIGN = 'I'.
LS_YTBM-OPTION = 'EQ'.
LS_YTBM-LOW = 'Z000'.
APPEND LS_YTBM TO LT_YTBM.
* ENDIF.
SELECT A~BS_CODE, A~YTBM, BS_DESCR, CATELOG, DESCR, CATELOG1, DESCR1,
CATELOG2, DESCR2, CATELOG3, DESCR3, CATELOG4, DESCR4, GTEXT
FROM ZTFI1040_C06 AS A
LEFT JOIN TGSBT AS B
ON A~YTBM = B~GSBER
AND B~SPRAS = @SY-LANGU
LEFT JOIN ZTFI1040_C06_01 AS C
ON A~BS_CODE = C~BS_CODE
INTO CORRESPONDING FIELDS OF TABLE @GT_ALV_TREE
WHERE A~BS_CODE IN @S_BS_CODE
AND A~YTBM IN @LT_YTBM
AND C~HKONT IN @S_HKONT
AND XFLAG = ''.
SORT GT_ALV_TREE BY YTBM BS_CODE.
DELETE ADJACENT DUPLICATES FROM GT_ALV_TREE COMPARING YTBM BS_CODE.
IF GT_ALV_TREE[] IS INITIAL.
"一般层无数据
E_CANC = '1'.
EXIT.
ENDIF.
LOOP AT GT_ALV_TREE ASSIGNING <LF_ALV_TREE>.
IF <LF_ALV_TREE>-YTBM = 'Z000'.
"通用业态显示到 分类1
CLEAR: <LF_ALV_TREE>-CATELOG2,<LF_ALV_TREE>-CATELOG3,<LF_ALV_TREE>-CATELOG4.
ELSE.
"非通过业态显示到 大类科目
CLEAR: <LF_ALV_TREE>-CATELOG1,<LF_ALV_TREE>-CATELOG2,<LF_ALV_TREE>-CATELOG3,<LF_ALV_TREE>-CATELOG4.
ENDIF.
ENDLOOP.
GT_ALV_TREE_SEL[] = GT_ALV_TREE[].
"TREE INIT
IF G_ALV_TREE IS NOT INITIAL.
G_ALV_TREE->FREE( ).
GV_CONTAINER->FREE( ).
CALL METHOD CL_GUI_CFW=>FLUSH.
CLEAR:G_ALV_TREE,GV_CONTAINER.
ENDIF.
"alv 树形展示,供用户选择数据
CALL SCREEN 9001 STARTING AT 15 1.
E_CANC = G_CANC.
CHECK E_CANC = ''.
LOOP AT GT_ALV_TREE_SEL INTO LS_ALV_TREE_SEL WHERE SEL = 'X'.
MOVE-CORRESPONDING LS_ALV_TREE_SEL TO LS_DATA.
APPEND LS_DATA TO ET_DATA.
ENDLOOP.
ENDFUNCTION.
top include定义:
FUNCTION-POOL ZFG_FI_YWLX_HELP. "MESSAGE-ID ..
* INCLUDE LZFG_FI_YWLX_HELPD... " Local class definition
TYPES:
BEGIN OF ty_alv_tree,
ytbm TYPE ztfi1040_c06-ytbm, "业态编码
catelog TYPE ztfi1040_c06-catelog, "大类科目
catelog1 TYPE ztfi1040_c06-catelog1, "分类1
catelog2 TYPE ztfi1040_c06-catelog2, "分类2
catelog3 TYPE ztfi1040_c06-catelog3, "分类3
catelog4 TYPE ztfi1040_c06-catelog4, "分类4
bs_code TYPE ztfi1040_c06-bs_code, "业务类型编码
bs_descr TYPE ztfi1040_c06-bs_descr, "业务类型-描述
descr TYPE ztfi1040_c06-descr, "大类科目-描述
descr1 TYPE ztfi1040_c06-descr1, "分类1-描述
descr2 TYPE ztfi1040_c06-descr2, "分类2-描述
descr3 TYPE ztfi1040_c06-descr3, "分类3-描述
descr4 TYPE ztfi1040_c06-descr4, "分类4-描述
bs_type TYPE ztfi1040_c06-bs_type, "业务类型属性
gtext TYPE tgsbt-gtext, "业态编码-描述
description TYPE text128, "描述
hkont TYPE ztfi1040_c06_01-hkont, "财务科目代码
sel TYPE c,
END OF ty_alv_tree.
DATA gt_alv_tree TYPE TABLE OF ty_alv_tree.
DATA gt_alv_tree_sel TYPE TABLE OF ty_alv_tree.
DATA gt_alv_tree_yb TYPE TABLE OF ty_alv_tree.
DATA g_canc TYPE c.
DATA g_alv_tree TYPE REF TO cl_gui_alv_tree.
DATA gv_container TYPE REF TO cl_gui_custom_container.
DATA gt_fieldcatalog TYPE lvc_t_fcat.
CLASS lcl_tree_event_receiver DEFINITION.
PUBLIC SECTION.
*§2. Define an event handler method for each event you want to react to.
* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.
METHODS checkbox_change FOR EVENT checkbox_change
OF cl_gui_alv_tree
IMPORTING checked
fieldname
node_key.
ENDCLASS.
CLASS lcl_tree_event_receiver IMPLEMENTATION.
*§3. Implement your event handler methods.
METHOD checkbox_change.
PERFORM f_checkbox_change USING checked
fieldname
node_key.
ENDMETHOD.
ENDCLASS.
屏幕PBO定义
*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPO01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
SET PF-STATUS '9001'.
SET TITLEBAR '9001'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module M_BUILD_TREE_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE m_build_tree_9001 OUTPUT.
IF g_alv_tree IS INITIAL.
PERFORM f_init_tree.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Automation Queue failure'(801)
txt1 = 'Internal error:'(802)
txt2 = 'A method in the automation queue'(803)
txt3 = 'caused a failure.'(804).
ENDIF.
ELSE.
CALL METHOD g_alv_tree->frontend_update.
CALL METHOD cl_gui_cfw=>flush.
ENDIF.
ENDMODULE.
PAI定义
*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPI01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'ZOK'.
* PERFORM f_get_selected_data.
LEAVE TO SCREEN 0.
WHEN 'CANC'.
g_canc = 'X'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
form定义
*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form F_INIT_TREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_init_tree .
DATA ls_hierarchy_header TYPE treev_hhdr.
CREATE OBJECT gv_container
EXPORTING
container_name = 'G_TREE_YB'.
* create tree control
CREATE OBJECT g_alv_tree
EXPORTING
parent = gv_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
PERFORM f_build_hierarchy_header CHANGING ls_hierarchy_header.
PERFORM f_build_fieldcatalog.
* (even after this method call). You can change data of your table
* by calling methods of CL_GUI_ALV_TREE.
* Furthermore, the output table 'gt_outtab' must be global and can
* only be used for one ALV Tree Control.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = ls_hierarchy_header
CHANGING
it_fieldcatalog = gt_fieldcatalog
it_outtab = gt_alv_tree_yb.
PERFORM f_create_hierarchy.
PERFORM f_register_events.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog. (see build_fieldcatalog).
CALL METHOD g_alv_tree->update_calculations.
* Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.
ENDFORM.
FORM f_build_hierarchy_header CHANGING
ps_hierarchy_header TYPE treev_hhdr.
ps_hierarchy_header-heading = '业务类型层级'(300).
ps_hierarchy_header-tooltip = '业务类型层级'(400).
ps_hierarchy_header-width = 80.
ps_hierarchy_header-width_pix = ''.
ENDFORM.
FORM f_build_fieldcatalog .
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
REFRESH gt_fieldcatalog.
ls_fieldcatalog-fieldname = 'DESCRIPTION'.
ls_fieldcatalog-coltext = '描述'.
ls_fieldcatalog-outputlen = 100.
APPEND ls_fieldcatalog TO gt_fieldcatalog.
ENDFORM.
FORM f_create_hierarchy .
DATA: lv_ytbm_key TYPE lvc_nkey,
lv_catelog_key TYPE lvc_nkey,
lv_catelog1_key TYPE lvc_nkey,
lv_catelog2_key TYPE lvc_nkey,
lv_catelog3_key TYPE lvc_nkey,
lv_catelog4_key TYPE lvc_nkey,
lv_last_key TYPE lvc_nkey,
lv_node_text TYPE lvc_value,
lv_top_key TYPE lvc_nkey.
DATA lt_children TYPE lvc_t_nkey.
DATA:
lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
DATA ls_alv_tree TYPE ty_alv_tree.
FIELD-SYMBOLS <lf_alv_tree> TYPE ty_alv_tree.
* Define one top node. In this way it is possible to calculate
* values for the whole hierarchy.
CLEAR ls_item_layout.
ls_item_layout-fieldname = '&Hierarchy'.
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
ls_item_layout-editable = 'X'.
APPEND ls_item_layout TO lt_item_layout.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = TEXT-001
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = lv_top_key.
* CALL METHOD g_alv_tree->add_node
* EXPORTING
* i_relat_node_key = lv_top_key
* i_relationship = cl_gui_column_tree=>relat_last_child
* i_node_text = TEXT-002
* IMPORTING
* e_new_node_key = lv_top_key.
* SORT gt_alv_tree BY ytbm DESCENDING catelog DESCENDING catelog1 DESCENDING
* catelog2 DESCENDING catelog3 DESCENDING catelog4 DESCENDING.
SORT gt_alv_tree BY ytbm catelog catelog1
catelog2 catelog3 catelog4.
LOOP AT gt_alv_tree ASSIGNING <lf_alv_tree>.
AT NEW ytbm.
CLEAR:lv_ytbm_key,lv_catelog_key,lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
lv_node_text = <lf_alv_tree>-ytbm.
IF <lf_alv_tree>-ytbm IS NOT INITIAL OR <lf_alv_tree>-gtext IS NOT INITIAL.
* ls_alv_tree-description = <lf_alv_tree>-gtext.
<lf_alv_tree>-description = <lf_alv_tree>-gtext.
PERFORM f_add_node USING <lf_alv_tree>
lv_top_key
lv_node_text
CHANGING lv_ytbm_key.
ENDIF.
ENDAT.
AT NEW catelog.
CLEAR:lv_catelog_key,lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
lv_node_text = <lf_alv_tree>-catelog.
IF <lf_alv_tree>-catelog IS NOT INITIAL OR <lf_alv_tree>-descr IS NOT INITIAL.
* ls_alv_tree-description = <lf_alv_tree>-descr.
<lf_alv_tree>-description = <lf_alv_tree>-descr.
PERFORM f_add_node USING <lf_alv_tree>
lv_ytbm_key
lv_node_text
CHANGING lv_catelog_key.
ENDIF.
ENDAT.
AT NEW catelog1.
IF <lf_alv_tree>-ytbm = 'Z000'.
CLEAR:lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
lv_node_text = <lf_alv_tree>-catelog1.
IF <lf_alv_tree>-catelog1 IS NOT INITIAL OR <lf_alv_tree>-descr1 IS NOT INITIAL.
* ls_alv_tree-description = <lf_alv_tree>-descr1.
<lf_alv_tree>-description = <lf_alv_tree>-descr1.
PERFORM f_add_node USING <lf_alv_tree>
lv_catelog_key
lv_node_text
CHANGING lv_catelog1_key.
ENDIF.
ENDIF.
ENDAT.
* AT NEW catelog2.
* CLEAR:lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
* lv_node_text = <lf_alv_tree>-catelog2.
* IF <lf_alv_tree>-catelog2 IS NOT INITIAL OR <lf_alv_tree>-descr2 IS NOT INITIAL.
** ls_alv_tree-description = <lf_alv_tree>-descr2.
* <lf_alv_tree>-description = <lf_alv_tree>-descr2.
* PERFORM f_add_node USING <lf_alv_tree>
* lv_catelog1_key
* lv_node_text
* CHANGING lv_catelog2_key.
* ENDIF.
* ENDAT.
* AT NEW catelog3.
* CLEAR:lv_catelog3_key,lv_catelog4_key.
* lv_node_text = <lf_alv_tree>-catelog3.
* IF <lf_alv_tree>-catelog3 IS NOT INITIAL OR <lf_alv_tree>-descr3 IS NOT INITIAL.
** ls_alv_tree-description = <lf_alv_tree>-descr3.
* <lf_alv_tree>-description = <lf_alv_tree>-descr3.
* PERFORM f_add_node USING <lf_alv_tree>
* lv_catelog2_key
* lv_node_text
* CHANGING lv_catelog3_key.
* ENDIF.
* ENDAT.
* AT NEW catelog4.
* CLEAR:lv_catelog4_key.
* lv_node_text = <lf_alv_tree>-catelog4.
* IF <lf_alv_tree>-catelog4 IS NOT INITIAL OR <lf_alv_tree>-descr4 IS NOT INITIAL.
** ls_alv_tree-description = <lf_alv_tree>-descr4.
* <lf_alv_tree>-description = <lf_alv_tree>-descr4.
* PERFORM f_add_node USING <lf_alv_tree>
* lv_catelog3_key
* lv_node_text
* CHANGING lv_catelog4_key.
* ENDIF.
* ENDAT.
lv_node_text = <lf_alv_tree>-bs_code.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_catelog3_key.
ENDIF.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_catelog2_key.
ENDIF.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_catelog1_key.
ENDIF.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_catelog_key.
ENDIF.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_ytbm_key.
ENDIF.
IF lv_catelog4_key IS INITIAL.
lv_catelog4_key = lv_top_key.
ENDIF.
* ls_alv_tree-description = <lf_alv_tree>-bs_descr.
<lf_alv_tree>-description = <lf_alv_tree>-bs_descr.
PERFORM f_add_node USING <lf_alv_tree>
lv_catelog4_key
lv_node_text
CHANGING lv_last_key.
ENDLOOP.
"展开集团层
CALL METHOD g_alv_tree->get_children
EXPORTING
i_node_key = lv_top_key
IMPORTING
et_children = lt_children
EXCEPTIONS
historic_error = 1
node_key_not_found = 2.
IF lt_children[] IS NOT INITIAL.
CALL METHOD g_alv_tree->expand_node
EXPORTING
i_node_key = lv_top_key.
ENDIF.
ENDFORM.
FORM f_add_node USING ps_alv_tree TYPE ty_alv_tree
pi_relat_key TYPE lvc_nkey
pi_node_text TYPE lvc_value
CHANGING pc_node_key TYPE lvc_nkey.
DATA:
lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
CLEAR ls_item_layout.
ls_item_layout-fieldname = '&Hierarchy'.
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
ls_item_layout-editable = 'X'.
APPEND ls_item_layout TO lt_item_layout.
* add node
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = pi_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = pi_node_text
is_outtab_line = ps_alv_tree
it_item_layout = lt_item_layout
IMPORTING
e_new_node_key = pc_node_key.
ENDFORM.
FORM f_register_events .
DATA: lt_events TYPE cntl_simple_events,
ls_event TYPE cntl_simple_event,
lo_event_receiver TYPE REF TO lcl_tree_event_receiver.
*§4a. Frontend registration(i): get already registered tree events.
*................................................................
* The following four tree events registers ALV Tree in the constructor
* method itself.
* - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
* - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
* - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
* - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
*
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):
CALL METHOD g_alv_tree->get_registered_events
IMPORTING
events = lt_events.
* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.
ls_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
ls_event-appl_event = 'X'.
APPEND ls_event TO lt_events.
*§4c. Frontend registration(iii):provide new event table to alv tree
CALL METHOD g_alv_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
*--------------------
*§4d. Register events on backend (ABAP Objects event handling)
CREATE OBJECT lo_event_receiver.
SET HANDLER lo_event_receiver->checkbox_change FOR g_alv_tree.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form F_CHECKBOX_CHANGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_CHECKED text
* -->P_FIELDNAME text
* -->P_NODE_KEY text
*----------------------------------------------------------------------*
FORM f_checkbox_change USING iv_checked TYPE c
iv_fieldname TYPE lvc_fname
iv_node_key TYPE lvc_nkey.
DATA:
ls_level_tree_output TYPE ty_alv_tree,
lt_nkey TYPE lvc_t_nkey,
lv_nkey TYPE lvc_nkey.
DATA:
lt_item_layout TYPE lvc_t_layi,
ls_item_layout TYPE lvc_s_layi.
DATA:
lt_item_layout_updata TYPE lvc_t_laci,
ls_item_layout_updata TYPE lvc_s_laci.
CALL METHOD g_alv_tree->get_outtab_line
EXPORTING
i_node_key = iv_node_key
IMPORTING
e_outtab_line = ls_level_tree_output.
IF iv_checked IS NOT INITIAL.
ls_level_tree_output-sel = abap_true.
ELSE.
ls_level_tree_output-sel = abap_false.
ENDIF.
MODIFY gt_alv_tree_sel FROM ls_level_tree_output
TRANSPORTING sel
WHERE bs_code = ls_level_tree_output-bs_code.
CALL METHOD g_alv_tree->get_subtree
EXPORTING
i_node_key = iv_node_key
IMPORTING
et_subtree_nodes = lt_nkey.
LOOP AT lt_nkey INTO lv_nkey.
CLEAR lt_item_layout.
CALL METHOD g_alv_tree->get_outtab_line
EXPORTING
i_node_key = lv_nkey
IMPORTING
et_item_layout = lt_item_layout
e_outtab_line = ls_level_tree_output.
IF iv_checked IS NOT INITIAL.
ls_level_tree_output-sel = abap_true.
ELSE.
ls_level_tree_output-sel = abap_false.
ENDIF.
MODIFY gt_alv_tree_sel FROM ls_level_tree_output
TRANSPORTING sel
WHERE bs_code = ls_level_tree_output-bs_code.
CLEAR ls_item_layout_updata.
CLEAR ls_item_layout.
CLEAR lt_item_layout_updata.
READ TABLE lt_item_layout INTO ls_item_layout INDEX 1.
ls_item_layout_updata-fieldname = ls_item_layout-fieldname.
ls_item_layout_updata-chosen = iv_checked.
ls_item_layout_updata-u_chosen = 'X'.
APPEND ls_item_layout_updata TO lt_item_layout_updata.
CALL METHOD g_alv_tree->change_node
EXPORTING
i_node_key = lv_nkey
i_outtab_line = ls_level_tree_output
it_item_layout = lt_item_layout_updata.
ENDLOOP.
CALL METHOD g_alv_tree->frontend_update.
ENDFORM.
GUI STATUS:
SCREEN 9001逻辑流:
PROCESS BEFORE OUTPUT.
MODULE status_9001.
MODULE m_build_tree_9001.
*
PROCESS AFTER INPUT.
MODULE user_command_9001.