on 03-07-2011 3:16 AM
Experts,
My main view has an ALV table and my requirement is to display one of its column as ICON depending on the table values. I was happy to find the below link that exactly fit my requirement
https://wiki.sdn.sap.com/wiki/display/Snippets/WebDynproABAP-UsingUIelementsinALVcomponentcells
But it turned out not simple for me. After 3 days now, i still couldn't figure out where exactly is the problem.. All that i could see is the text of the icon like ICON_YELLOW_LIGHT etc., but not the ICON itself
I am 100 % sure that, i have implemented every word from the above document though i couldn't get the results..
I just wanted to see if anyone have come across such experience before..
Thanks
ASujo
Hi,
To display an ICON in a column of ALV table, you need to do the following:
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv_usage( ).
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_usage( ).
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model(
).
* 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_value->if_salv_wd_column_settings~get_column( 'SEATSOCC' )."get the reference to the column in which the image has to be displayed
CREATE OBJECT lr_image.
lr_image->SET_SOURCE_FIELDNAME( 'STATUS' )."STATUS attribute has the image path ex: ICON_RED_LIGHT
lr_column->set_cell_editor( lr_image ). "Display traffic light images in column 'SEATSOCCC'
Hope this code snippet helps you in resolving the issue.
If you are not able to solve using this, please post the code snippet you are using.
Best Regards.
Srilatha
Edited by: Srilatha M on Mar 7, 2011 4:37 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Srilatha.. I tried your code earlier but didn't work either..
But here are the 2 pieces of code that I currently have..
One in WDDOINIT method( where I am trying to set the column STAT as ICON )
DATA:
lo_cmp_usage type ref to if_wd_component_usage,
lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
lr_column_settings type ref to if_salv_wd_column_settings,
lt_columns type salv_wd_t_column_ref,
lr_image type ref to cl_salv_wd_uie_image.
DATA lv_value TYPE ref to cl_salv_wd_config_table.
FIELD-SYMBOLS
<fs_column> like line of lt_columns.
Instantiate the ALV component
lo_cmp_usage = wd_this->wd_cpuse_cmp_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
*Get reference to model
lo_INTERFACECONTROLLER = wd_this->wd_cpifc_cmp_alv( ).
lv_value = lo_interfacecontroller->get_model( ).
*Set the UI elements
lr_column_settings ?= lv_value.
lt_columns = lr_column_settings->get_columns( ).
loop at lt_columns ASSIGNING <fs_column>.
case <fs_column>-id.
when 'STAT'.
create object lr_image.
lr_image->set_source_fieldname( <fs_column>-id ).
<fs_column>-r_column->set_cell_editor( lr_image ).
free lr_image.
endcase.
endloop.
Second piece of code is in WDDOMODIFYVIEW where actually i am setting the ICON
ldetails-rno = ltable-receiptno.
ldetails-exp_type = ltable-exp_type.
ldetails-stat = '~Icon/YellowLed'.
append ldetails to lt_details.
Let me know if you observe anything different
Hi,
The same code which you posted works properly for me. BTW why you are filling the context data in WDDOMODIFYVIEW??
You shouldnt do in that method as it gets executed everytime theres a user interaction. It would be better to fill the context in WDDOINIT.
The code looks perfect. I am not sure why this is not working for you. are you still seeing the text '~Icon/YellowLed' in STAT column??
Best Regards,
Srilatha
Code is fine.
it should work.
Only thing that could cuase the icon to be replaced by the text is that the cell editor itself is not gettign changed.
check whether it is really having an attribute of name 'STAT'.
then try to put a breakpoint here
case <fs_column>-id.
when 'STAT'.
-------->>>> create object lr_image.
lr_image->set_source_fieldname( <fs_column>-id ).
<fs_column>-r_column->set_cell_editor( lr_image ).
free lr_image.
endcase.
endloop.
and check whether it enters here and change the cell editor.
and also r u getting any javascript error...
and what is the exact text you are getting for the image .. is it ~icon/yellowled
thanks
sarbjeet singh
Edited by: sarbjeet singh on Mar 7, 2011 12:09 PM
Hi,
The code seems to me fine as well except that in the example document it is `Icon/YellowLed` and in your source it is 'Icon/YellowLed'. However i do not think this as the problem.
i also assume that you bind the lt_details to the context node after this code
ldetails-rno = ltable-receiptno.
ldetails-exp_type = ltable-exp_type.
ldetails-stat = '~Icon/YellowLed'.
append ldetails to lt_details.
Thanks to all who have responded to this.. But to answer your questions, yes, I do have the proper binding since the text atleast shows up in the correct column(STAT) which means i do have the correct column ID( STAT )
Srilatha: I am checking the parameter first_time in MODIFYVIEW though i didn't post it here.. so i am sure that should be okay to have under that method
But i am going to try investigate more to see if i missed anything else and post here any issues that i identified..
ASujo
Update:
It works fine now.. I realized that, I created the ALV column(STAT) as "input field". I recreated this column with the property "Image" and now all works fine.. Infact, I completely revered my code implementation suggested in the article and it still works good.. It seems to me that, all I need is the property of the column to be set to "image" and pass the code of what ICON i need through context binding. Rest is taken care of by dynpro.. Sweet !!!
Thanks to you all for your suggestions...
ASujo
Bhaskaran,
I think you totally misunderstood. I just followed the linked article hoping that it would work as it is. The article didn't mention about changing the layout property of the column.. I certainly isn't smart enough to know the difference.
I posted my code based on the request from one of the responder. When I later found out that it was to do with the layout property, i updated my posting so it could help anyone who happened to be in my situation..
Anyway, the reason for my response to you is to clarify any misunderstanding..
ASujo
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.