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,
- 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
- 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