Webdynpro for ABAP中ALV输出为层次结构:
代码:
METHOD wddoinit .
DATA lo_nd_sflight TYPE REF TO if_wd_context_node.
DATA lo_el_sflight TYPE REF TO if_wd_context_element.
DATA ls_sflight TYPE wd_this->element_sflight.
DATA lt_sflight TYPE wd_this->elements_sflight.
* 输入数据
lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_sflight
FROM sflight.
CALL METHOD lo_nd_sflight->bind_table
EXPORTING
new_items = lt_sflight .
* 实例化ALV重用comp
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv_table( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv_table( ).
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model( ).
DATA:lo_config_tab TYPE REF TO if_salv_wd_table_settings.
lo_config_tab ?= lo_value.
* 设置ALV显示layout
CALL METHOD lo_config_tab->set_display_type
EXPORTING
value = if_salv_wd_c_table_settings=>display_type_hierarchy.
DATA:lo_config_col TYPE REF TO if_salv_wd_column_settings.
DATA:lt_columns TYPE salv_wd_t_column_ref,
lwa_column TYPE salv_wd_s_column_ref.
lo_config_col ?= lo_value.
CALL METHOD lo_config_col->get_columns
RECEIVING
value = lt_columns.
LOOP AT lt_columns INTO lwa_column.
IF lwa_column-id = 'CARRID' OR
lwa_column-id = 'CONNID'.
* 指定层次列
lwa_column-r_column->if_salv_wd_column_hierarchy~set_hierarchy_column( value = abap_true ).
ENDIF.
ENDLOOP.
ENDMETHOD.
阅读(883) | 评论(0) | 转发(0) |