cancel
Showing results for 
Search instead for 
Did you mean: 

IWDImage-Source as BLOB

0 Kudos

Hi all,

i want to display images with the ui-element IWDImage. My problem is, that i read an image from a fpt-server with the function 'FTP_SERVER_TO_R3'. This runs very good. But now i have the image-source in a itab from the type BLOB.

How can i bind a BLOB to the source of an IWDImage element or how can i display an image, that i have in a itab with type BLOB?

I hope somebody can help me!

Regards,

Florian

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If you have the binary content of the image in memory, you need to push it into the ICM Cache in order to generate a temporary URL which you can reference in an Image UI element. I'm not sure what you mean my IWDImage. That sounds like Web Dynpro Java, not Web Dynpro ABAP.

Here is a sample of how to publish content 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.
*  cached_response->set_compression( options = cached_response->IF_HTTP_ENTITY~CO_COMPRESS_IN_ALL_CASES ).
  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_data( lv_image ).
      l_app_type = 'image/png'.

 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 '.' 'png' into lv_image_url.

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


  wd_context->get_element( )->set_attribute(
    name =  `IMAGE_URL`
    value = lv_image_url ).

0 Kudos

Sorry, i meant the standard image UI element form Webdynpro (ABAP)!

Thanks, your solution is perfect!!!!