How to store a binary file as function module
Many information is stored in different files with different formats. This information is often important for the customer and there is the question, how to transport this to a customer. For this case I code a program, called BinFile2ABAP, which offers this possibility. With BinFile2ABAP you can store each file in an ABAP function module.
It converts the file to an ABAP source code as a function module, form or report. With the call the file is saved on the presentation server and executed. BinFile2ABAP can also create base64 encoded JSON and PowerShell files from any file too. You can use this JSON file in the context of your SAPUI5 development, e.g. to simulate backend databinding, via OData and the SAP Gateway, as local databinding.
With this kind of information you can extend your possibilities. You can integrate each type of file you want in your ABAP program, e.g. Adobe Flash and Portable Document Format (PDF), Compiled HTML Help (CHM), all image, sound and video formats etc.
BinFile2ABAP is free and you can download it from here.
The process to generate ABAP code is very easy. Choose the binary file you want, press the button Create Code and save the file to disc. Transfer the code in your ABAP editor via clipboard or upload – that’s all.
You can choose the line width, 16, 32, 64 or 125 bytes, this means, 32, 64, 128 or 250 characters in a line. It is dependence from the file size, because the ABAP interpreter allows max. 65535 lines to concatenate. With 125 bytes and 65535 lines you get a file size limit from 8’191’875 bytes. It is possible to create an ABAP source with more lines, but you can not compile it.
The process to generate JSON code is also very easy. Choose the binary file you want, press the button Create Code and save the file to clipboard or disc – that’s all. You can find an example how to use it here.
2018/04/02: Update is available
- Change variable arrangements in the ABAP sources.
- Add the possibility to create PowerShell file.
- Update to a new compiler version
2016/11/20: Update is available
- Change variable names in the ABAP sources to another prefix.
- Update to a new compiler version.
2016/04/01: Update is available
- Add now a few information as comment in the source about the file, like name, size, last modification date and time and MD5 hash
- Add now Authority-Check stub in the ABAP sources
2015/11/22: Update is available
- Now two versions are available, x86 and x64.
- Checked with Windows 10 x64.
2015/02/15: Update is available
- Add the possibility to create JSON file with base64 encoded content.
- Add the possibility to create function modules with an export interface.
- Add the possibility to create function modules in ABAP in Eclipse (AiE) style.
- New GUI design with tabs.
- Delete the possibility to create ABAP code with more than 65535 lines, because it has no practical significance.