视图初始化的时候,初始化跟节点:
method WDDOINIT .
INIT_DATA( ).
DATA lo_nd_tree TYPE REF TO if_wd_context_node.
DATA lo_el_tree TYPE REF TO if_wd_context_element.
DATA ls_tree TYPE wd_this->element_tree.
DATA lv_name TYPE wd_this->element_tree-name.
lo_nd_tree = wd_context->get_child_node( name = wd_this->wdctx_tree ).
lo_el_tree = lo_nd_tree->get_element( ).
lo_el_tree->set_attribute(
name = 'NAME'
value = '计划进度管理' ).
Endmethod.
method INIT_DATA .”第一级节点初始化用DATA1的数据
DATA lo_nd_data1 TYPE REF TO if_wd_context_node.
DATA lt_data1 TYPE wd_this->Elements_data1.
DATA lS_data1 TYPE wd_this->Element_data1.
lo_nd_data1 = wd_context->get_child_node( name = wd_this->wdctx_data1 ).
DEFINE ADDED1.
lS_data1-IDA = &1.
lS_data1-NAME = &2.
APPEND lS_data1 TO lt_data1.
END-OF-DEFINITION.
ADDED1: '01' '计划模板管理',
'02' '计划管理',
'03' '进度管理'.
lo_nd_data1->bind_table( new_items = lt_data1 set_initial_elements = abap_true ).
DATA lo_nd_data2 TYPE REF TO if_wd_context_node.
DATA lt_data2 TYPE wd_this->Elements_data2.
DATA lS_data2 TYPE wd_this->Element_data2.
lo_nd_data2 = wd_context->get_child_node( name = wd_this->wdctx_data2 ).
DEFINE ADDED2.
lS_data2-IDA = &1.
lS_data2-IDB = &2.
lS_data2-NAME = &3.
APPEND lS_data2 TO lt_data2.
END-OF-DEFINITION.”初始化第二级节点用DATA2的数据
ADDED2: '01' '01' '模板显示',
'02' '02' '项目年度开发计划',
'02' '03' '项目主计划',
'02' '04' '项目楼栋月度计划',
'02' '05' '部门月度计划',
'03' '06' '项目年度计划进度提交',
'03' '07' '项目主项计划进度提交',
'03' '08' '项目楼栋计划计划进度提交',
'03' '09' '部门月度计划进度',
'01' '10' '模板维护'
.
lo_nd_data2->bind_table( new_items = lt_data2 set_initial_elements = abap_true ).
DATA lo_nd_data3 TYPE REF TO if_wd_context_node.
DATA lt_data3 TYPE wd_this->Elements_data3.
DATA lS_data3 TYPE wd_this->Element_data3.
lo_nd_data3 = wd_context->get_child_node( name = wd_this->wdctx_data3 ).
DEFINE ADDED3.
lS_data3-IDB = &1.
lS_data3-IDC = &2.
lS_data3-NAME = &3.
APPEND lS_data3 TO lt_data3.
END-OF-DEFINITION.”初始化第三极节点用DATA3
ADDED3: '01' '01' '模板显示',
'02' '02' '项目年计划查询、修改、添加',
'02' '03' '项目年计划审核',
'03' '04' '项目主计划查询、修改、添加',
'03' '05' '项目主计划审核',
'04' '06' '项目楼栋计划查询、修改、添加',
'04' '07' '项目楼栋计划审核',
'05' '08' '部门计划查询、修改、添加、审核',
'06' '09' '年度关键节点进度显示、保存',
'06' '10' '年度关键节点进度审核',
'07' '11' '主项计划进度显示、保存',
'07' '12' '主项计划进度审核',
'08' '13' '楼栋计划进度显示、保存',
'08' '14' '楼栋计划进度审核',
'09' '15' '部门月度计划进度显示、保存',
'09' '16' '部门月度计划进度审核',
'10' '17' '模板维护'
.
lo_nd_data3->bind_table( new_items = lt_data3 set_initial_elements = abap_true ).
Endmethod.
将第一级节点于树根相连
method SUPPLY1 .
DATA lo_nd_DATA1 TYPE REF TO if_wd_context_node.
DATA lo_el_DATA1 TYPE REF TO if_wd_context_element.
DATA ls_DATA1 TYPE wd_this->element_DATA1.
DATA lt_DATA1 TYPE wd_this->elements_DATA1.
lo_nd_DATA1 = wd_context->get_child_node( name = wd_this->wdctx_DATA1 ).
lo_el_DATA1 = lo_nd_DATA1->get_element( ).
lo_nd_DATA1->get_static_attributes_table(
IMPORTING
table = lt_DATA1 ).
DATA lo_nd_NODE1 TYPE REF TO if_wd_context_node.
DATA lo_el_NODE1 TYPE REF TO if_wd_context_element.
DATA ls_NODE1 TYPE wd_this->element_NODE1.
DATA lt_NODE1 TYPE wd_this->elements_NODE1.
lo_nd_NODE1 = wd_context->path_get_node( path = `TREE.NODE1` ).
lo_el_NODE1 = lo_nd_NODE1->get_element( ).
LOOP AT lt_DATA1 INTO ls_DATA1.
ls_NODE1-ID = ls_DATA1-IDA.
ls_NODE1-NAME = ls_DATA1-NAME.
APPEND ls_NODE1 TO lt_NODE1.
ENDLOOP .
lo_nd_NODE1->bind_table( lt_NODE1 ).
Endmethod.
将第二级节点于第一级节点相连:
method SUPPLY2 .
DATA lo_nd_data2 TYPE REF TO if_wd_context_node.
DATA lt_data2 TYPE wd_this->Elements_data2.
DATA lS_data2 TYPE wd_this->Element_data2.
lo_nd_data2 = wd_context->get_child_node( name = wd_this->wdctx_data2 ).
lo_nd_data2->get_static_attributes_table( importing table = lt_data2 ).
DATA lo_nd_node2 TYPE REF TO if_wd_context_node.
DATA lt_node2 TYPE wd_this->Elements_node2.
DATA lS_node2 TYPE wd_this->Element_node2.
lo_nd_node2 = wd_context->path_get_node( path = `TREE.NODE1.NODE2` ).
DATA lv_text TYPE STRING.
parent_element->get_attribute(
EXPORTING
name = 'ID'
IMPORTING
value = lv_text ).
LOOP AT lt_DATA2 INTO ls_DATA2 WHERE IDA = lv_text.
ls_NODE2-ID = ls_DATA2-IDB.
ls_NODE2-NAME = ls_DATA2-NAME.
APPEND ls_NODE2 TO lt_NODE2.
ENDLOOP .
node->bind_elements( lt_node2 ).
Endmethod.
将第三节节点于第二级相连:
method SUPPLY3 .
DATA lo_nd_data3 TYPE REF TO if_wd_context_node.
DATA lt_data3 TYPE wd_this->Elements_data3.
DATA lS_data3 TYPE wd_this->Element_data3.
lo_nd_data3 = wd_context->get_child_node( name = wd_this->wdctx_data3 ).
lo_nd_data3->get_static_attributes_table( importing table = lt_data3 ).
DATA lo_nd_node3 TYPE REF TO if_wd_context_node.
DATA lt_node3 TYPE wd_this->Elements_node3.
DATA lS_node3 TYPE wd_this->Element_node3.
lo_nd_node3 = wd_context->path_get_node( path = `TREE.NODE1.NODE2.NODE3` ).
DATA lv_text TYPE STRING.
PARENT_ELEMENT->get_attribute(
EXPORTING
name = `ID`
IMPORTING
value = lv_text ).
LOOP AT lt_data3 INTO lS_data3 WHERE IDB = lv_text.
lS_node3-ID = lS_data3-IDC.
lS_node3-NAME = lS_data3-NAME.
APPEND lS_node3 TO lt_node3.
ENDLOOP.
node->bind_ELEMENTS( lt_node3 ).
Endmethod.
点击叶子节点:
method ONACTIONSHOW .
DATA lo_nd_node3 TYPE REF TO if_wd_context_node.
DATA lo_el_node3 TYPE REF TO if_wd_context_element.
DATA ls_node3 TYPE wd_this->Element_node3.
lo_nd_node3 = wd_context->path_get_node( path = `TREE.NODE1.NODE2.NODE3` ).
IF lo_nd_node3 IS INITIAL.
EXIT.
ELSE.
lo_el_node3 = lo_nd_node3->get_element( ).
lo_el_node3->get_static_attributes( IMPORTING static_attributes = ls_node3 ).
IF ls_node3-ID = '04'. "项目主计划 查询、修改、添加
wd_this->fire_to_display_plg( ).
ELSEIF ls_node3-ID = '05'. "项目主计划审核
wd_this->fire_to_check_plg( ).
ELSEIF ls_node3-ID = '08'. "部门计划查询、修改、添加、审核
wd_this->fire_to_department_plg( ).
ELSEIF ls_node3-ID = '06'. "楼栋计划查询、修改、添加、审核
wd_this->fire_to_building_plg( ).
ELSEIF ls_node3-ID = '02'. "年度计划查询、修改、添加、审核
wd_this->fire_to_year_plan_plg( ).
ELSEIF ls_node3-ID = '01'. "模板显示
wd_this->fire_to_mb_display_plg( ).
ELSEIF ls_node3-ID = '17'. "模板维护
wd_this->fire_to_mb_change_plg( ).
ELSE.
wd_this->fire_to_empty_plg( ).
ENDIF.
ENDIF.
Endmethod.