Hello,
in my project I have an ALV, when I click on an image I retrieve image data that I display in a screen via the following ABAP code:
pict_url TYPE c LENGTH 255,
html_tab TYPE tchar255,
lv_content_changed TYPE boolean.
* Create main container
DATA(custom_container) = NEW cl_gui_custom_container( container_name = ‘CONTAINER_600’ ).
* Create HTML control
DATA(html_control) = NEW cl_gui_html_viewer( parent = custom_container ).
* Get the binaries for pictures to preview
DATA(lt_pict_bin) = r_app->get_pict_bin_preview( ).
CHECK lt_pict_bin IS NOT INITIAL.
html_tab = VALUE #( ( ‘<html><body><basefont face=”arial”>’ ) ).
LOOP AT lt_pict_bin INTO DATA(ls_pict_bin).
html_control->load_data( EXPORTING url = ls_pict_bin-filename
type = ‘image’
subtype = ‘html’
IMPORTING assigned_url = pict_url
CHANGING data_table = ls_pict_bin-bin
iscontentchanged = lv_content_changed
EXCEPTIONS dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
html_syntax_notcorrect = 4 ).
APPEND ‘<img src=”‘ && pict_url && ‘” style=”width:20em;height:auto;”>’ TO html_tab.
ENDLOOP.
APPEND ‘</body></html>’ TO html_tab.
html_control->load_data( IMPORTING assigned_url = html_url
CHANGING data_table = html_tab ).
html_control->show_url( EXPORTING url = html_url ).
html_control->close_document( ).
html_control->free( ).
custom_container->free( ).
FREE: html_control, html_tab, html_url, pict_url, lt_pict_bin.
This works well… for the 1st selection… if I select another line of my ALV, it displays images but those of the 1st selection and I am absolutely sure that they are not the same images. However, I delete my objects, the URL is necessarily different, in short I am stuck.
Maybe a cache problem? In this case how to reset it with each selection?
Is this the right approach in 2024 to display images in an ABAP screen?
Thank you for your help.