SE38 里找BCALV*或者Package SLIS,有很多ALV的实例可以参考 | |||
method configure_alv . *... check ALV component usage data: lr_salv_wd_table_usage type ref to if_wd_component_usage. lr_salv_wd_table_usage = wd_this->wd_cpuse_salv_wd_table( ). if lr_salv_wd_table_usage->has_active_component( ) is initial. lr_salv_wd_table_usage->create_component( ). endif. *... get ALV component data: lr_salv_wd_table type ref to iwci_salv_wd_table. lr_salv_wd_table = wd_this->wd_cpifc_salv_wd_table( ). *... (1) get ConfigurationModel from ALV Component wd_this->r_table = lr_salv_wd_table->get_model( ). * ...(2) init ConfigurationModel *... init TableSettings data: lr_table_settings type ref to if_salv_wd_table_settings. lr_table_settings ?= wd_this->r_table. lr_table_settings->set_visible_row_count( '15' ). lr_table_settings->set_read_only( abap_false ). data: lr_header type ref to cl_salv_wd_header. lr_header = lr_table_settings->get_header( ). data: l_header type string. concatenate sy-sysid ' Flight overview' into l_header. "#EC NOTEXT lr_header->set_text( l_header ). lr_header->set_tooltip( 'Tooltip Flight Overview' ). "#EC NOTEXT lr_header->set_image_source( 'ICON_FLIGHT' ). lr_header->set_image_first( abap_false ). *... init FunctionSettings cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all( r_model = wd_this->r_table ). *... init ColumnSettings data: lr_column_settings type ref to if_salv_wd_column_settings. lr_column_settings ?= wd_this->r_table. data: lt_columns type salv_wd_t_column_ref. lt_columns = lr_column_settings->get_columns( ). data: ls_column type salv_wd_s_column_ref, lr_col_header type ref to cl_salv_wd_column_header, l_tooltip type string. loop at lt_columns into ls_column. lr_col_header = ls_column-r_column->get_header( ). l_header = lr_col_header->get_text( ). concatenate 'Tooltip:' l_header into l_tooltip separated by space."#EC NOTEXT lr_col_header->set_tooltip( l_tooltip ). *... create textview cellvariant for each column data: lr_cv type ref to cl_salv_wd_cv_standard. create object lr_cv. lr_cv->set_key( 'TEXT_VIEW' ). data: lr_textview type ref to cl_salv_wd_uie_text_view. create object lr_textview. lr_textview->set_text_fieldname( ls_column-id ). lr_cv->set_editor( lr_textview ). ls_column-r_column->add_cell_variant( r_cell_variant = lr_cv ). ls_column-r_column->set_sel_cell_variant_fieldname( 'CELLVARIANT' ). case ls_column-id. when 'CARRID'. data: lr_input_field type ref to cl_salv_wd_uie_input_field. create object lr_input_field exporting value_fieldname = ls_column-id. ls_column-r_column->set_cell_editor( lr_input_field ). when 'CONNID'. data: lr_button type ref to cl_salv_wd_uie_button. create object lr_button. lr_button->set_text_fieldname( ls_column-id ). ls_column-r_column->set_cell_editor( lr_button ). when 'FLDATE'. data: lr_link_to_action type ref to cl_salv_wd_uie_link_to_action. create object lr_link_to_action. lr_link_to_action->set_text_fieldname( ls_column-id ). ls_column-r_column->set_cell_editor( lr_link_to_action ). when 'CARRID_CONV'. data: lr_drdn_by_key type ref to cl_salv_wd_uie_dropdown_by_key. create object lr_drdn_by_key exporting selected_key_fieldname = ls_column-id. ls_column-r_column->set_cell_editor( lr_drdn_by_key ). when 'PRICE'. data: lr_link_to_url type ref to cl_salv_wd_uie_link_to_url. create object lr_link_to_url. lr_link_to_url->set_text_fieldname( ls_column-id ). lr_link_to_url->set_reference( 'http:\\www.amazon.de' ). ls_column-r_column->set_cell_editor( lr_link_to_url ). when 'CHECKBOX'. data: lr_checkbox type ref to cl_salv_wd_uie_checkbox. create object lr_checkbox exporting checked_fieldname = ls_column-id. ls_column-r_column->set_cell_editor( lr_checkbox ). when 'URL'. data: lr_image type ref to cl_salv_wd_uie_image. create object lr_image. lr_image->set_source( 'ICON_FLIGHT' ). ls_column-r_column->set_cell_editor( lr_image ). when 'SEATSOCC'. data: lr_progr_indicator type ref to cl_salv_wd_uie_progr_indicator. create object lr_progr_indicator. lr_progr_indicator->set_percent_value( 80 ). lr_progr_indicator->set_display_value_fieldname( ls_column-id ). lr_progr_indicator->set_show_value( abap_true ). lr_progr_indicator->set_width( '5em' ). ls_column-r_column->set_cell_editor( lr_progr_indicator ). when 'DISTANCE'. data: lr_toggle_button type ref to cl_salv_wd_uie_toggle_button. create object lr_toggle_button exporting checked_fieldname = 'CHECKBOX'. lr_toggle_button->set_text_fieldname( ls_column-id ). ls_column-r_column->set_cell_editor( lr_toggle_button ). when 'PLANETYPE' or 'CURRENCY' or 'DISTID'. when 'ICON'. create object lr_image. lr_image->set_source_fieldname( ls_column-id ). ls_column-r_column->set_cell_editor( lr_image ). ls_column-r_column->set_visible( cl_wd_uielement=>e_visible-visible ). ls_column-r_column->if_salv_wd_column_service_ref~set_sort_fieldname( 'ICON_SORT' ). when others. ls_column-r_column->set_visible( cl_wd_uielement=>e_visible-none ). endcase. endloop. *... init FieldSettings data: lr_field_settings type ref to if_salv_wd_field_settings. lr_field_settings ?= wd_this->r_table. data: lr_field type ref to cl_salv_wd_field. *... set reference fields lr_field = lr_field_settings->get_field( 'PRICE' ). lr_field->set_reference_field( 'CURRENCY' ). lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_curr ). lr_field = lr_field_settings->get_field( 'PAYMENTSUM' ). lr_field->set_reference_field( 'CURRENCY' ). lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_curr ). lr_field = lr_field_settings->get_field( 'DISTANCE' ). lr_field->set_reference_field( 'DISTID' ). lr_field->set_reference_field_type( if_salv_wd_c_field_settings=>reffieldtype_quan ). endmethod. |