cancel
Showing results for 
Search instead for 
Did you mean: 

How to display BDS attachment list in WDA

Former Member
0 Kudos

Hi Experts

I have used CL_BDS_DOCUMENT_SET=>create_with_table to attach a document to a business object.

This works fine.

I now want to display a list of attachments, previously added to the business object.

Function BDS_BUSINESSDOCUMENT_GET_TAB returns to me the list in binary form.

How do I now go about converting this binary data to display the list in a Web Dynpro view?

Thanks in advance.

Anton Kruse

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Anton,

As Phani suggested you can use the class CL_WD_RUNTIME_SERVICES and the method "attach_file_to_response"  but when ever u r using a link to action field you need to take care that you get the correct row which user has selected and for that you need to get the whole records and then get the index and try to read the table with that index and pass that information to the above mentioned methos or else you will be seeing only the first clicked link all the time .

lo_nd_itab_final = wd_context->get_child_node( name = wd_this->wdctx_itab_final ).

   lo_nd_itab_final->get_static_attributes_table( IMPORTING table = lt_itab_final ).

   lo_el_itab_final = lo_nd_itab_final->get_element( ).

   lo_el_itab_final = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

   lo_el_itab_final->get_static_attributes( IMPORTING static_attributes = ls_itab_final ).

   lv_index = lo_el_itab_final->get_index( ).

READ TABLE  lt_itab_final INTO ls_itab_final INDEX lv_index.

   IF sy-subrc = 0.

     DATA: lv_filename TYPE string,

           lv_mimetype TYPE string.

     lv_filename = ls_itab_final-file_name.

     lv_mimetype = ls_itab_final-mime_type.

     CALL METHOD cl_wd_runtime_services=>attach_file_to_response

       EXPORTING

         i_filename      = lv_filename

         i_content       = ls_itab_final-file_content

         i_mime_type     = lv_mimetype

         i_in_new_window = abap_true

         i_inplace       = abap_true.

   ENDIF.

phanir_mullapudi
Active Participant
0 Kudos

Create a view with a node ATTACHS, with four fields,

NAME, TYPE, SIZE as String fields & CONTENTS as xstring.

Convert binary data to xstring & attach it to context attribute CONTENTS, name to name, size to size, & attachment/mime type.

Show your attachments list using a  WDA table with fields file name, type, size & create file name as link.

When user clicks on the file name, call method cl_wd_runtime_services=>attach_file_to_response to Pass the CONTENTS(xstring) data, filename, mimetype to this method in order to display the attachment.

This should work for sure as its a tried n tested solution by many.

Warm regards!