cancel
Showing results for 
Search instead for 
Did you mean: 

Show image in Web Dynpro ALV column

uta_bchner
Explorer
0 Kudos

Hello everybody,

I have a WD component with an ALV table bound to a context node. Works very fine so far.

Now in the first column of the node I have put an image source (MIME object in my WD component).

I configured the first ALV column as Link To Action and now would like to link it to the image source. My problem is that the image is not loaded in the ALV.

This is my coding (INIT method of my view):

METHOD wddoinit .

DATA: lo_alv_cmp TYPE REF TO if_wd_component_usage,

lo_alv_if TYPE REF TO iwci_salv_wd_table,

lo_alv_config TYPE REF TO cl_salv_wd_config_table,

lo_column_settings TYPE REF TO if_salv_wd_column_settings,

lo_column TYPE REF TO cl_salv_wd_column,

lo_link_to_action TYPE REF TO cl_salv_wd_uie_link_to_action.

  • get instance of ALV component

lo_alv_cmp = wd_this->wd_cpuse_alv( ).

IF lo_alv_cmp->has_active_component( ) IS INITIAL.

lo_alv_cmp->create_component( ).

ENDIF.

  • get instance of ALV Interface Controller

lo_alv_if = wd_this->wd_cpifc_alv( ).

  • configure ALV

lo_alv_config = lo_alv_if->get_model( ).

lo_column_settings ?= lo_alv_config.

lo_column = lo_column_settings->get_column( 'IMAGE' ).

CREATE OBJECT lo_link_to_action.

  • fix settings for test purpose (how must I change it to get the information from the context node??)

lo_link_to_action->set_image_height( '50px' ).

lo_link_to_action->set_image_width( '50px' ).

lo_link_to_action->set_image_source( 'ICE Flottenportal.jpg' ).

lo_column->set_cell_editor( lo_link_to_action ).

ENDMETHOD.

Thanx a lot in advance for any help!!

Accepted Solutions (1)

Accepted Solutions (1)

uta_bchner
Explorer
0 Kudos

Sorry for not explaining clearly enough. I will try again:

The context node which is bound to the ALV has a field "image_source" in which the image source is saved as string value.

What I want do do now is to bind this value to the IMAGE_SOURCE attribute of my LINK TO ACTION column.

Is there any method etc. for doing this?

Thank you!

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

you can use the method CL_SALV_WD_UIE_LINK_TO_ACTION->SET_IMAGE_SOURCE_FIELDNAME to bind the context attribute which contains the image path.

BR, Saravanan

Answers (5)

Answers (5)

uta_bchner
Explorer
0 Kudos

Oh, I see... quite obvious, but I misunderstood the method at first.

Thank you!

uta_bchner
Explorer
0 Kudos

Thanks a lot for your helpful advice.

I now found that method cl_wdr_utilities=>get_mime_path is the best way to get the path.

But one question is still open:

How can I retrieve my image source from the context? Do I have to read the context and then write it to the image_source attribute? Or ist there a more elegant solution?

Thank you for any help!

former_member199125
Active Contributor
0 Kudos

What do you mean reading image source from context? I dont think we have a method to retrieve the image source location.

Generally you have to hardcode the image source value.

Regards

Srinivas

gill367
Active Contributor
0 Kudos

As suggested, you need to give the complete path of the image from the MIME repositroy.

like as follows.

'/SAP/BC/WebDynpro/SAP/<ur comp>/<imagename>'

Thanks

sarbjeet singh

Former Member
0 Kudos

You need to refer the full path of the image location.

You can try something like this and replace <component_name> with you component name

lo_link_to_action->set_image_source( 'Isap/bc/webdynpro/sap/<component_name>/CE Flottenportal.jpg' ).

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

check this thread which explains about how to construct the MIME image URL.

BR, Saravanan