Beruflich Dokumente
Kultur Dokumente
For displaying an image/logo in Web Dynpro application, usually a MIME object is created where a image
is uploaded from a legacy.
But what if an image or logo is stored in document server (Transaction SE78) or what if the image is
required to be fetched from R3??
In simple words this article will help in displaying an image from SE78 transaction to the Web Dynpro
application.
The 6 steps in the whole process are described below. Code mentioned in step 2-5 needs to be provided
in WDDOINIT method of view.
1. Create a Web dynpro component ZTEST1.
Create a view FIRST_VIEW for a Web Dynpro component. Insert a image element 'IMAGE' in view
layout.
Assign the above created attribute to the SOURCE property of IMAGE element
Create a window ZTEST1 for Web Dynpro component and drag the view inside the window.
2. Get the Binary contents of image/logo from BDS (Business document store).
Go to the WDDOINIT method of view and call the below Function module for getting the binary contents
of a image. I am calling this FM for a specific image. To make it a dynamic call, select query on table
STXBITMAPS is required. Thus it can help in deciding the image at run time.
For black & White images pass 'BMON' in parameter I_BTYPE (graphic type) and for color images pass
'BCOL' in parameter I_BTYPE.
Data:
i_name
i_id
TYPE
i_btype
TYPE
l_bds_bytecnt
l_bds_content
TYPE
TYPE
STXBITMAPS-TDNAME
STXBITMAPS-TDID
STXBITMAPS-TDBTYPE
TYPE
TABLE
value
VALUE
VALUE
OF
'ZLOGOTEST',
'BMAP',
'BMON',
i,
bapiconten.
*-CALL
EXPORTING
i_object
i_name
i_id
i_btype
IMPORTING
e_bytecount
TABLES
content
EXCEPTIONS
not_found
OTHERS = 2.
Get
FUNCTION
=
=
i_btype
image
contents
'SAPSCRIPT_GET_GRAPHIC_BDS'
=
i_name
=
"Image
'GRAPHICS'
name
i_id
gray)
"Image
type(color
or
l_bds_bytecnt
l_bds_content[]
=
l_length
TYPE
i,
tsf_xsf_ct,
TYPE
CALL
EXPORTING
old_format
new_format
bitmap_file_bytecount_in
IMPORTING
bitmap_file_bytecount
TABLES
bds_bitmap_file
bitmap_file
EXCEPTIONS
OTHERS = 1.
FUNCTION
'SAPSCRIPT_CONVERT_BITMAP'
=
=
'BDS'
'BMP'
l_bds_bytecnt
=
=
l_length
=
=
l_bds_content[]
l_content[]
w_file
TYPE
TYPE
LINE
TYPE
DESCRIBE
FIELD
l_grline
LENGTH
l_linelength
LOOP
AT
l_content
IF
l_length
>
CONCATENATE
w_file
l_grline-line
INTO
w_file
ELSE.
xstring,
tsf_xsf_ct,
i.
OF
IN
INTO
IN
BYTE
MODE.
l_grline.
l_linelength.
BYTE
MODE.
CONCATENATE
ENDIF.
l_length
ENDLOOP.
w_file
l_grline-line(l_length)
INTO
w_file
l_length
IN
BYTE
MODE.
l_linelength.
TYPE
TYPE
REF
TYPE
CREATE
TYPE
cl_http_response
EXPORTING
add_c_msg
string,
guid_32,
if_http_response.
TO
OBJECT
cached_response
*
set
cached_response->set_data(
cached_response->set_header_field(
name
=
value
=
image
to
mime
).
w_file
if_http_header_fields=>content_type
'image/pjpeg'
).
cached_response->set_status(
code
cached_response->server_cache_expire_rel(
180
CALL
IMPORTING
ev_guid_32
1.
200
reason
expires_rel
FUNCTION
'OK'
'GUID_CREATE'
=
cl_wd_utilities=>construct_wd_url(
application_name
=
'ZTEST1'
IMPORTING
out_local_url
CONCATENATE
url
'/'
cl_http_server=>server_cache_upload(
url
response = cached_response ).
).
=
).
guid.
"Webdynpro
=
guid
application
url
sy-uzeit
INTO
EXPORTING
name
).
url.
url
lo_el_context
ls_context
lv_image
get
TYPE
element
=
REF
TYPE
LIKE
TO
if_wd_context_element.
wd_this->element_context.
ls_context-image_url.
via
lead
wd_context->get_element(
selection
).
*
get
lo_el_context->set_attribute(
EXPORTING
name
value = url ).
single
=
Now activate the Web Dynpro component and test the application to see output.
attribute
`IMAGE_URL`