2021 Jan 18 9:46 PM
Hi everyone,
I'm writing because I'm facing a problem using ABAP class cl_gui_html_viewer.
The requirement is to extract all image files saved in transaction XD03 from GOS for further usage to display an HTML file in HTML viewer.


Unfortunately, I came across when HTML viewer has displayed all data, some images are displayed correctly and some other does not appear, what appears is the 'X' or some other does not appear anything.
- Correct display.

- Incorrect display (No Image).


I don't understand what's wrong with the program so If somebody might help me to solve this issue.
I attach a small part of the code:
* Creates Container
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = 'CUST_CONT_1'.
ENDIF.
* Creates HTML Control
IF html_control IS INITIAL.
CREATE OBJECT html_control
EXPORTING
parent = custom_container. " Container
ENDIF.
* ITAB containing IMAGE code.
IF im_t_kunnr_image[] IS NOT INITIAL.
* Build image name.
CONCATENATE c_image_url_
im_s_outtab-bukrs
'_'
im_s_outtab-kunnr
'_'
im_image_count
INTO lv_image_name.
* Load image data into URL variable.
im_html_control->load_data(
EXPORTING
url = lv_image_name
type = c_image "'image'
subtype = c_jpg "'.jpg'
IMPORTING
assigned_url = lv_image_url
CHANGING
data_table = im_t_kunnr_image ).
* Defines table for image.
ex_t_html = VALUE #( BASE ex_t_html
( '<table>' )
( '<tr align="center">' )
( '<th align="center"><img src="' && lv_image_url && '" style="width:40%;"></th>' )
( '</tr>' )
( '</table>' ) ).
ENDIF.
* Load data HTML itab.
html_control->load_data(
IMPORTING
assigned_url = lv_html_url
CHANGING
data_table = html_table ).
* Get URL to be displayed in container.
html_control->show_url(
EXPORTING
url = lv_html_url ).
* Display HTML Preview
CALL SCREEN 0100.
Thanks for your comments.
Hi everyone,
I'm writing because I'm facing a problem using ABAP class cl_gui_html_viewer.
The requirement is to extract all image files saved in transaction XD03 from GOS for further usage to display an HTML file in HTML viewer.


Unfortunately, I came across when HTML viewer has displayed all data, some images are displayed correctly and some other does not appear, what appears is the 'X' or some other does not appear anything.
- Correct display.

- Incorrect display (No Image).


I don't understand what's wrong with the program so If somebody might help me to solve this issue.
I attach a small part of the code:
* Creates Container
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = 'CUST_CONT_1'.
ENDIF.
* Creates HTML Control
IF html_control IS INITIAL.
CREATE OBJECT html_control
EXPORTING
parent = custom_container. " Container
ENDIF.
* ITAB containing IMAGE code.
IF im_t_kunnr_image[] IS NOT INITIAL.
* Build image name.
CONCATENATE c_image_url_
im_s_outtab-bukrs
'_'
im_s_outtab-kunnr
'_'
im_image_count
INTO lv_image_name.
* Load image data into URL variable.
im_html_control->load_data(
EXPORTING
url = lv_image_name
type = c_image "'image'
subtype = c_jpg "'.jpg'
IMPORTING
assigned_url = lv_image_url
CHANGING
data_table = im_t_kunnr_image ).
* Defines table for image.
ex_t_html = VALUE #( BASE ex_t_html
( '<table>' )
( '<tr align="center">' )
( '<th align="center"><img src="' && lv_image_url && '" style="width:40%;"></th>' )
( '</tr>' )
( '</table>' ) ).
ENDIF.
* Load data HTML itab.
html_control->load_data(
IMPORTING
assigned_url = lv_html_url
CHANGING
data_table = html_table ).
* Get URL to be displayed in container.
html_control->show_url(
EXPORTING
url = lv_html_url ).
* Display HTML Preview
CALL SCREEN 0100.
Thanks for your comments.
2021 Jan 19 4:39 AM
Are all the images .jpg files?
Are there any similarities between the images that does not work?
Is the lv_image_name and lv_image_url turning out correct?
2021 Jan 19 7:52 AM
I second Jörgen + the parameter SIZE (number of bytes) of LOAD_DATA is missing, you should pass the exact image size otherwise SAP will calculate it like number of lines of table im_t_kunnr_image multiplied by line size, which will probably consider extra null bytes, and they may be incorrectly interpreted.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |