cancel
Showing results for 
Search instead for 
Did you mean: 

How to present pics from SAP folder?

Former Member
0 Kudos

Hi,

I would like to present a pic that is on the SAP folder (visible via AL11).

I want to use logical filename to get the path to that gif.

How can I present this pic on the screen?

Thanks,

Itay

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi itay,

you can use webdynpro IMAGE ui element. Bind the Source Property of the image UI element to the URL for this image. Check the below code on how to get IMAGE source URL in HR

DATA: it_toav0 TYPE TABLE OF toav0,
        wa_toav0 TYPE toav0,
        p_exists TYPE c.
 
  DATA: ex_length   TYPE int4,
        ex_document TYPE TABLE OF tbl1024,
        ex_message  TYPE bapiret2,
        img         TYPE xstring,
        url         TYPE string,
        pernr       TYPE persno VALUE `1006786`.
 
  DATA: cached_response TYPE REF TO if_http_response,
        guid TYPE guid_32.
 
* check employee image
  CALL FUNCTION 'HR_IMAGE_EXISTS'
    EXPORTING
      p_pernr        = pernr
      p_tclas        = 'A'
    IMPORTING
      p_exists       = p_exists
      p_connect_info = wa_toav0.
 
  IF p_exists = 1.
*   get image data 
    CALL FUNCTION 'ALINK_RFC_TABLE_GET'
      EXPORTING
        im_docid    = wa_toav0-arc_doc_id
        im_crepid   = wa_toav0-archiv_id
      IMPORTING
        ex_length   = ex_length
        ex_message  = ex_message
      TABLES
        ex_document = ex_document.
 
*   convert to xstring
    CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
      EXPORTING
        input_length = ex_length
      IMPORTING
        buffer       = img
      TABLES
        binary_tab   = ex_document.
 
    CREATE OBJECT cached_response
      TYPE
        cl_http_response
      EXPORTING
        add_c_msg        = 1.
 
*   set image to mime
    cached_response->set_data( img ).
    cached_response->set_header_field(
                     name  = if_http_header_fields=>content_type
                     value = 'image/pjpeg'  ).
    cached_response->set_status( code = 200 reason = 'OK' ).
    cached_response->server_cache_expire_rel( expires_rel = 180 ).
 
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_32 = guid.
 
    cl_wd_utilities=>construct_wd_url(
                     EXPORTING application_name = 'Z_JR05'
                     IMPORTING out_local_url    = url     ).
 
    CONCATENATE url '/' guid sy-uzeit INTO url.
    cl_http_server=>server_cache_upload(
                    url      = url
                    response = cached_response ).
 
*   set photo 
    DATA:
     node_photo           TYPE REF TO if_wd_context_node,
     elem_photo           TYPE REF To if_wd_context_element,
     stru_photo           TYPE wd_this->element_photo.
 
    node_photo = wd_context->get_child_node( 
                name = wd_this->wdctx_photo ).
 
    elem_photo = node_photo->get_element(  ).
    
    elem_photo->set_attribute(
      EXPORTING
        name =  `PHOTO`
        value = url ).
  ENDIF.

Also check this excerpt from Thomas Jung for previous Thread on same issue

 SE78 is the old graphics store for SAPScript. Not the best place to store images now because of the limited support for graphic types. Usually you store as Bitmaps there, making those images highly inefficient for usage on the web. Unless you have thousands of images you need to use, I would suggest downloading them, converting their format and storing them in the MIME repository. If you absolutely must access those images for some reason, look at the function modules in group STXBITMAPS - function module SAPSCRIPT_GET_GRAPHIC_BDS or SAPSCRIPT_BITMAP_GET depending upon which of the two formats/folders where used in SE78.

greetings

Prashant

Former Member
0 Kudos

Hi,

It looks pretty impressive.

I tried the function and it appears that the parameter IM_CREPID has no values in my system.

Do you have another idea how to upload the binary data of the pic so I can use the rest of your logic?

Thanks,

Itay

Former Member
0 Kudos

First of all sorry for the bad formatting, i forgot to checked the preview of my post . IM_CREPID may be specific to SAP HR system. All the intention was to show how you can always get the IMAGE file data and then display in your WD ABAP application.

so in steps

1. Get the Content of the IMAGE, from MIME or TABLE where ever it is stored.

2. Convert it into XSTRING.

3. Generate URL for it.

4. Use image UI element & set its SOURCE property to point to that URL.

Greetings

Prashant