Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to srore images in custom table?

Former Member
0 Kudos

Hi Experts,

I have searched in sdn. i am unable to find out .

I Have requirement to create a custom table but this custom table contain one field belong to image. so what should datatype to give for this filed. is that filed will store image? how?

Plz post answers this is very needful to me.

Thanks

Lakshmi

7 REPLIES 7

nabheetscn
Active Contributor
0 Kudos

Did you first check how SAP standard is doing it in OAER tcode why dont you use the same ?  Please search on SCN for various options

Nabheet

sivaganesh_krishnan
Contributor
0 Kudos

Hi ravilla,

Try searching the net , you will find many ways of working with images in sap.

One way is Uploading images through se78 and it is stored in table STXBITMAPS.

Regards,

sivaganesh

former_member184569
Active Contributor
0 Kudos

The images that are uploaded in SAP though SE78 are stored in table STXBITMAPS.

Kindly check this table, you will get a good idea on how an image is stored in a table and use the corresponding datatypes.

You can also store your image with the datatype - HRTMC_XSTRING. You can see examples on the net. .. Search for upload photos to custom table.

Former Member
0 Kudos

I think you do do this trough MIME.

Check this thread, might be helpful for you..

Former Member
0 Kudos

hi Ravilla,

make one dataelement of predefined type 'Rawstring' like in img here....and use it in your table.

Former Member
0 Kudos

Hi Ravilla,


I already done this req..


***ztable

Create table for a image type HRTMC_XSTRING.


***report


1. Upload the image using FM GUI_UPLOAD.


2. convert the BIN file to XSTRING FILE using FM  SCMS_BINARY_TO_XSTRING


3. Then insert the image to ztable in xstring formet..

krishnadhuriya
Explorer
0 Kudos

Hi Ravilla,


create a field in ztable with type xstring.

bind data of browse UI element with the attribute of xstring type.

then simply insert data to the table.

if u want to insert and display as soon as uploaded in image UI element then ..follow

DATA:url TYPE string,

guid TYPE guid_32,

cached_response TYPE REF TO if_http_response,

wa_img type zckc_img,

w_file type xstring.

select single * from <ztable> into <workarea> where <cond>..

CREATE OBJECT cached_response

TYPE

cl_http_response

EXPORTING

add_c_msg = 1.

move wa_img-img to w_file.

* set image to mime

cached_response->set_data( w_file ).

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 =         "Webdynpro application name

IMPORTING out_local_url = url ).

CONCATENATE url '/' guid sy-uzeit INTO url.

cl_http_server=>server_cache_upload(

url = url

response = cached_response ).

   DATA lo_nd_cd_cust_image TYPE REF TO if_wd_context_node.

   DATA lo_el_cd_cust_image TYPE REF TO if_wd_context_element.

   DATA ls_cd_cust_image TYPE wd_this->element_cd_cust_image.

* navigate from <CONTEXT> to <CD_CUST_IMAGE> via lead selection

   lo_nd_cd_cust_image = wd_context->get_child_node( name = wd_this->wdctx_cd_cust_image ).

* @TODO handle non existant child

* IF lo_nd_cd_cust_image IS INITIAL.

* ENDIF.

* get element via lead selection

   lo_el_cd_cust_image = lo_nd_cd_cust_image->get_element( ).

* @TODO handle not set lead selection

   IF lo_el_cd_cust_image IS INITIAL.

   ENDIF.

* @TODO fill attribute

* lv_url = 1.

* set single attribute

   lo_el_cd_cust_image->set_attribute(

     name `URL`

     value = url ).

Note: here Source of Image is bounded with URL attribute of type string..