Show TOC

Media LinksLocate this document in the navigation structure

SAP Gateway supports media entries. This enables applications to expose information from different media types, such as graphics and videos, for example.

The OData Channel provides a generic solution for exposing binary data that is stored in an SAP Business Suite backend system and should be accessible using a media link entry.

  • Binaries can be exchanged separately between the consumer, SAP Gateway system, and SAP Business Suite backend system.

  • The application can set the respective HTTP headers via an API, for example, for cache control for the respective media resource (for non-sensitive data only).

  • Media link representation:

    An entity type of an SAP Gateway data model that is to be treated as a media type has to be defined as such in its properties. For such entity types, you must select the Media checkbox in its properties. Based on the media type classification, the OData Service Metadata Document sets the hasStream to true for the resulting EntityType.

    Node structure: An entity type that is marked as a media link has to have the following properties to support the correct handling of the media link:

    • Source URI

      External resources: this is used by the consumer to retrieve the associated media resource. For internal resources, the resource manager can be used in the application logic at runtime to set the media resource URI properly. In a read scenario of a static media resource, the Source URI contains a static link to the resource. The property which contains the source URI is annotated by the application developer by using method SET_AS_CONTENT_SOURCE.


      OData Channel only:

      Binary resources, for example stored in the SAP Business Suite backend system: the source URI of the media link entry is automatically generated by the framework. When accessing the link, the framework routes the request to the read stream implementation of the data provider class. Note that this is only required if you want to point to a media resource which refers to an external URL. If you handle the resource call with your own implementation in GET_STREAM, then you do not have to set this property reference at all.

    • MIME type

      This describes the media resource's type, for example image/png. The mime type of the media resource is set by the application logic at runtime. The property which contains the source URI is annotated by the application developer by using method SET_AS_CONTENT_TYPE. The content type always has to be set.

Implementation Considerations for OData Channel

To use this function to retrieve a raw value, you must include an implementation for each service in the SAP Business Suite backend system. The entity type has to be marked as HasStream and the method Get_Stream has to be implemented.

The /$value is an additional command to an entry to identify the raw value of an entry. For example, if an entry represents an engine with the additional /$value, an image of the engine can be retrieved.


The following is an example of the source code for the software component IW_BEP for the redefined method DEFINE of class /IWBEP/CL_MGW_ABS_MODEL and /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM of class /IWBEP/CL_MGW_ABS_MODEL.

Redefined method DEFINE of class /IWBEP/CL_MGW_ABS_MODEL:

* setting a data object as media type means that it gets a special semantic by having a url and allows streaming etc.
  lo_data_object->set_is_media( ).

  lo_property = lo_data_object->create_property(
    iv_property_name  = 'mimeType'
    iv_abap_fieldname = 'MIME_TYPE'
* must be set when data object is a media type to mark the property which represents the mime type information
  lo_property->set_as_content_type( ).



  DATA: ls_stream         TYPE         ty_s_media_resource
       ,lo_api            TYPE REF TO  if_mr_api

  lo_api = cl_mime_repository_api=>get_api( i_prefix = '/SAP/PUBLIC/BC/Pictograms' ).
  lo_api->get( EXPORTING i_url       = '3_people_money.gif'
               IMPORTING e_content   = ls_stream-value
                         e_mime_type = ls_stream-mime_type ).

  copy_data_to_ref( EXPORTING is_data = ls_stream
                    CHANGING  cr_data = er_stream ).