Former Member
Posted onSeptember 15, 2014 2 minute read
Linking of Attachment in SAP documents
FollowRSS feedLike
4 Likes 33,108 Views 5 Comments
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
Alert Moderator
Assigned tags
ABAP Development
Related Blog Posts
How to store a mobile made picture in SAPoffice
By Stefan Heitzer, Feb 10, 2014
Attach File to Standard Trasaction VA02 Using Function Module SO_DOCUMENT_REPOSITORY_MANAGER
By HariKrishna Malladi, May 18, 2015
Extend Thomas Jungs simple mail function with Attachment Filename
By Gregor Wolf, May 25, 2006
Related Questions
Attachment name same for all Attachments- Late Archiving with Bar code
By Former Member, May 05, 2016
GOS attachment and KPRO
By Former Member, Nov 15, 2010
Attachment size in CL_document_bcs->send
By chaitanya mouli, Jul 18, 2017
5 Comments
Sridhar Bolisetti
September 17, 2014 at 8:31 am
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,
Sridhar
Like(0)
Reply
Alert Moderator
Vincent Chevillard
February 7, 2017 at 4:44 pm
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,
Vincent
Like(0)
Reply
Alert Moderator
Former Member
May 17, 2018 at 7:47 am
Hello Raja
Great document. Can you please tell me the coding you refer to in "B Coding - To link the attachment" ?
Thanks
Deepak
Like(0)
Reply
Alert Moderator
Linus PTS
November 15, 2018 at 9:18 am
Hello,
Very good explanation. Could you please guide on, how to troubleshoot if the functionality is not working after certain time. (Was working last year, not not working now)
Thanks in advance!
Like(0)
Reply
Alert Moderator
Gerald Peoples
January 29, 2019 at 7:31 pm
I have a user who when he clicks on the document it tries to view the attachment it opens in adobe PDF but it says:
There was an error opening this document. This file cannot be found
the only option is ok
i have narrowed it down that it is trying to open it from system 32 folder. since the user does not have access to that folder to save it is erring off
this is the version he is working off of
is there a place that you can edit and ask it to open in a new directory? i know its not a rights issue in SAP as i have and logged in with his credentials and it works fine. this is the version on my machine and as i said, it works fine following the same process
i do believe this is a setting in the new interface but so far i have yet to discover it
Like(0)
Reply
Alert Moderator