cancel
Showing results for 
Search instead for 
Did you mean: 

Image in ALV

former_member574468
Participant
0 Kudos

hi,

I want to display images ( own photos) dynamically in ALV WDYnot in a table...

How can i do that?

Kindly help me to come out from this scenariao

Thanks in Advance...

Vimal raj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,



  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_model = 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_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 ). "Display traffic light images in column 'SEATSOCCC'

Have a look at the above code. Here, the code is for displaying an image in column 'SEATSOCC'.

First you have to get alv model 'lv_model'.

And then get the reference to the column in which you want to display an image 'lr_column'.

create an image object 'lr_image'

set image's source. In the above code, 'STATUS' is the attribute which holds the path to Image MIME Object. 'STATUS' attribute has to be there in the context node which is mapped to ALV table.

set the image as cell editor for the column.

Hope this helps!

Best Regards,

Srilatha

former_member574468
Participant
0 Kudos

Hi Srilatha,

Can you give me a detail code regarding this scenario.

Thanks,

Vimal

gill367
Active Contributor
0 Kudos

HI

Store the image in the mime repository of the web dynpro component.

add one more attibute to the mode which is bound to the mapped to the data node of ALV comp.

type string.

then fill the mode again with this attirbute having the URL for the mime image object.

here is the sample code for that.

DATA lt_zdealer TYPE wd_this->Elements_zdealer.
  DATA ls_zdealer LIKE LINE OF lt_zdealer.
  data indx type i.
** @TODO compute values
** e.g. call a data providing FuBa
*
  data url type string.
  url = '/SAP/BC/WebDynpro/SAP/ZSSG_FEB_EXPL4/'.
  DATA URL1 TYPE STRING.
  loop at lt_zdealer into ls_zdealer.
   indx = sy-tabix mod 3.
   if indx eq 0.
     CONCATENATE URL 'Blue hills.jpg' INTO URL1.
    ls_zdealer-Imageurl = URL1.

    elseif indx eq 1.
       CONCATENATE URL 'Sunset.jpg' INTO URL1.
    ls_zdealer-imageurl  = URL1.
    else.
        CONCATENATE URL 'Winter.jpg' INTO URL1.
      ls_zdealer-imageurl  = URL1.
      endif.
       url1 = ''.
      modify lt_zdealer from ls_zdealer.
    endloop.

** bind all the elements
  node->bind_table(
    new_items            =  lt_zdealer
    set_initial_elements = abap_true ).
*

then go to the place where you are producing the alv.

if it is opening in the intitial screen itself, then get the model of the ALV and change the editor and set it to image and set the

source of this editor to that attribute.

here is the sample code.

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 lo_value TYPE ref to cl_salv_wd_config_table.
    lo_value = lo_interfacecontroller->get_model(
    ).
data col type ref to  CL_SALV_WD_COLUMN.
col = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'IMAGEURL' ).
data image type ref to cl_salv_wd_uie_image.
CREATE OBJECT image.
 image->SET_SOURCE_FIELDNAME( 'IMAGEURL' ).
COL->SET_CELL_EDITOR( image  ).

thanks

sarbjeet singh

former_member574468
Participant
0 Kudos

Thanks ,

Issue solved...

Points awarded...

Answers (0)