Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issue when displaying images using cl_gui_html_viewer!

guillermo_espaa2
Explorer
0 Likes
3,391

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.

2 REPLIES 2
Read only

joltdx
Active Contributor
2,403

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?

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,403

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.