Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Save file content in dictionary table

RicardoRomero_1
Active Contributor
0 Likes
2,442

Hello, all.

We need to save the content of some CSV files in a dictionary table (don't want to save the files in server in this requirement).

We've created a field in our custom table with type RAWSTRING, concatenating the content of each row in a string separated by cl_abap_char_utilities=>cr_lf.

Then converting this string in base64 with method cl_http_utility=>if_http_utility~encode_base64.

And at last, converting to xstring to save the value in this RAWSTRING field.

--
And it's working fine, we can save the data and read it successfully.

We've checked the size of the table with report RSTABLESIZE, and after save a file of about 4 MB the size of the table is growing only about 95 KB.

--

But, I'm wondering if there is another more optimized way to do it.

Do you know any other way to do it ?

Thanks in advance.

Hello, all.

We need to save the content of some CSV files in a dictionary table (don't want to save the files in server in this requirement).

We've created a field in our custom table with type RAWSTRING, concatenating the content of each row in a string separated by cl_abap_char_utilities=>cr_lf.

Then converting this string in base64 with method cl_http_utility=>if_http_utility~encode_base64.

And at last, converting to xstring to save the value in this RAWSTRING field.

--
And it's working fine, we can save the data and read it successfully.

We've checked the size of the table with report RSTABLESIZE, and after save a file of about 4 MB the size of the table is growing only about 95 KB.

--

But, I'm wondering if there is another more optimized way to do it.

Do you know any other way to do it ?

Thanks in advance.

8 REPLIES 8
Read only

FredericGirod
Active Contributor
2,029

You have recreate the ArchivLink submodule. It is how to archiv/store document (like GOS).

The better part of Archivlink is you could customize where to store the data: Database, local file, http content storage. And you could find the file directly from the standard transaction (with GOS)

Read only

0 Likes
2,029

I've used GOS sometimes, I'll try to check if we can use it for this requirement.
Thanks for answer !

Read only

0 Likes
2,029

ArchivLink use GOS, but it is not GOS. ArchivLink is mainly transaction OAM1

Long time ago, I have started a blog on this subject :

https://blogs.sap.com/2014/07/07/http-content-server-gos/

Read only

0 Likes
2,029

I think we are going to use archivelink, one question, is it always necessary to use a BO ?
In our case we only need to save the document in the content server, but not necessary to have a relation with a BO.

Well, If its necessary we can create a dummy BO in SWO1.

Anyway, do you know any FM to create a file in the content server? I've tried with ARCHIVOBJECT_CREATE_FILE and ARCHIV_CONNECTION_INSERT but no luck.

Thanks !

Read only

0 Likes
2,029

GOS need BO, not archivlink.

It is just to know how to retrieve the file.

When you do Archiving, you could use ArchivLink, but not GOS, so not SWO1

Read only

2,029

Ricardo Romero Mata To write to a content server, you may use ArchiveLink (in fact, there are lots of possibilities; they all call the CMS function modules in the end).

ARCHIVOBJECT_CREATE_* should work to save a document to the content server.

ARCHIV_CONNECTION_INSERT should permit to link the saved document to a business object.

ARCHIV_CREATE_* combines ARCHIVOBJECT_CREATE_* and ARCHIV_CONNECTION_INSERT.

Try again. Create a new question if you have issues with these FMs.

Read only

matt
Active Contributor
2,029

Use EXPORT with the internal table containing the CSV contents.

EXPORT the_file = csv_itab DATA BUFFER myxstring_var.

Put myxstring_var into the RAWSTRING. You could also use EXPORT ... DATABASE...

Retrieve by something like:

SELECT SINGLE * INTO @DATA(record) FROM z_mytab WHERE ...
IMPORT the_file = csv_tab DATA BUFFER record-file_contents.

To optimise, use the zip classes before storing in the table.

Read only

Sandra_Rossi
Active Contributor
2,029

or to compress, the addition:

EXPORT ... COMPRESSION ON.

(compression is OFF by default for all media (DATA BUFFER and so on)except for TO DATABASE)