Skip to Content
Technical Articles
Author's profile photo Arnab Datta

SAP OData tutorial: Return file content with GET_ENTITY (HTTP GET method, without using Media / blob)

Hi folks,

Sometimes, due to some UI framework limitation or requirements you may need to return the file content through OData with GET method only. You can do that in the below way.

Define the entity as below. Do not mark it as media.

Define attributes as below.

While, returning the data from XXXXXX_GET_ENTITY method, implement the logic to get the file content from table/BOFP objects and after that use the below code to convert it to BSEE 64 string.


lv_content = rr_s_content->content .

    input  = lv_content
    output = lv_pdf_string.

er_entity-content   = lv_pdf_string.
er_entity-mimetype  = rr_s_content->mime_code.
er_entity-filename  = rr_s_content->file_name.


This will return the file content in Base64 encoding which can be consumed by the UI library and make it downloadable for the user.

Happy coding!! 🙂

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.