Download the binary content of the file stored in the SAP ABAP database table as a local file trial version

In the development of SAP standard products and actual projects, it is often encountered that the binary content of a small file (such as a configuration file smaller than 1MB) needs to be stored in the ABAP database.

For example, in this article in the author's SAP OData development tutorial , the code in line 17 of the following figure uses ABAP OPEN SQL to insert the value ls_file_dbof into the database table zfile:

insert image description here

The figure below is the field list ZFILEof . This database table is used to store the file content saved after the user uploads the file to the ABAP server using the SAP ABAP OData service according to the steps introduced by the author in this tutorial.

Specifically, the content of the file VALUEis maintained , and the data type is RAWSTRING.

insert image description here

For example, in my system, there are three pieces of data in the ZFILE table, representing three files that have been successfully saved after uploading:

insert image description here

Double-click any record to view the details:

insert image description here

Among them, the VALUE field shows the hexadecimal encoding of the binary content of the file. This encoding is the same as what we use locally WinHex, UltraEditand the content viewed after the software is opened is consistent.

This article describes how to download the content of this RAWSTRINGformat to the local, and regenerate a new file.

The complete 50 lines of ABAP code used in this article are at the end of the article, and here are the key points of code writing.

Guess you like

Origin blog.csdn.net/i042416/article/details/131018288