07-14-2017 6:36 AM
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.
07-14-2017 6: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.
07-17-2017 8:51 AM
How about using Cluster tables like standard sap table INDX. Instead of insert statement we can use Export to database, import from database.
07-17-2017 9:10 AM
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.
07-14-2017 8: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.
07-14-2017 2:33 PM
Hi Harper,
Can you explain me better about this DMS mechanic?
thank you for the tips
07-17-2017 8:26 AM
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
07-17-2017 3: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.
Regards,
07-17-2017 7:11 AM
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.