cancel
Showing results for 
Search instead for 
Did you mean: 

Display image in view

Former Member
0 Kudos

Hi,

My requirement is to create a web dynpro application where the first view contains all images stored in ECC along with one button (Display image). When the user clicks on the button Display image then another view should display the image on the screen.

I have created View1 with a table,which display the details of the table STXBITMAPs in it,when i select a row and press a button second view is displayed with a UI conatiner of type IMAGE.

Basiccaly when button on view1 is pressed, I get the value of the TDNAME field via lead_selection method and set this value to a global attribute, whch inturn is copied into second view and bonded to the SOURCE attribute of the UI element.

My problem is , that global attribute is being updated probley and value have been passed to second view..but Image is not being displayed on the screen.

Can anyone help me out in this.

Thanks in advance.

Pooja

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks.

Former Member
0 Kudos

hi ,

right click ur application and then click on create mime object.

with Mime Objects u cn upload doc , jpeg, or giff files from our local system into the webdypnpro system .

You can even try creating the MIME objects in webdynrpo abap .

Right click on ur component->mime object->import

after importing you can see that image into your component as MIME object .

Now insert a UI element image into your 2nd view layout .

Go to the source property of IMAGE element and select F4 option , u will find a window is opening with some tabs

Select tab COMPONENT IMAGES and component name select your component .

You will find the image which you have imported into this section just select the image and save it.

In the transaction sicf/bc/webdynpro , u cn check your component name there you can view the mime objects created by you .

also refer the SAP online help :

http://help.sap.com/saphelp_crm50/helpdata/en/46/bb182fab4811d4968100a0c94260a5/content.htm

to knw more abt mime repositories.

http://help.sap.com/saphelp_nw04/helpdata/en/f3/1a61a9dc7f2e4199458e964e76b4ba/content.htm

regards,

amit

Former Member
0 Kudos

Amit,

Thanl=ks for quick respone, but my requirement is to display the all the images existing in the ECC in view1 and selecting the one of the image from view1 and displaying the same in view2.

I guess images in the ECC are stored in the table STXBITMAPS right?

I ma not clear to display these images do I need to create MIME repository first/ or do i have to just display the content of this table and use one of the field??? to display the image in second view.

Pooja

Former Member
0 Kudos

hi

in ur first view , u may wish all the images to appear in one table column , the following code can help u


    DATA lv_image TYPE xstring.
    SELECT SINGLE imagestring FROM z2ts_images INTO lv_image
      WHERE userid = wa_roleowners-userid.

       DATA: cached_response TYPE REF TO if_http_response.
    CREATE OBJECT cached_response
      TYPE
        cl_http_response
      EXPORTING
        add_c_msg        = 1.

****set the data and the headers
    DATA: l_app_type TYPE string.
    DATA: l_xstring TYPE xstring.
    cached_response->set_data( lv_image ).
    l_app_type = '.JPG'.

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

*Set the Response Status
    cached_response->set_status( code = 200 reason = 'OK' ).

*Set the Cache Timeout - 60 seconds - we only need this in the cache
*long enough to build the page and allow the Image on the
*Client to request it.
    cached_response->server_cache_expire_rel( expires_rel = 60 ).

    DATA r_url TYPE string.
*Create a unique URL for the object
    DATA: guid TYPE guid_32.
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_32 = guid.
    CONCATENATE  '/sap/public' '/' guid '.' 'JPG' INTO wa_table-image.

*Cache the URL
    cl_http_server=>server_cache_upload( url      = wa_table-image
                                         response = cached_response ).

regds,

amit

Former Member
0 Kudos

hi ,

in the second view , u can insert a UI image and bind its source property to a context attribute of type XSTRING

u can set it using set_attribute method

rgds,

amit

Former Member
0 Kudos

Amit,

Could you please help me in clarifying few of my doubts:

Can't we images existing in the ECC in the web browser using WebDynpro ABAP?

Do we need to create MIME repository before displaying images?

Cant BMP images be displayed via web dynpro abap?

Pooja

Former Member
0 Kudos

If you want to display any image then it should exist in MIME repository. When you add a image UIElement in your view, the image source alswys refers to MIME repository or is shown existing SAP GUI icon images.

Thanks

Vishal

Former Member
0 Kudos

Hi Vishal,

Can you tell me how to create MIME repository of all the images existing in the ECC(tabe STXBITMAPS).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You don't necessarily have to move your images from STXBITMAPS to the MIME repository. You can display any image - not just those in the MIME repository, by placing the content in the ICM Cache. This creates a temporary URL for any content. So you just need to read the binary content of the image from STXBITMAPS into a XSTRING variable. From there you can use this code sample to put the content in the cache and generate a URL:

****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.
  data: l_xstring type xstring.
      cached_response->set_data( me->gx_content ).
      l_app_type = 'image/x-ms-bmp'.

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

****Set the Response Status
  cached_response->set_status( code = 200 reason = 'OK' ).

****Set the Cache Timeout - 60 seconds - we only need this in the cache
****long enough to build the page and allow the IFrame on the Client to request it.
  cached_response->server_cache_expire_rel( expires_rel = i_cache_timeout ).

****Create a unique URL for the object
  data: guid type guid_32.
  call function 'GUID_CREATE'
    importing
      ev_guid_32 = guid.
  concatenate i_path '/' guid '.' i_format into r_url.

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

Former Member
0 Kudos

null

sorry ..just ignore this post

Edited by: Pooja Gupta on Jan 15, 2010 10:45 AM

Edited by: Pooja Gupta on Jan 15, 2010 10:59 AM

Former Member
0 Kudos

Hello Thomas,

Thanks for your valuable inputs, but I am afraid the image is still not being displayed, Writing down the steps that I have been following just before the code you hace supplied:

1. I am reading the value of the STXBITMAPS-tdname in a string type variable

2.then using the FM 'SCMS_STRING_TO_XSTRING' to convert the string value to xstring type.

3.and using this converted xstring value in setting the data in the cache.

I am not sure if i ma following the right approach, secondly can you let me know the value of the i_path to be set in concatenation statement.

PS: i am using /usr/sap/public/ as i_path value.

looking forward soem suggestions.

PS: I am using ECC 6.0 with enhancement pack 4.0

Pooja

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>1. I am reading the value of the STXBITMAPS-tdname in a string type variable

Are you sure TDNAME has the content of the bitmap? It sounds like a field that would just have the name of the file and not the actual content. Why would the content be in STRING variable since it is binary content.

Also don't put all the cached URLs into the content. The caching only lasts 60 seconds. The cache could be expiring before you can access the images. Instead list the link to the images as linkToAction. In the event handler of the Action, build the temporary URL.

am not sure if i ma following the right approach, secondly can you let me know the value of the i_path to be set in concatenation statement.

PS: i am using /usr/sap/public/ as i_path value

That seems like a valid path to use. I often use the path of my application, but using the public path should work as well.