cancel
Showing results for 
Search instead for 
Did you mean: 

Display a picture (binary) inplace a WebDynpro application.

Former Member
0 Kudos

Hi,

I am developing an application in Web Dynpro ABAP. In this application, a product catalog is displayed in a table.

When you click on a product, the user gets a detailed view of this article. In this detailed view to the user will also get a picture of the product.

However, the images are located in the document root (Tcode CV03N) of the material and not in the MIME folder of the application. I managed it to get the Picture as a binary file type XSTING into a context-attribute and display the result with the UIElement "File download" in a new browser window.

But i would like to display this image inplace the existing View.

So is there a possibility to display an binary xstring inplace a WebDynpro view?

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You can create a temporary URL for the content by placing the XSTRING 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/jpg'.

 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 '.' 'jpg' 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 ).

Another option would be to create your ICF Handler class. That's a bit more complicated to explain in a forum posting, but if that path interest you I can point you to a tutorial.

Former Member
0 Kudos

Hi Thomas,

thanks a lot. This answer solved my problem!

Regards.

Former Member
0 Kudos

Hi Thomas,

In the solution you provide you say that the URL is temporary, right? How long after the creation is the URL deleted? Is it immediate?

Thank you very much.

Cheers,

Ricardo

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

In the code you specify how long you want the content/URL to stay alive. In my example it lives for 60 seconds:

cached_response->server_cache_expire_rel( expires_rel = 60 ).

0 Kudos

Can you provide a tutorial for me? Thank you

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

@ye yongliu - sorry but I don't remember what tutorial I had in mind when I wrote that response 10 years ago.

Answers (0)