Skip to Content
-4

Create Z program to append files to z-table.

Jul 14, 2017 at 05:36 AM

174

avatar image

Hi,

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.

10 |10000 characters needed characters left 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.

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Horst Keller
Jul 14, 2017 at 05:56 AM
2

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

How about using Cluster tables like standard sap table INDX. Instead of insert statement we can use Export to database, import from database.

0

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.

0
David Antonio Arroyo León Jul 17, 2017 at 02:16 AM
2

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.

Regards,

Share
10 |10000 characters needed characters left characters exceeded
Richard Harper Jul 14, 2017 at 07:34 AM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Harper,

Can you explain me better about this DMS mechanic?

thank you for the tips

0

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:

BAPI_DOCUMENT_GETACTVERSION

BAPI_DOCUMENT_SETSTATUS

BAPI_DOCUMENT_ENQUEUE

BAPI_DOCUMENT_DELETE_DIRECT

BAPI_DOCUMENT_DEQUEUE

BAPI_DOCUMENT_CREATENEWVRS2

BAPI_DOCUMENT_CHANGE2

BAPI_DOCUMENT_CHECKIN2

BAPI_DOCUMENT_CREATE2

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

BAPI_DOCUMENT_GETDETAIL2

SCMS_DOC_READ

SCMS_BINARY_TO_STRING

SCMS_BINARY_TO_XSTRING

SCMS_BASE64_ENCODE_STR

Rich

0