cancel
Showing results for 
Search instead for 
Did you mean: 

Add additional column in ALV

Former Member
0 Kudos

Hi,

How can I add an additional column in ALV ie the particular field does not exist in the context?

Thanks,

Ronita.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Instead of creating a static context, create the context dynamically. You can do this by using the method add_new_child_node of interface if_wd_context_node_info.

Regards,

Wenonah

Former Member
0 Kudos

Hi,

use create_column method of if_salv_wd_column_settings.

sample coding

*... create an instance of ALV component

data: l_ref_cmp_usage type ref to if_wd_component_usage.

l_ref_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).

if l_ref_cmp_usage->has_active_component( ) is initial.

l_ref_cmp_usage->create_component( ).

endif.

*... Invoke a method of the ALV Interfacecontroller

data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .

l_ref_interfacecontroller = wd_this->wd_cpifc_salv_wd_table( ).

data:

l_value type ref to cl_salv_wd_config_table,

param_in type if_salv_wd_table=>s_type_param_get_model.

  • param_in-default_fields = 'X'.

*... get model_extended

l_value = l_ref_interfacecontroller->get_model_extended( param_in ).

  • ... get all fields

data: lr_fields type ref to if_salv_wd_field_settings.

data: lt_fields type salv_wd_t_field_ref,

ls_fields like line of lt_fields.

data:

lr_table_settings type ref to if_salv_wd_table_settings.

lr_table_settings ?= l_value.

lr_table_settings->set_visible_row_count( '15' ).

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 ).

data: lr_column_settings type ref to if_salv_wd_column_settings.

data: lr_column type ref to cl_salv_wd_column.

data: id type string.

lr_column_settings ?= l_value.

data:

lr_text type ref to cl_salv_wd_uie_text_view.

lr_fields ?= l_value.

lt_fields = lr_fields->get_fields( ).

loop at lt_fields into ls_fields.

concatenate ls_fields-fieldname '_COL' into id.

lr_column = lr_column_settings->create_column( id = id position = sy-tabix ).

create object lr_text.

lr_text->set_text_fieldname( ls_fields-fieldname ).

lr_column->set_cell_editor( lr_text ).

  • lr_column->IF_SALV_WD_COLUMN_REF~SET_TEXT_FIELDNAME( ls_fields-fieldname ).

endloop.

data: lr_field type ref to cl_salv_wd_field.

lr_field = lr_fields->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_fields->get_field( 'DISTANCE' ).

lr_field->SET_REFERENCE_FIELD( 'DISTID' ).

lr_field->SET_REFERENCE_FIELD_TYPE( IF_SALV_WD_C_FIELD_SETTINGS=>REFFIELDTYPE_QUAN ).