Skip to Content

The linking of attachments between SAP documents will be required in many business scenarios in SAP. But in this document, I have taken a scenario of cross company posting to explain this process. Let us go through this with an example,

Generally, an accounting document (i.e. Accounts receivable document) will be generated when billing is done (T-code VF01). In cross company trading scenario, when this document is generated, there may arise a requirement to post a corresponding AP document (Account Payable) on the partner company code. Using workflow, AP documents in partner company code can be posted. But how to transfer the attachment from AR document to AP document posted in SAP. This document will explain this process.

Below screen shot shows the AR document posted (in Company code – 0774) which is generated upon Billing. The attachment can also be seen along with the AR document. The trading partner company code for this Customer is 3277.


When this document is posted, workflow will be triggered to post the AP document and the transfer of attachment will happen.

AP document posted in the partner company code 3277 along with attachment is given as example below. Here, if you notice, the attachment from AR document is transferred to the newly posted AP document.


The linking of this attachment between the documents involves two steps,

  1. Configuration of Document Type and linking the content repository in T-Codes – OAC2 and OAC3 respectively. Also, changing the setting for the message type in transaction NACE

   b. Coding part to do the linking of attachment

  1. Configuration of Document Type

Step 1: Go to Transaction OAC2 and create a new document type as shown below. Here, the kind of attachment which we intend to transfer is PDF.


Step 2: Go to Transaction OAC3 and create a link for content repository. Here Billing document (VBRK) and Accounting document (BKPF) will be linked      with a test content repository ‘TN’. Here in this example, link table ‘TOA01’ is used.


Step 3: Go to transaction NACE and select the output type for this process is followed. In storage mode select “Print and Archive” and give the document      type that was created in transaction OAC2.


B. Coding – To link the attachment

Please find the code which is added as attachment along with document. Please refer the code for the variables mentioned here.

Step 1: Use the object key (BKPF-AWKEY) of the AR document to prepare source object W_OBJECT

Step 2: Call FM ‘ARCHIV_GET_CONNECTIONS’ using source object key to get the attachment document link into internal table T_TOAV0.

Step 3: Prepare target object W_BKPF_OBJECT (i.e. target AP document to which attachment link needs to be created). Here, we can use AP document’s object key (BKPF-AWKEY)

Step 4: Call FM ‘ARCHIV_WORKFLOW_COMMIT’ and pass the import parameters as shown below.


     Done. Attachment will be transferred.

Feedback and Suggestions to correct any mistakes or improve this document are most welcome

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi Raja Kesavan,

    Thanks for the process.  It’s a nice explanation.

    You mentioned that when the billing is completed (ie, AR document) then workflow will be triggered to post the AP document.  Could you please elaborate on this process as well so that this document can be a good guide.  Also mention if it is possible to have this workflow set up in case of AR document is in one SAP system (ie, one business) and AP document should be in another SAP system (ie, another business).

    Thanks and Regards,


  2. Vincent Chevillard

    Hi Raja Kesavan,

    the business case you mentioned is exactly the one we need to achieve at my company. It was very useful to know it could be done quite easily. However, i have two questions for you:

    1- Could you tell me how you generated the pdf SD Invoice and attached it to the AR document

    2- I was not able to find the code in the post. Could you send it over to me?

    Thanks in adavcen for your answers.

    Kind regards,


  3. Former Member

    Hello Raja

    Great document. Can you please tell me the coding you refer to in “B Coding – To link the attachment” ?





Leave a Reply