cancel
Showing results for 
Search instead for 
Did you mean: 

Publish Icon with DP_PUBLISH_WWW_URL

Former Member
0 Kudos

Hai,

I wanted to use SAP Icons in cl_gui_html_viewer.

I wanted to have the url of the sap Icons.

I know we can publish the Images in the web repository with <b>DP_publish_www_url</b>.

Do I have to pubish them or if they are readily available for use.

regards,

venkat

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

You can achive this by using load_data of html viewer.

Steps to follow:

1)First load mime LOAD_MIME_OBJECT

2)build html

3)read url

4)show url

Check the following code.

*&---------------------------------------------------------------------*
*&      Form  LOAD_HTML_VIEWER
*&---------------------------------------------------------------------*
FORM load_html_viewer.
  DATA : html_alignment TYPE i.
*   CREATE HTML VIEWER
  CREATE OBJECT htmlviewer
    EXPORTING
       parent = custom_container
    EXCEPTIONS
      others         = 1.
  IF sy-subrc <> 0.
    MESSAGE i000(zmsg) WITH 'HTML Viewer Error'.

    EXIT.
  ENDIF.
*   Alignment
  html_alignment = htmlviewer->align_at_left  +
                   htmlviewer->align_at_right +
                   htmlviewer->align_at_top   +
                   htmlviewer->align_at_bottom.

  CALL METHOD htmlviewer->set_alignment
    EXPORTING
      alignment = html_alignment
    EXCEPTIONS
      OTHERS    = 1.
  IF sy-subrc <> 0.
    MESSAGE i000(zmsg) WITH 'Control Alignment Error'.
    EXIT.
  ENDIF.
  PERFORM load_data_to_html.
ENDFORM.                    " LOAD_HTML_VIEWER

*&---------------------------------------------------------------------*
*&      Form  LOAD_DATA_TO_HTML
*&---------------------------------------------------------------------*
FORM load_data_to_html.
  TYPES :t_html(130) TYPE c.
  DATA : l_url(80)        TYPE c,
         lt_html  TYPE STANDARD TABLE OF t_html,
         x_html LIKE LINE OF lt_html.
         
  CALL METHOD htmlviewer->LOAD_MIME_OBJECT
     EXPORTING
** here you can use your icon id
          OBJECT_ID  = 'HTMLCNTL_TESTHTM2_SAPLOGO'  
          OBJECT_URL = 'SAPLOGO.GIF'
     EXCEPTIONS
          OTHERS     = 1.
          
  x_html = '<html><h1>My Test Page<h1>'.
  APPEND x_html TO lt_html.
  x_html = '<br><img src="SAPLOGO.GIF"></html>'.
  APPEND x_html TO lt_html.

  CALL METHOD htmlviewer->load_data
   EXPORTING
*     URL                  =
     TYPE                 = 'html'
     SUBTYPE              = 'html'
   IMPORTING
      assigned_url         = l_url
    CHANGING
      data_table           = lt_html
    EXCEPTIONS
      dp_invalid_parameter = 1
      dp_error_general     = 2
      cntl_error           = 3
      OTHERS               = 4 .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
*  Display html data.
  CALL METHOD htmlviewer->show_data
    EXPORTING
      url                    =  l_url
    EXCEPTIONS
      cntl_error             = 1
      OTHERS                 = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
ENDFORM.                    " LOAD_DATA_TO_HTML

Thanks,

Venu.

athavanraja
Active Contributor
0 Kudos

check out sample program in dynamic document

<b>DD_ADD_PICTURE</b>

for the same .

Regards

Raja

Former Member
0 Kudos

Thanks raja,

I am not using Dynamic documents

and wanted to use the pictures for displaying in the plane html in htmlviewer.

I want a link some thing to include in <img src="...">

So I am publishing the images in swww with dp_publish_www_url and using then in the src attribute of img tag.

one other way is use load_mime_object in cl_gui_html_viewer to load the mime objects.

regards,

venkat

regards,