Skip to Content
avatar image
Former Member

Create Z program to append files to z-table.


I need to create a Z program that will attach files to a Z table, how should I create this table to store files type attachments and if this is really possible,

thank you so much.

Add comment
10|10000 characters needed characters exceeded

  • As you can see, there are many ways to relate your files to "SAP standard" storages. If you really don't care about what they are, simply store the file as BLOB as Horst says, or give more information what you plan to do with these files.

  • Get RSS Feed

3 Answers

  • Jul 14, 2017 at 05:56 AM

    You need something like a table with a key and a RAWSTRING (BLOB) column. Convert the contents of the files to binary and store them in the BLOB column. The MIME repository delivered by SAP works like this.

    Examples, how that can be done by streaming can be found here. The table key might be enhanced for columns that denote the file type etc. Streaming might become necessary for large files. Otherwise, you might INSERT normally.

    Add comment
    10|10000 characters needed characters exceeded

    • You can use export/import tables for this. But of course not INDX. INDX should not be used in production programs. You should create your own export/import tables that correspond to your needs.

  • Jul 17, 2017 at 02:16 AM

    Hi Flavio,

    Did you check GOS solution? Using GOS, your Z program will create the attach files in GOS, and in your Z Table, you can store a records for each file attached, each record referencing to a file attached. So that when your Z program displays the attached file, you can also view it.

    Maybe the solution is focused on the actions you will take with the attachment.


    Add comment
    10|10000 characters needed characters exceeded

  • Jul 14, 2017 at 07:34 AM

    I would use the DMS for this. Store your files in the DMS and then store the DMS document number in your ZTable.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Flavio, The DMS is pretty well documented in SAP. First you define a document type using transaction DC10, whether it should have versions, what statuses it can have etc etc. This is all under DC10. There are lots of sites on the web about how to do this.

      As well as this you create a number range for your document type and copy or change include MCDOKZNR to cope with your number range - forms Number_Get_Next and External_Number_Check. You should also change the message class to your own (which is why I prefer to copy it) so that the messages have more meaning.

      Then in your code you would use the following BAPI's:










      To display a PDF stored in the DMS for exampleyou could use: