Image in ALV table
Hello All,
I have a AVL table with some data in it, but one of the columns of the AVL table I want to put an image.
Is that possible?
How do I do that?
Thanks & Regards,
Chris Bogers
Hi,
It is possible to insert image.
Refer the code below :
DATA: lr_column TYPE REF TO cl_salv_wd_column,
lr_image TYPE REF TO cl_salv_wd_uie_image,
lv_icon TYPE string.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'STATUS' ).
CREATE OBJECT lr_image.
lr_image->SET_SOURCE_FIELDNAME( 'STATUS' ).
lr_column->set_cell_editor( lr_image ).
Similar Messages
-
WD4A : Displaying images in ALV table
Hi,
Does anyone know how to display images in ALV tables in Webdynpro?Hello,
You can define an attribute in the context with the type CHAR 30 and define it value like an icon from WDA (like ~Icon/GreenLed). And then you need to create an method to define the attributes of the column that will have the image like follows:
METHOD display_alv .
DATA: lr_alv_usage TYPE REF TO if_wd_component_usage,
lr_config TYPE REF TO cl_salv_wd_config_table,
lr_col_header TYPE REF TO cl_salv_wd_column_header,
lr_function_wd TYPE REF TO cl_salv_wd_function,
lr_button TYPE REF TO cl_salv_wd_fe_button,
lr_image TYPE REF TO cl_salv_wd_uie_image,
lr_header TYPE REF TO cl_salv_wd_header,
lr_uie_link TYPE REF TO cl_salv_wd_uie_link_to_action,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_function_set TYPE REF TO if_salv_wd_function_settings,
lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA: lt_columns TYPE salv_wd_t_column_ref,
ls_column TYPE salv_wd_s_column_ref,
lv_text TYPE string.
* Instantiate ALV Component
lr_alv_usage = wd_this->wd_cpuse_all_alv( ).
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_all_alv( ).
lr_config = lr_if_controller->get_model( ).
* modify visible rows
lr_config->if_salv_wd_table_settings~set_visible_row_count( iv_rows ).
lr_config->if_salv_wd_table_settings~set_selection_mode(
wd_assist->co_alv_selmode ).
* create function
lr_function_set ?= lr_config.
lr_function_wd = lr_function_set->create_function(
wd_assist->co_func_det_nfe ).
CREATE OBJECT lr_button.
*read text
lv_text = wd_assist->read_text( iv_key = '002' ).
lr_button->set_text( lv_text ).
lv_text = wd_assist->read_text( iv_key = '001' ).
lr_button->set_tooltip( lv_text ).
lr_button->set_image_source( wd_assist->co_icon_seldet ).
lr_function_wd->set_editor( lr_button ).
* set table header
lr_table_settings ?= lr_config.
lr_header = lr_table_settings->get_header( ).
lv_text = wd_assist->read_text( iv_key = '003' ).
lr_header->set_text( lv_text ).
lv_text = wd_assist->read_text( iv_key = '004' ).
lr_header->set_tooltip( lv_text ).
lr_header->set_image_source( wd_assist->co_icon_list ).
lr_column_settings ?= lr_config.
lt_columns = lr_column_settings->get_columns( ).
LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
WHEN 'ICON'.
CREATE OBJECT lr_image.
lr_image->set_source_fieldname( ls_column-id ).
lr_image->set_tooltip_fieldname( 'ICON_TOOLTIP' ).
ls_column-r_column->set_cell_editor( lr_image ).
WHEN 'ID'.
CREATE OBJECT lr_uie_link.
lr_uie_link->set_text_fieldname( ls_column-id ).
ls_column-r_column->set_cell_editor( lr_uie_link ).
WHEN 'ICON_TOOLTIP' or 'LOGSYS'.
ls_column-r_column->set_visible(
cl_wd_uielement=>e_visible-none ).
ENDCASE.
*set header binding of medium description, otherwise title
lr_col_header = ls_column-r_column->get_header( ).
lr_col_header->set_ddic_binding_field(
if_salv_wd_c_column_settings=>ddic_bind_medium ).
ENDLOOP.
ENDMETHOD.
Here will be showed an icon (column ICON) and an link (column ID).
Regards, -
Refer to MIME image in ALV Table
Hello All,
I know now how to refer to an image in the AVL Table.
But I want to refer to the MIME image.
The filename is not enough?
Anyone an idea?
Thanks & Regards,
Chris BogersHi,
1. Here you have to mention the URL where your mime objects are stored.
data: mime_repository type ref to if_mr_api,
content type xstring,
mime_type type string,
url type string value 'SAP/BC/WebDynpro/SAP/ZTREE/s.bmp'.
mime_repository = cl_mime_repository_api=>get_api( ).
call method mime_repository->get
exporting i_url = url
importing e_content = content e_mime_type = mime_type.
2. Finally you have the value in an XString which you can bind to the context attribute.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* set single attribute
lo_el_context->set_attribute(
name = `CONTENT`
value = content ).
Note : CONTENT is my context attribute binded to image UI. -
HI,
is it possible to show a picture (image) in ALV ?
Regards,
Gordonhi
Check this blog to show image in ALV table:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9
regards
Satish -
How to display different icon within WDA alv table base on row data ?
Hi,
is that possible to display different icon for every row within ALV table depending on the row data ?
for instance if the status 'S' display ~Icon/SuccessMessage and 'E' display ~Icon/ErrorMessage ?
because base on this code below i only can set 1 icon for the whole row data.
LOOP AT lt_columns ASSIGNING <fs_column>.
CASE <fs_column>-id.
WHEN 'ICO'.
CREATE OBJECT lr_caption.
lr_caption->set_image_source( value = '~Icon/SuccessMessage').
<fs_column>-r_column->set_cell_editor( lr_caption ).
ENDCASE.
ENDLOOP.
Thank you in advance.
FernandHello,
Yes it is possible to display different images based on data.
For that what you can do is create one attribute 'STATUS' of type string in context node which you are mapping to ALV.
And fill that attribute with the path to image based on your requirement like for status 'S' set the attribute to ~Icon/SuccessMessage and if status is 'E', set it to ~Icon/ErrorMessage at runtime.
Now in the settings for ALV use the following code:
* Display icon in column seatsocc
DATA: lr_column TYPE REF TO cl_salv_wd_column,
lr_image TYPE REF TO cl_salv_wd_uie_image,
lv_icon TYPE string.
lr_column = lv_model->if_salv_wd_column_settings~get_column( 'SEATSOCC' ).
CREATE OBJECT lr_image.
lr_image->SET_SOURCE_FIELDNAME( 'STATUS' ).
lr_column->set_cell_editor( lr_image ).
in the above code, column 'SEATSOCC' will be displayed as an icon.
Sample code to fill the attribute 'STATUS'
LOOP AT lt_flights INTO ls_flight.
lv_seatsfree = ls_flight-seatsmax - ls_flight-seatsocc.
IF lv_seatsfree = 0.
ls_flight-status = 'ICON_RED_LIGHT'.
ELSEIF lv_seatsfree <= 50.
ls_flight-status = 'ICON_YELLOW_LIGHT'.
ELSE.
ls_flight-status = 'ICON_GREEN_LIGHT'.
ENDIF.
MODIFY lt_flights FROM ls_flight.
ENDLOOP.
Hope this helps!
Regards,
Srilatha
Edited by: Srilatha M on Jun 25, 2010 12:02 PM -
Checkbox,dropdown,image in ALV
Hi Experts,
I am working ALV table in Webdynpro ABAP.
My client have a requirement like
1] He want to display the check box for ist row accept and secon row reject and 4th coloumn link if you click that it will open the editor.7th coloumn inputfield and 8th image if you click that image then add two coloumns in the table below that cell.and 12h coloumn dropdown box the values coming from BAPI.and 18th image. like that........
2] these above UI elemnts will be based on the record containe in the number.
Example:1. if that BAPI gives the 3 records only three row will be appear these UI elements other rows are should be
non- editable.
2. If the BAPI giving 10 records only ten rows should appear these Ui elements.
3] Some casess based on the condition also the UI elements should non-editable in ALV.
Can you please give how to do this.Please help me these screen how to develop.time is very less.Hi,
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
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( ).
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model(
DATA lt_columns type SALV_WD_T_COLUMN_REF.
DATA ls_columns type SALV_WD_S_COLUMN_REF.
lr_column type ref to CL_SALV_WD_COLUMN
DATA:
lr_input TYPE REF TO cl_salv_wd_uie_input_field,
lr_checkbox type ref to cl_salv_wd_uie_checkbox.
CALL METHOD lv->if_salv_wd_column_settings~get_columns
RECEIVING
value = lt_columns.
LOOP AT lt_columns INTO lis_columns.
lv_id = ls_columns-id.
lr_column = ls_columns-r_column.
***Column name
CASE lv_id.
WHEN 'CARRID'.
create object lr_checkbox
EXPORTING
checked_fieldname = 'CARRID'.
lr_checkbox->set_enabled( abap_true ).
lr_column->set_cell_editor( lr_checkbox ).
WHEN 'CONNID'.
CREATE OBJECT lr_input
EXPORTING
value_fieldname = lv_id.
CALL METHOD lr_column->set_cell_editor
EXPORTING
value = lr_input.
WHEN 'FLDATE'.
endcase.
endloop.
Regards,
Lekha. -
Displaying default value for a field in ALV table
Hai all,
I am having an ALV table in which I want to display Requisition number by default using a value which i generated randomly and it is stored in a variable.
While displaying ALV table my req number field should display that value by default when ever user is inserting a row( all the coloumns n my alv are editable.
Is it possible??
Kindly give some suggestions.
Thanks in Advance,
Nalla.BHai Kris,
I took help from ur link and i declared a global attribute request_number.
and i created an event handler ON_ALV_INSERT and did the follwing coding for giving default value wen ever am inserting new row.
FIELD-SYMBOLS: <wa_row> LIKE LINE OF r_param->t_inserted_rows.
DATA bill_details TYPE REF TO zdom_bill_detail.
LOOP AT r_param->t_inserted_rows ASSIGNING <wa_row>.
bill_details ?= <wa_row>-r_value.
IF bill_details->REQ_NUMBER IS INITIAL.
DATA lo_nd_bill_detail TYPE REF TO if_wd_context_node.
DATA lo_el_bill_detail TYPE REF TO if_wd_context_element.
DATA ls_bill_detail TYPE wd_this->Element_bill_detail.
navigate from <CONTEXT> to <BILL_DETAIL> via lead selection
lo_nd_bill_detail = wd_context->get_child_node( name = wd_this->wdctx_bill_detail ).
lo_el_bill_detail = lo_nd_bill_detail->get_element( index = <wa_row>-index ).
lo_el_bill_detail->set_attribute(
EXPORTING
name = 'REQ_NUMBER'
value = wd_comp_controller->request_number
Wen am setting the value of wd_comp_controller->request_number to my context attribute am getting NULL object ref error.
lo_el_bill_detail->set_attribute(
name = `REQ_NUMBER`
value = wd_comp_controller->request_number ).
Pls give some suggestions,
Thanks in Advance,
Nalla.B -
How can i change the column label text in a alv table display
how can i change the column label text in a alv table display??
A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
<i>* declare column, settings, header object
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
get column by specifying column name.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( ' ' ).</i>
My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
<i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
i have checked in debugging and the error occured at the statement :
<i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
Thanks,
SuriI found it myself how to do it. The error says that it is not able to find the reference object i.e it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_cmdl TYPE REF TO cl_salv_wd_config_table,
lr_col TYPE REF TO cl_salv_wd_column.
DATA : node_year TYPE REF TO if_wd_context_node,
elem_year TYPE REF TO if_wd_context_element,
stru_year TYPE if_alv_layout=>element_importing,
item_year LIKE stru_year-i_current_year,
lf_string TYPE char(x),
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
Get the entered value from the input field of the screen
node_year = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
elem_year = node_year->get_element( ).
elem_year->get_attribute(
EXPORTING
name = 'IMPORT_NODE-PARAMETER'
IMPORTING
value = L_IMPORT_PARAM ).
WRITE L_IMPORT_PARAM TO lf_string.
Get the reference of the table
lr_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
lr_if_controller = wd_this->wd_cpifc_alv( ).
lr_column_settings = lr_if_controller->get_model( ).
get column by specifying column name.
IF lr_column_settings IS BOUND.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( lf_string ).
endif. -
How to delete a particular row in ALV table
Hi,
How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
Thanks
Bala DuvvuriHello Bala,
Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
data : lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_config TYPE REF TO cl_salv_wd_config_table.
lr_table_settings ?= lr_config.
** Setting the ALV selection to multiple selection with no lead selection
lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
Next delete the selected rows in the action triggered by the button:
METHOD onactiondelete_rows .
DATA: wd_node TYPE REF TO if_wd_context_node,
lt_node1 TYPE ig_componentcontroller=>elements_node,
wa_temp TYPE REF TO if_wd_context_element,
lt_temp TYPE wdr_context_element_set,
row_number TYPE i VALUE 0.
wd_node = wd_context->get_child_node( name = 'NODE' ).
CALL METHOD wd_node->get_selected_elements
RECEIVING
set = lt_temp.
LOOP AT lt_temp INTO wa_temp.
wd_node->remove_element( EXPORTING element = wa_temp ).
ENDLOOP.
CALL METHOD wd_node->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_node1.
wd_node->bind_table( new_items = lt_node1 ).
ENDMETHOD.
If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
Regards,
Uday -
Hi Experts,
I need single column to be selected from a ALV table...selected in da sense to be highlighted....as it happens..by default for a row.....
I hope u understood my query...
Please help me out in this..
I know u all will surely help me...
Thks and Regards,
Runali.Hi Runali,
Get the reference to the column settings of your ALV Model. Then you can get the reference of each column by passing the column ID. There is a method set_selected_state in the column class, but that does not highlight the column as it does for a row. So what you can use is a cell design for a column that will highlight the column with a color or whatever.
lr_column = lr_column_settings->get_column( ID = id ).
lr_column->set_cell_design( preferred design ).
Hope this helps. Please award points if it solves your purpose.
Regards,
Nithya -
UI Element : MessageArea : How to I show a ALV table instead of messages
UI Element : MessageArea : How to I show a ALV table (Message Log) instead of all the messages.
Hi,
Create a View Container UI Element at the bottom of the View and Embed ALV into it. Catch the Errors and populate into ALV instead of report message.
hope this helps u.,
Thanks & Regards,
Kiran -
How To Edit Selected Row In ALV Table
Hello Experts,
In My Webdynpro Application, I am displaying records from database table into an ALV Table.
I want to edit only selected record from ALV table.
Please Suggest How to achieve this.
Thanks,
PratibhaThe link given above is for the UI element 'Table' and does not pertain to ALV.
To Make an ALV Editable on lead selection for that particular lead selected row.
1. The ALV should be made lead selectable, when initializing
2. The ON_LEAD_SELECT function should be invoked.
3. Withing this function the index has to be retrieved to know which row was selected.
4. Based on the index retrived all the columns have to pass FALSE to read_only in the column properties.
Regards,
Pramod -
Hi,
Does any one have a code sample for the ALV Table Delete button? When I hit the DELETE button the selected row gets deleted but how can I save this deletion to the database table so that when I do a refresh the deleted row does not re-appear.
Thanks. KimHi Kim,
i am sorry but I dont have a sample code for this .. but yes i can tell you a very simple logic here that should work fine ..
When the user clicks on Delete Entry call method say "Delete_entry" and within this you can write code based on this logic..
1) On_Action_Lead_Select should copy the content of that row to another context node say "Selected_Entry"
2) Search for this entry in your internal table/database that was bound to the ALVs context node(data source) and remove it using standard functions
3) again read the database/internal table data and bind it to the context node ..
Your changes will be reflected in your ALV..
I hope this helps and if it does please do award points
Also please close the thread if the issue gets resolved ..
Regards,
Anoop -
How to create a context menu in ALV table cell editor(Webdynpro abap )
Hello Experts,
I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
The code snippet below:
"Create menu for each coloumn
create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
id = 'MITM_ACTIONS'.
lo_menu_actions->set_visible( value = abap_true ).
lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
"ADd menu items
CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
exporting
id = 'MITM_CREATE_EXPRESSION'.
lo_menu_item_create->set_visible( value = abap_true ).
lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
"Add item 1
lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ).
" Set the cell editor for each column cell(link to an action)
LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
lv_column_name = ls_node_dec_tab_cols-object_name.
lr_column = lr_column_settings->get_column( lv_column_name ).
"Create 'lta' Ui item
CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
lo_lta->set_menu( value = lo_menu_actions ).
lo_lta->set_text_fieldname( lv_column_name ).
lr_column->set_cell_editor( lo_lta ).
IF ls_node_dec_tab_cols-is_result EQ abap_true.
lr_column->set_cell_design( value =
cl_wd_table_column=>e_cell_design-key_medium ).
ENDIF.
ENDLOOP.Hi Prakash,
I have not come across this requirement till now to have context menu in a cell editor of alv.
Unfortunately the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
Regards,
Rama -
Embeding ALV table in dynamically created view container UI element
Hi ,
I created a view container UI element dynamically .that is working fine . I am using standard ALV component . Now i want to embed ALV table in View container UI element dynamically > please help me in this .
Thanks in advance ,
Vijay vorsuHi,
I am not sure how to do add an ALV table dynamically but you can have a look at this blog which talks about creating and adding a TABLE ui element dynamically. And TABLE UI element may solve your problem.
http://mamma1360.blog.163.com/blog/static/314740992008127115551165/
Thanks,
Abhishek
Maybe you are looking for
-
dear can i configre a report using SOP and not run mrp only for running report and these are the fields which i require These are the parameters required in that report 1. sales forecast(this is done annually with the monthly break up) 2. sales forec
-
Multiple Apple IDs on the same computer
We have three separate Apple IDs in our family and I need to store the iTunes media for each on the same desktop (under separate Windows user accounts). When I start to download the media for a second account on the computer, I get a message that th
-
So I tried shooting a subject on a green screen. Took the footage into Motion. Put an Image Mask on the clip telling it to use Green as Source Channel No matter what I set the mask to it simply doesnt mask at all! What is going on?
-
Hi All, What is the transaction code to see the list of customers? Regards Ashis
-
Netweaver editor is not opening!!
Hai While opening my Netweaver Editor it is showing problems during startup. check the ".log" file in the ".metadata" directory of your workspace. please tell me how to get rid of this error with Regards K. Ravi Shankar