cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Use of Mime in component

Former Member
0 Kudos

Dear All,

I'm using an iframe to display html content on my WDA iView. The html content is presently uploaded as MIME in my component. I want to make this dynamic.

Can any of you experts tell me a way by which I can make this MIME upload dynamic. My idea is to generate the html content runtime and place the same in the MIME of the component.

Any help i this regd would be highly appreciated.

Regds.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well you can manipulate the MIME content at runtime by using the API: CL_MIME_REPOSITORY_API. However if your content is temporary, it is more efficient to just place the content directly into the ICM cache. You don't have the overhead of having to both write and then delete it from the database. Here is an example of how you can do this:

****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 ).

Answers (1)

Answers (1)

Former Member
0 Kudos

Thankx a lot Mr. Thomas. Just one more thing for confirmation : Using this approach, the MIME content becomes a temporary storage area for the dynamic content?? , ie, I need not worry about the deletion of the created content post usage.

Thankx again.

Regds.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Thankx a lot Mr. Thomas. Just one more thing for confirmation : Using this approach, the MIME content becomes a temporary storage area for the dynamic content?? , ie, I need not worry about the deletion of the created content post usage.

>

> Thankx again.

>

> Regds.

Correct the content is temporarily stored in the cache storage of the ICM itself. The cache lifetime is managed by the ICM itself. If you are curious you can read more about the ICM cache here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/1ef7f8c26a4e73e10000000a42189c/frameset.htm

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/89d462714735e1e10000000a42189c/frameset.htm

There are tools to monitor what is in the ICM cache, to control how many entries and how big the cache can get, and ones to manually clear the cache.

The ICM cache is also very fast to access since it never touches the ABAP layer. No session has to be created and nothing swapped into the work processes. Objects in the ICM cache, when accessed, only touch the C layer of the kernel.