Display/Delete attachment from Business transactions using Webdynpro (Java)
Introduction: This blog describes how to display/delete the documents, which are stored in any SAP Business transactions like MM01, IE01, VA01, FB01 and WTY etc from Webdynpro Java.
If you have not read the Organize your business attachments from Web & How To: Create attachments in Business Transaction from Webdynpro(Java), I would recommend to read those before you continue this blog.
Let’s look at the outcome of this blog before we get into the details.
Note: We will display & delete those documents, which we created in How To: Create attachments in Business Transaction from Webdynpro(Java) of this series blog.
- Let’s say my Material master has 2 attachments as shown below.

-
Using this Webdynpro Application we will view/delete those attachments in web.
-
You will get the confirmation after successful deletion of document
Let’s look at the development steps:
Below is the Java webdynpro application which will look like once you are done with the development:
-
Create the webdynpro project say Display_attachment and Application DisplayAttachmentt
-
Import the BAPI which will get the attachment list & details from SAP to webdynpro by right clicking the Model. RFC detail will be explained later in this document.
-
In following screen, choose “Import Adaptive RFC Model” also enter the necessary details
-
Node AttachmentList cardinality is 0:n, selection is 0:1
-
Attribute details are below:
Attribute
Type
Date
date
Display_Doc
com.sap.ide.webdynpro.uielementdefinitions.Resource
DocContent
string
DocName
string
DocumentID
string
DocumentType
string
Material_No
string
-
Create the Event handler say “submit” and assign it to Submit button. This method will bring the list of attachments from SAP. Below is the code for the same & related methods:
-
Create the event handler say “Displayattachment” and assign into Link (AttachmentList.DocName). This will be used to view the document. Below is the Code for the same:
-
Create the event handler say “Delete” and assign into “Delete” button.
-
RFC to get attachment List:
-
Use RFC FM ”BDS_DOCUMENT_GET_TABLE’ to display the attachment content.
-
To delete the attachment use RFC “BDS_DOCUMENT_DELETE”.
Download: Here is the ready to use Project file Display_attachment.
Hope I covered all the points & add some value to community over here…









That one definitely gets saved to my favourites list - thanks.
One question - why do you create the two Z function modules instead of just calling the BDS function modules directly?
Best regards,
Darren
Thanks for your comments.
Partially you are correct :). You can access the FM 'BDS_DOCUMENT_GET_TABLE' directly since its RFC enabled, but not 'BDS_ALL_CONNECTIONS_GET' since its normal FM. I will update the blog.
Raja T
First of all this blog is very useful. But I have problems with the function module BDS_DOCUMENT_GET_TABLE, it doesn't return nothing. I don't know why, I use the same data that return the function BDS_ALL_CONNECTIONS_GET so it is correct. I'm developing something in Web Dynpro for ABAP so it is like the same thing. But I just have this issue, so if you can help me, if I'm doing something wrong I'll very appreciated. I'm testing the function in the transaction SE37, I import the parameter of DOC_ID and I fill the table of SIGNATURE with the fields DOC_COUNT, DOC_ID, DOC_VER_NO, DOC_VAR_ID, DOC_VAR_TG. Another thing is that I'm reading the attachments from the assets (transaction AS02). So I use the ClassName: BUS1022 and the ClassType: BO. Do you know something that I'm doing wrong?
Regards,
Isaac
Some our users created attachments through the business transaction. Those attachments are not showing in OAOR or not returned by BDS_ALL_CONNECTIONS_GET. Do you know why?
Your answer is really appreciated.
Jenny
Hi Raja,
Would this work for the 4 char. extension files as well? For example, .exlx or .docx files?
I believe, Docuclass field from RFC would return DOC only even though file extension was .docx.
Let me know if you have come across such scenario and how you would have handled it.
Thanks,
Bhavik