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

CL_GUI_HTML_VIEWER - HTML with image https://scn.sap.com/thread/3854272

Former Member
0 Likes
3,439

First of all - I read this post: https://scn.sap.com/thread/3854272

However I still don't get my image to display.

The HTML is correctly parsed: src="MIME000004"

This is the code to add the image (which is stored in SMW0) and to retrieve the URL:

*   Get URL
    CALL METHOD html_viewer->load_mime_object
      EXPORTING
        object_id            = objid
      IMPORTING
        assigned_url         = -url
      EXCEPTIONS
        others               = 1.
    IF sy-subrc <> 0.
      RAISE not_found.
    ENDIF.

Output:

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,195

This process is working just fine. I had another defect in my report, where i passed on the original HTML template to CL_GUI_HTML_VIEWER, rather then the version that i had updated URL for my image.

Below is a high level flow of my report:

* Load Data
  CALL METHOD html_viewer->load_data
    EXPORTING
      subtype      = 'html'
    IMPORTING
      assigned_url = lv_url
    CHANGING
      data_table   = lt_html
    EXCEPTIONS
      OTHERS       = 1.
       
...

* Show Data
  CALL METHOD html_viewer->show_data
    EXPORTING
      url    = lv_url
    EXCEPTIONS
      OTHERS = 1.

...

* Attach Images to HTML Viewer
  CALL METHOD html_viewer->load_mime_object
     EXPORTING
       object_id  = ls_image-objid
       object_url = ls_image-url
     EXCEPTIONS
       OTHERS     = 1.            

You can see i even "show the data" before loading the mime objects, although this may not make any logical sense, it just happened this way, as i added the image capability as an add-on and it would require more signficant changes to execute this in "logical" order.

You can also check SAP's samples which should be available in you system: RSDEMO_HTML_VIEWER

1 REPLY 1
Read only

Former Member
0 Likes
1,196

This process is working just fine. I had another defect in my report, where i passed on the original HTML template to CL_GUI_HTML_VIEWER, rather then the version that i had updated URL for my image.

Below is a high level flow of my report:

* Load Data
  CALL METHOD html_viewer->load_data
    EXPORTING
      subtype      = 'html'
    IMPORTING
      assigned_url = lv_url
    CHANGING
      data_table   = lt_html
    EXCEPTIONS
      OTHERS       = 1.
       
...

* Show Data
  CALL METHOD html_viewer->show_data
    EXPORTING
      url    = lv_url
    EXCEPTIONS
      OTHERS = 1.

...

* Attach Images to HTML Viewer
  CALL METHOD html_viewer->load_mime_object
     EXPORTING
       object_id  = ls_image-objid
       object_url = ls_image-url
     EXCEPTIONS
       OTHERS     = 1.            

You can see i even "show the data" before loading the mime objects, although this may not make any logical sense, it just happened this way, as i added the image capability as an add-on and it would require more signficant changes to execute this in "logical" order.

You can also check SAP's samples which should be available in you system: RSDEMO_HTML_VIEWER