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.
Once you execute the WDJ Application, enter the Object Key Number for which you already created the attachment. In our case Material number is the object key. Click Submit. The list of attachment will be shown as below:
In order to view the attachment, click on File name (Link), the attachment will be shown in pop as below:
Let's look at the delete functionality. Select anyone of the line & click on
delete button and click 'Yes' for confirmation.
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
Once Model is imported successfully, add the model into webdynpro component by right clicking "Used Model" as shown below.
Create the view
Display_AttachmentView & create the below context node & attributes:
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 |
The layout looks like below:
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...