cancel
Showing results for 
Search instead for 
Did you mean: 

Display HTML code in WebDynpro for ABAP

tobias_haak
Explorer
0 Kudos

Hi, I would like to display a html page in a WebDynpro View, ie: I have the html code in a "string" variable and would now display this string now not with the html tags visible, but as a "real" html page.

I found a thread in WebDynpro for ABAP but I am a little bit lost in converting the logic to ABAP world.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I found a thread in WebDynpro for ABAP but I am a little bit lost in converting the logic to ABAP world.

I'm a little bit confused by this statement. Do you mean you found a thread in Web Dynpro Java, perhaps?

Regardless the approach is possible using the iFrame UI. The warning about the iFrame is that it is deprecated in NetWeaver 7.0 and 7.01 and my not be usable depending upon your support package level. However in NetWeaver 7.02 the iFrame returns to fully supported status.

If you have the HTML content in a string, you can simply place it into the ICM cache. This will provide a temporary URL for the content (you supply the lifetime of the URL) that can be referenced via the iFrame URL or even the LinkToURL if you want to open in a new window.

Here is the code for placing the string into the ICM Cache:

****Create the cached response object that we will insert our content into
  data: cached_response type ref to if_http_response.
  create object cached_response
    type
      cl_http_response
    exporting
      add_c_msg        = 1.
  try. " ignore, if compression can not be switched on
      call method cached_response->set_compression
        exporting
          options = cached_response->co_compress_based_on_mime_type
        exceptions
          others  = 1.
    catch cx_root.
  endtry.
****set the data and the headers
  data: l_app_type type string.

      cached_response->set_cdata( lv_html_text ).
      l_app_type = 'text/html'.

 cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                     value = l_app_type ).

  cached_response->set_status( code = 200 reason = 'OK' ).
  cached_response->server_cache_expire_rel( expires_rel = 60 ).
  data: guid type guid_32.
  call function 'GUID_CREATE'
    importing
      ev_guid_32 = guid.
  concatenate '/sap/public' '/' guid '.' 'html' into lv_iframe_url.

****Cache the URL
  cl_http_server=>server_cache_upload( url      = lv_iframe_url
                                       response = cached_response ).


  wd_context->get_element( )->set_attribute(
    name =  `IFRAME_URL`
    value = lv_iframe_url ).

Former Member
0 Kudos

Hello Sir,

I followed everything what you said. It works perfectly and displays html string in the IFRAME.

However some of the HTML characters are still displayed in the IFRAME. for e.g » TEST HTML «

Now in the IFRAME we see it as » TEST HTML «

I was expecting the IFRAME can render » character and display it in HTML.

Can you help me understand why is it displaying this special character?

Cheers

Daniel-Alex
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear Thomas,

works fine - thanks for the example so far.

Another question: is it possible to update the content with new data reusing the http response object and the URL? I tried to set "new data" on changing the lead selection of my elements, hoping that the new content is shown; but it always displays the initial content.

Any idea to solve this as well?

Best regards, Daniel

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Sounds like it might just be a caching issue.  That is why I use a GUID in the URL in my example. That makes the URL unique and by binding a new URL to the iFrame it will force the new content to load.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Sir,

I followed everything what you said. It works perfectly and displays html string in the IFRAME.

However some of the HTML characters are still displayed in the IFRAME. for e.g » TEST HTML «

Now in the IFRAME we see it as » TEST HTML «

I was expecting the IFRAME can render » character and display it in HTML.

Can you help me understand why is it displaying this special character?

Cheers