cancel
Showing results for 
Search instead for 
Did you mean: 

Get photo from archive link and link into WDA Image UI

former_member189690
Participant
0 Kudos

Hi guys,

I have employee photos stored in archive link under PREL HRICOLFOTO object.

The question is: how can I get the image and link it on an image UI element on WDA?

I have read some posts but, to be honest, I don't understand very well.

I'm trying use ARCHIV_GET_CONNECTIONS function module to obtain ARC_DOC_ID field, but I don't know which is the following step.

Can anyone help me?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

TomVanDoo
Active Contributor
0 Kudos

I direct you to Thomas Jung's reply in this thread:

You can't show the image directly from archivelink, as it isn't physically there.

It's just a binary string in a table

so you have to get the binary string of the image

attach it to your response as a temporary file

and show the image on the screen by referring to the temporary file

former_member189690
Participant
0 Kudos

Hi Tom,

I have followed Thomas thread but nothing appears on my screen.

My issue is: how can I get "binary string of the image" to assign to response?

Currently I'm assigning ARC_DOC_ID field (CHAR40) to GX_CONTENT (xstring) directly, but the method cached_response->set_data needs a Xstring. I think this is my problem. Any idea? Is is correct this approach?

thank you!

former_member189690
Participant
0 Kudos

More info about the issue...

In fact, I can see the temporary file created on ICM cache, but when I try to open the file is not appearing the photo, it is appearing the string. I put my source code:

<pre>

<code>

<B>* Get ARC_DOC_ID string from archive link for the employee 10002 </B>

CALL FUNCTION 'ARCHIV_GET_CONNECTIONS'

EXPORTING

objecttype = 'PREL'

object_id = '10002'

until_ar_date = sy-datum

TABLES

connections = lt_connections

  • PARAMETER =

EXCEPTIONS

nothing_found = 1

OTHERS = 2.

DATA: gx_mimetype TYPE string VALUE 'image/jpeg'.

DATA: l_image TYPE xstring.

DATA: converter TYPE REF TO cl_abap_conv_out_ce.

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

DATA: l_xstring TYPE xstring,

i_cache_timeout TYPE i VALUE '60'.

READ TABLE lt_connections INTO ls_connections INDEX 1.

<B>* On this part I try to convert STRING (ARC_DOC_ID) into XSTRING, I don't know if it is correct or not!!!!</B>

*-- Convert

converter = cl_abap_conv_out_ce=>create( encoding = 'DEFAULT' ).

converter->reset( ).

CALL METHOD converter->write

EXPORTING

data = ls_connections-arc_doc_id.

<B>* Store on l_image xstring converted!!!!!!</B>

l_image = converter->get_buffer( ).

cached_response->set_data( l_image ).

l_app_type = gx_mimetype.

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 = i_cache_timeout ).

DATA: r_url TYPE string.

DATA: i_path TYPE string VALUE '/sap/public/bc/webdynpro',

i_format TYPE string VALUE 'JPG'.

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

" bind the generated url with the image uielement attribute

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_url LIKE ls_context-foto.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • set single attribute

lo_el_context->set_attribute(

EXPORTING

name = `FOTO`

value = r_url ).</code></pre>

Thank you

Edited by: vanbelal on Apr 22, 2010 9:39 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

check this wiki [http://wiki.sdn.sap.com/wiki/display/WDABAP/DisplayEmployeeImageinABAPWebDynpro+Application]

former_member189690
Participant
0 Kudos

Hi Radhika,

I've tried your solution but I get the following error when I get URI with FM 'HR_ESS_WHO_PROG_GET_PICT_URI': for example, I copy URI on a new browser window and I get:

SSF Signer not valid

or others cases

SSF Decoding not possible.

What is this?

Anyone can help me?

Thanks