on 10-25-2008 3:48 PM
Hi,
I have a "viewcontaineruielement" which displays an ALV. Now i want to change the column names.
Please give an detailed answer.
Thanks
Hi Adil
Ple refer this.
data:
lr_alv_usage type ref to if_wd_component_usage,
lr_if_controller type ref to iwci_salv_wd_table,
lr_config type ref to cl_salv_wd_config_table,
lr_column type ref to cl_salv_wd_column,
lr_header type ref to cl_salv_wd_column_header,
lr_column_settings type ref to if_salv_wd_column_settings,
ls_column type salv_wd_s_column_ref,
lt_columns type salv_wd_t_column_ref,
Instantiate the ALV Component
lr_alv_usage = wd_this->wd_cpuse_alv_display( ).
if lr_alv_usage->has_active_component( ) is initial.
lr_alv_usage->create_component( ).
endif.
Get reference to model
lr_if_controller = wd_this->wd_cpifc_alv_display( ).
lr_config = lr_if_controller->get_model( ).
To get the dropdowns displayed you need to set the table to editable by using below statement
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
Set the UI elements.
lr_column_settings ?= lr_config.
lt_column = lr_column_settings->get_columns( ).
********--
lr_column = lr_column_settings->get_column( 'VBELN' ).
lr_column->set_position( '1' ).
lr_header = lr_column->get_header( ).
lr_column->set_width( '2' ).
lr_column->Set_width( '2' ).
lr_header->set_text( 'Invoice No' ).
lr_header->set_tooltip( 'Invoice No' ).
lr_header->set_ddic_binding_field( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Happened to run into the same issue and wanted to post the solution for the benefit of others.
Please go back to the 'COMPONENTCONTROLLER" click PROPERTIES and ensure that the component use ALV (if ALV is the chosen name) is already there. If not add it by using the CREATE button.
This should ensure the error goes away.
This could happen when use the ALV with a VIEW; and then happened to add your code at CC level as you may have changed the approach within your WD solution.
Edited by: Sekar Sanku on Jul 2, 2009 12:26 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to delete the DDIC bindings for the column text as well as set the new texts. Here is a sample:
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
data l_column type ref to cl_salv_wd_column.
data l_header type ref to cl_salv_wd_column_header.
l_column = l_table->if_salv_wd_column_settings~get_column( 'CREATED_BY' ).
l_header = l_column->get_header( ).
l_header->set_prop_ddic_binding_field(
property = if_salv_wd_c_ddic_binding=>bind_prop_text
value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
l_header->set_prop_ddic_binding_field(
property = if_salv_wd_c_ddic_binding=>bind_prop_tooltip
value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
l_header->set_tooltip( `TTCreated By` ).
l_header->set_text( `Created By` ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The methods and interfaces for the component usages of the ALV are dynamically generated using the component usage names that you gave them. If you didn't name your ALV component usages "ALV" then you will have to adjust the coding for your names. I marked the areas you have to adjust with your name as bold and put in the placeholder <name>.
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_<name>( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_alv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_<name>( ).
This lets you have more than one usage of the same component and still be able to identify which one you are coding against.
For instance - here is a difference example where I named one ALV ALV_ADV and one ALV_BASIC
data: l_ref_cmp_usage1 type ref to if_wd_component_usage.
l_ref_cmp_usage1 = wd_this->wd_cpuse_alv_adv( ).
if l_ref_cmp_usage1->has_active_component( ) is initial.
l_ref_cmp_usage1->create_component( ).
endif.
data l_salv_wd_table_a type ref to iwci_salv_wd_table.
l_salv_wd_table_a = wd_this->wd_cpifc_alv_adv( ).
data: l_ref_cmp_usage2 type ref to if_wd_component_usage.
l_ref_cmp_usage2 = wd_this->wd_cpuse_alv_basic( ).
if l_ref_cmp_usage2->has_active_component( ) is initial.
l_ref_cmp_usage2->create_component( ).
endif.
data l_salv_wd_table_b type ref to iwci_salv_wd_table.
l_salv_wd_table_b = wd_this->wd_cpifc_alv_basic( ).
Hi Thomas,
I have already tried to do this, my node name is MASTER and i changed the codes as you said. But then it gives the error message :
"The field 'wd_cpuse_master(' is unknown, but there is a field with the similar name "WDCTX_MASTER"".
Should i inheritance any class or interface or do something else?
Also the method which i write this code is WDDOINIT.
Thanks.
> Hi Thomas,
> I have already tried to do this, my node name is MASTER and i changed the codes as you said. But then it gives the error message :
> "The field 'wd_cpuse_master(' is unknown, but there is a field with the similar name "WDCTX_MASTER"".
> Should i inheritance any class or interface or do something else?
> Also the method which i write this code is WDDOINIT.
> Thanks.
You must be doing something wrong, because the process I described is how it works. Are you sure you named the component usage MASTER? It looks like from the error message that you have context node named MASTER. These are not the same things. Look at the Used Components tab of your component and see what the Component Use name is for your ALV. There is no other inheritance or interface that you need and it is perfectly fine to have this coding in the WDDOINIT. Just make sure that you have included the Component Usage for the ALV within the Component Controller or View Controller where your WDDOINIT is.
Sorry,
My component usage name is ALV and i tried to compile this code :
"data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
data l_column type ref to cl_salv_wd_column.
data l_header type ref to cl_salv_wd_column_header."
I can't understand where is the mistake..
> Sorry,
> My component usage name is ALV and i tried to compile this code :
> "data: l_ref_cmp_usage type ref to if_wd_component_usage.
> l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
> if l_ref_cmp_usage->has_active_component( ) is initial.
> l_ref_cmp_usage->create_component( ).
> endif.
>
> data l_salv_wd_table type ref to iwci_salv_wd_table.
> l_salv_wd_table = wd_this->wd_cpifc_alv( ).
> data l_table type ref to cl_salv_wd_config_table.
> l_table = l_salv_wd_table->get_model( ).
> data l_column type ref to cl_salv_wd_column.
> data l_header type ref to cl_salv_wd_column_header."
> I can't understand where is the mistake..
You are still getting the same error that WD_CPUSE_ALV doesn't exist? I'm not sure what else to tell you other than you still have an error somewhere. This process is correct. Try commenting out the code and activating the component. Also make sure that you have also declared the component usage at the component controller or the view level (where you placing this code). There are also tutorials (video and printed) of working with the ALV on SCN. Perhaps if you study these tutorials you will see what you are missing.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.