Store Files in SAP ArchiveLink

In this article, we will discuss the functionality of ArchiveLink, a data storage interface provided by SAP for archiving documents. We will first learn what the purpose of ArchiveLink is, then look into an ABAP program that can store files, such as PDFs, TXT, JPEG, in the archive content server. Additionally, we will study Function Modules (FM) for archiving documents using the ArchiveLink functionality.

If you like to learn how to read files from ArchiveLink, you can refer to the linked article.

ArchiveLink is an interface provided by SAP that links SAP business documents and their attachments stored in a digital storage system. ArchiveLink allows us to store important documents, such as customer invoices, customs declarations, purchase orders, etc. in an internal or external data storage system. It also allows users to view the archived documents via SAP GUI transactions of business documents. For example, archived PDF attachments of sales orders can be accessed through the Generic Object Service (GOS) toolbox of transactions, sales order change (va02), sales order display(va03), etc.

ArchiveLink can store

  • Incoming files – Files that are interfaced from external systems: scanned documents, emails, and files uploaded from local PCs.
  • Outgoing files – Files created in SAP system, such as outputs of SAPScripts and Smartforms.
  • Print Lists – Results of report outputs
  • Archive Files

Let’s design an ABAP program that can upload files from a local PC and store them in an archive server using ArchiveLink. We will use selection parameters to link the file uploaded to an SAP business document such as invoice, sales order, purchase order, etc.

Selection Screen of the ABAP Program

Selection screen of the ABAP program that can store files in ArchiveLink
Selection screen of the ABAP Program – ArchiveLink

Parameters of the selection screen are as follows,

  1. File location – Full path of the file to be uploaded.
  2. SAP business object – Corresponds to the SAP business object type. For example, VBRK for billing document, VBAK for sales orders, etc.
  3. Archive document type – The document type of the uploaded file. This parameter corresponds to the archive document type configured under transation OAC2.
  4. Document number – The document number of the SAP business object.
Configuration node of the global document types in SAP. Transaction OAC2. The screen shot shows the configured ArchiveLink document types.
ArchiveLink document type configuration – Transaction OAC2

The primary purpose of the program is to store the uploaded file into the archive repository. Additionally, it should display the stored archive file as an attachment in the GOS toolbox of the transactions. In this example, the PDF we store in ArchiveLink should be visible in the attachment list of the invoice.

A list of archived documents shown in GUI transaction of business document display.
The archive document list in GOS

Now we will design the ABAP program that writes files in ArchiveLink. We will look into the data processing steps and the function modules used for ArchiveLink.

  1. The first step of the processing logic is to upload the file from local PC. We will use GUI_UPLOAD to upload the file content into SAP Office binary format.
  2. Next, convert the binary format of the file content to Xstring via function module SCMS_BINARY_TO_XSTRING.
  3. Then, convert the Xstring to RAW 1024 format. RAW 1024 is the data format accepted by ArchiveLink FM which writes the data to data storage. Use the FM SCMS_XSTRING_TO_BINARY to convert the data to RAW 1024 binary format.
  4. Aftwards, use SAP business object type and archive document type to find the archive content repository. For this, you can use the FM ARCHIV_CONNECTDEFINITION_GET.
  5. Next step is to define a new archive document ID for the file that we will store. You can use the FM ARCHIVOBJECT_CREATE_TABLE for this purpose.
  6. Finally, link the business document (invoice) with the archive document ID using function module ARCHIV_CONNECTION_INSERT.
ABAP FM and program processing steps to store files in ArchiveLInk. FM flow GUI_UPLOAD,  SCMS_BINARY_TO_XSTRING, SCMS_XSTRING_TO_BINARY, ARCHIV_CONNECTDEFINITION_GET, ARCHIVOBJECT_CREATE_TABLE, ARCHIV_CONNECTION_INSERT
ABAP program flow of writing files to ArchiveLink

Refer to the linked article if your requirement involves archiving files transmitted in base64 format.


ABAP Program Code

Main Program

Include


To summarize, we talked about the purpose of ArchiveLink, then looked into how to modularize an ABAP program to store documents, such as PDFs, TXT, images, in the archive repository. Additionally, we developed a custom ABAP program that can write files to the ArchiveLink repository and link the archive files to SAP business documents.

If you have any comments or suggestions on the topic, please post below.

TECH GADGETS I USE EVERY DAY

These are some of the tech gadgets I use every day. If you make a purchase through these links I will earn a small comission at absolutely no extra cost to you.

One thought on “Store Files in SAP ArchiveLink

  1. Ankit Kachhwaha says:

    Hi,
    I have tried your solution to archive vendor invoices, it successfully uploaded the document in archivelink but unfortunately, I am not able to retrieve the document in FB03, the PDF File is corrupted.
    Do you have any suggestions to rectify this issue so that I can see the pdf whenever needed ?

Leave a Reply

Your email address will not be published. Required fields are marked *