Professional Documents
Culture Documents
Sap Odata Media Entity
Sap Odata Media Entity
Using ODATA.
Step-6 : Click the check box for Media as shown below to make
the entity as Media Resource
Step-7 : Generate the Project as shown below
super->define( ).
lo_entity_type = model->get_entity_type('Image').
lo_entity_type->set_is_media( ).
IF lo_entity_type is bound .
"Retrieve the corresponding entity type property
"and store it in lo_property.
ENDIF.
Step-9 : Need to Redefine the Create Stream method in the Dpc
extn Class
This method actually performs the File UPLOAD process. The file
which is inserted in the HTTP POST request
" has to be saved in the transparent table, predefined for it. The
table name is ' zimg_upd'. And redifne the get stream and get
entity methods
Code implementation of create stream
method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.
ls_file-filename = iv_slug.
ls_file-createdon = sy-datum.
ls_file-createdby = sy-uname.
ls_file-createdat = sy-uzeit.
ls_file-mimetype = is_media_resource-mime_type.
ls_file-value = is_media_resource-value.
ls_key_tab-name = 'FileName'.
ls_key_tab-value = iv_slug.
append ls_key_tab to lt_key_tab.
ls_key_tab-name = 'MIMEType'.
ls_key_tab-value = is_media_resource-mime_type.
append ls_key_tab to lt_key_tab.
if sy-subrc = 0.
"Now call the FILESET_GET_ENTITY method
images_get_entity(
exporting
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_key_tab = lt_key_tab
it_navigation_path = it_navigation_path
importing
er_entity = ls_entity
) .
"Fill the export parameter er_entity accordingly
copy_data_to_ref(
exporting
is_data = ls_entity
changing
cr_data = er_entity ).
endif.
endmethod.
copy_data_to_ref(
exporting
is_data = ls_stream
changing
cr_data = er_stream
) .
endif.
endmethod.
Step-10 : Generating the Service as shown below