on 05-02-2008 11:36 AM
Hi Experts,
I'm using buttons in ALVs. Until now I used entries from a collumn for labeling my buttons. Additionally I used a static icon.
lr_ui_button->set_text_fieldname( 'COLUMN_1' ).
lr_ui_button->set_image_source( 'ICON_SELECT_DETAIL' ).
That worked fine, but now I need to use a static text for my button-label, too. Therefore I must say, that I don't want to use another column with an constant value and I don't want to change the values of my COLUMN_1.
I tried
lr_ui_button->set_text( 'My Labelname' ).
instead of
lr_ui_button->set_text_fieldname( 'COLUMN_1' ).
but only got this error, which seems to occur deep in the generated SAP-code
Attribut SALV_WD_COL_VSBL_00007 could not be found.
(Attribut SALV_WD_COL_VSBL_00007 konnte nicht gefunden werden.)
My guess is, that the button needs the method set_text_fieldname() as a requiered binding, similar to other Elements, which need certain bindings to context elements.
So, I tried
lr_ui_button->set_text_fieldname( 'COLUMN_1' ).
lr_ui_button->set_text( 'My Labelname' ).
The program was runable, but the set_text() had no real effect. So, I'm running out of ideas now and would apreciate some help .
Regards
Torsten
Hi,
Create a new button in tool bar of alv.Following code works
DATA:
lr_comp_alv TYPE REF TO if_wd_component_usage,
lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
lr_config TYPE REF TO cl_salv_wd_config_table.
*internal table for buttons
TYPES: BEGIN OF ty_button,
lv_btn TYPE string,
lv_id TYPE string,
END OF ty_button.
DATA: it_button TYPE STANDARD TABLE OF ty_button,
wa_button TYPE ty_button.
wa_button-lv_btn = 'Select All'.
wa_button-lv_id = 'SELECT'.
APPEND wa_button TO it_button.
wa_button-lv_btn = 'Deselect All'.
wa_button-lv_id = 'DESELECT'.
APPEND wa_button TO it_button.
wa_button-lv_btn = 'Cancel Assignment(s)'.
wa_button-lv_id = 'CANCEL'.
APPEND wa_button TO it_button.
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv1( ).
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_alv1( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
*
l_table->if_salv_wd_table_settings~set_read_only( abap_false ).
l_table->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
l_table->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
l_table->if_salv_wd_std_functions~SET_EXPORT_ALLOWED( abap_false ).
l_table->if_salv_wd_std_functions~SET_PDF_ALLOWED( abap_false ).
*
*... ALV Component Usage
lr_comp_alv = wd_this->wd_cpuse_alv1( ).
IF lr_comp_alv->has_active_component( ) IS INITIAL.
lr_comp_alv->create_component( ).
ENDIF.
lr_comp_if_alv = wd_this->wd_cpifc_alv1( ).
*... Configure ALV
lr_config = lr_comp_if_alv->get_model( ).
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
lr_config->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
lr_config->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
lr_config->if_salv_wd_std_functions~SET_EXPORT_ALLOWED( abap_true ).
lr_config->if_salv_wd_std_functions~SET_PDF_ALLOWED( abap_false ).
*
data: lr_func type ref to IF_SALV_WD_STD_FUNCTIONS.
lr_func ?= lr_config.
lr_func->SET_DISPLAY_AS_ALLOWED( ABAP_TRUE ).
lr_func->SET_EXPORT_ALLOWED( ABAP_FALSE ).
lr_func->SET_VIEW_LIST_ALLOWED( ABAP_FALSE ).
Set toolbar visibility to false.
DATA: lr_function_settings TYPE REF TO if_salv_wd_function_settings.
lr_function_settings ?= lr_config.
lr_function_settings->set_visible( cl_wd_uielement=>e_visible-none ).
set default ALV Functions off
DATA: lr_standard_functions TYPE REF TO if_salv_wd_std_functions.
lr_standard_functions ?= lr_config.
lr_standard_functions->set_sort_headerclick_allowed( ABAP_false ).
lr_standard_functions->set_filter_filterline_allowed( abap_false ).
lr_standard_functions->set_filter_complex_allowed( abap_false ).
lr_standard_functions->set_sort_complex_allowed( abap_false ).
*
lr_config->if_salv_wd_table_hierarchy~set_expanded( abap_true ).
*
**... ... Standard ALV Functions
cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(
r_model = lr_config
allowed = abap_true ).
*
cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_group_edit(
r_model = lr_config
allowed = abap_false ).
*... ... Toolbar
DATA:
lr_function TYPE REF TO cl_salv_wd_function,
lr_toggle_button TYPE REF TO cl_salv_wd_fe_button,
lref_toolbar_button TYPE REF TO cl_salv_wd_fe_a_button.
*... ... Table Header
lr_config->if_salv_wd_table_settings~r_header->set_text( 'Objects On Loan(Currently Selected For Display)' )."#EC NOTEXT
LOOP AT it_button INTO wa_button.
lr_function = lr_config->if_salv_wd_function_settings~create_function( wa_button-lv_id ).
CREATE OBJECT lr_toggle_button.
lref_toolbar_button ?= lr_toggle_button.
lr_toggle_button->set_text( wa_button-lv_btn ). "#EC *
lr_function->set_editor( lr_toggle_button ).
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have used set_text_fieldname( 'COLUMN_1' ), then have you done a set_attribute of the attribute column_1 to whatever value you wish to display? Also, the field column_1 has to be in the same context node as your ALV data. Then the value that is bound to the context attribute column_1 will be displayed in the button at runtime.
This will anyway work without the set_text_fieldname method, by just using set_text statically.
Regards,
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nithya,
Until now, I had a context node TABLE1 with an attribute COLUMN1. TABLE1 has a cardinality of 0...n and COLUMN1 is of type string with the default value "report". TABLE1 is also bound to my ALV data.
With set_text_fieldname() I bound the text of my button to COLUMN1. So, "report" is shown on every button in my ALV columns.
But now, I don't want this binding anymore. I want COLUMN1 to contain other data, e.g. booleans which I can bind to the visibility of my buttons. But I also need a text on my buttons. Therefore I tried set_text() but it does not work.
Regards
Torsten
Hi Torsten,
I tried the following and it works fine for me:
data: lr_button type ref to cl_wd_salv_uie_button.
create object lr_button.
lr_button->set_text( 'Text' ).
ls_col-r_column->set_cell_editor( lr_button ).
Here ls_col is the particular column of type SALV_WD_S_COLUMN_REF. I did not face any issue, and the static text was set for all the buttons in the entire column.
Regards,
Nithya
Hi Nithya,
this is really strange. If I try it without the set_text_fieldname(), I always get this exception:
Folgender Fehlertext wurde im System "ourServer" prozessiert: Attribut SALV_WD_COL_VSBL_00008 konnte nicht gefunden werden.
Der Fehler trat auf dem Applikationsserver "ourServer" und im Workprozess 0 auf.
Die Abbruchart war: RABAX_STATE
Die ABAP-Aufrufhierarchie war:
Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program CL_WDR_CONTEXT_NODE_INFO======CP
Method: IF_WD_CONTEXT_ELEMENT~GET_ATTRIBUTE of program CL_WDR_CONTEXT_ELEMENT========CP
Method: GET_ATTRIBUTE_INTERNAL of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L0STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
That means, he cant find the attribute SALV_WD_COL_VSBL_00008. And I guess it's the node_info element, where the programm fumbles, but I have no idea why or where I have done something wrong. I never touched the node_info. This is my code at that point:
DATA:
lr_column_button TYPE REF TO cl_salv_wd_column,
lr_ui_button TYPE REF TO cl_salv_wd_uie_button.
lr_column_button = l_value->if_salv_wd_column_settings~get_column( 'DETAILS' ).
CREATE OBJECT lr_ui_button.
lr_ui_button->set_text_fieldname( 'DETAILS' ).
lr_ui_button->set_image_source( 'ICON_SELECT_DETAIL' ).
lr_column_button->set_cell_editor( lr_ui_button ).
Well, I don't think, it will be of much help, but here you go
method CHANGE_LOOK_ALV_1 .
DATA:
l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
l_ref_interfacecontroller = wd_this->wd_cpifc_alv_comp_ebene_1( ).
Referenziert auf die ALV Einstellungen
DATA:
l_value TYPE REF TO cl_salv_wd_config_table,
lr_header TYPE REF TO cl_salv_wd_header.
l_value = l_ref_interfacecontroller->get_model( ).
ALV Einstellungen sind über das Model möglich
ALV Überschrift
lr_header = l_value->if_salv_wd_table_settings~get_header( ).
lr_header->set_text( EXPORTING value = 'Fahrzeugübersicht' ).
ALV Einstellungen sind über das Model möglich
l_value->if_salv_wd_table_settings~set_visible_row_count( '10' ).
l_value->if_salv_wd_table_settings~set_empty_table_text( 'Es wurden keine Daten selektiert!' ).
l_value->if_salv_wd_table_settings~set_width( '100%' ).
l_value->IF_SALV_WD_TABLE_SETTINGS~SET_selection_mode( 00 ). "Auto-Einstellung (06=aus)
PDF Funktion und Excel-Export ausblenden
l_value->if_salv_wd_std_functions~set_pdf_allowed( '0' ).
l_value->if_salv_wd_std_functions~set_export_allowed( '0' ).
headlines
DATA col TYPE REF TO cl_salv_wd_column.
DATA header_col TYPE REF TO cl_salv_wd_column_header.
col = l_value->if_salv_wd_column_settings~get_column( 'KENNZEICHEN' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'Kennzeichen' ).
col = l_value->if_salv_wd_column_settings~get_column( 'FIN' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'FIN' ).
col = l_value->if_salv_wd_column_settings~get_column( 'HERSTELLER' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'Hersteller' ).
col = l_value->if_salv_wd_column_settings~get_column( 'HNUMMER' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'H-Nummer' ).
col = l_value->if_salv_wd_column_settings~get_column( 'KUNDEN_ID' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'Kunden ID' ).
col = l_value->if_salv_wd_column_settings~get_column( 'DETAILS' ).
header_col = col->get_header( ).
header_col->set_text( EXPORTING value = 'Details' ).
button for button-columns
DATA:
lr_column_button TYPE REF TO cl_salv_wd_column,
lr_ui_button TYPE REF TO cl_salv_wd_uie_button.
lr_column_button = l_value->if_salv_wd_column_settings~get_column( 'DETAILS' ).
CREATE OBJECT lr_ui_button.
lr_ui_button->set_text_fieldname( 'DETAILS' ).
lr_ui_button->set_image_source( 'ICON_SELECT_DETAIL' ).
lr_column_button->set_cell_editor( lr_ui_button ).
image for traffic-light column status
DATA:
lr_col_ampel_s TYPE REF TO cl_salv_wd_column,
lr_header_col_ampel_s TYPE REF TO cl_salv_wd_column_header,
lr_image_status TYPE REF TO cl_salv_wd_uie_image.
lr_col_ampel_s = l_value->if_salv_wd_column_settings~get_column( 'AMPEL_STATUS' ).
lr_header_col_ampel_s = lr_col_ampel_s->get_header( ).
lr_header_col_ampel_s->set_text( EXPORTING value = 'Status' ).
CREATE OBJECT lr_image_status.
lr_image_status->set_source_fieldname( 'AMPEL_STATUS' ).
lr_col_ampel_s->set_cell_editor( lr_image_status ).
image for traffic-light column fällig
DATA:
lr_col_ampel_f TYPE REF TO cl_salv_wd_column,
lr_header_col_ampel_f TYPE REF TO cl_salv_wd_column_header,
lr_image_faellig TYPE REF TO cl_salv_wd_uie_image.
lr_col_ampel_f = l_value->if_salv_wd_column_settings~get_column( 'AMPEL_FAELLIG' ).
lr_header_col_ampel_f = lr_col_ampel_f->get_header( ).
lr_header_col_ampel_f->set_text( EXPORTING value = 'Fällig' ).
CREATE OBJECT lr_image_faellig.
lr_image_faellig->set_source_fieldname( 'AMPEL_FAELLIG' ).
lr_col_ampel_f->set_cell_editor( lr_image_faellig ).
endmethod.
Hi Torsten
I used the following code to write the text on ALV button.
data: lr_user_funcopy type ref to cl_salv_wd_function.
lr_user_funcopy = l_value->if_salv_wd_function_settings~create_function_right( id = 'COPYA' ).
The function is a button
data: lr_disp_button type ref to cl_salv_wd_fe_button.
lv_button_text type string.
create object lr_disp_button.
lv_button_text = 'Display'.
lr_disp_button->set_text( lv_button_text ).
lr_disp_button->SET_IMAGE_SOURCE( 'ICON_DISPLAY' ).
lr_user_funcopy->set_editor( lr_disp_button ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.