Skip to Content

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.

 

  1. Let’s say my Material master has 2 attachments as shown below.
  2. Using this Webdynpro Application we will view/delete those attachments in web.
  3. 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:
  4. In order to view the attachment, click on File name (Link), the attachment will be shown in pop as below:
  5. Let’s look at the delete functionality. Select anyone of the line & click on delete button and click ‘Yes’ for confirmation. 
  6. 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:

 

  1. Create the webdynpro project say Display_attachment and Application DisplayAttachmentt
  2. 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.
  3. In following screen, choose “Import Adaptive RFC Model” also enter the necessary details 
  4. Once Model is imported successfully, add the model into webdynpro component by right clicking “Used Model” as shown below.

  5. Create the view Display_AttachmentView & create the below context node & attributes:
  6. Node AttachmentList cardinality is 0:n, selection is 0:1
  7. 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

  8. The layout looks like below:
  9. 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:

  10. 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:

  11. Create the event handler say “Delete” and assign into “Delete” button.

     

  12. RFC to get attachment List:

  13. Use RFC FM ”BDS_DOCUMENT_GET_TABLE’ to display the attachment content.

  14. 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…

To report this post you need to login first.

5 Comments

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

  1. Darren Hague
    Hi Raja,

    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

    (0) 
    1. Raja Thangamani Post author
      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

      (0) 
  2. Former Member
    Hi Raja,

    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

    (0) 
  3. Former Member
    Hello Raja,

    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

    (0) 
  4. Former Member

    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

    (0) 

Leave a Reply