cancel
Showing results for 
Search instead for 
Did you mean: 

opening attachments

prathamesh_gandhi
Participant
0 Kudos

HI ALL,

I have developed a webdynpro (ABAP) component which shows a list of attachment for a document.  we have allowed some file type e.g. DOC, DOCX, TXT, XLS, PPT , PDF , MSG (Outlook File).

Now my problem is that for few file types like MSG, PPT, DOCX etc while opening it always ask to select program (like open with) and you need to select particular program each time so its annoying user. can we make any such configuration so for users no need to select supported program each and every time.

Thanks In Advance,

P$G.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

You can use BDS functionality to store your content and open it directly from there. below is the sample code for getting the documents and displaying them.


  DATA: all_connections_wd TYPE TABLE OF bdn_con.
  DATA: lw_all_connections_wd TYPE bdn_con.
  CALL FUNCTION 'BDS_ALL_CONNECTIONS_GET'
    EXPORTING
*   LOGICAL_SYSTEM         =
      classname              = 'Z_CONTENT'
      classtype              = 'OT'
*   OBJKEY                 =
*   CLIENT                 = SY-MANDT
*   ALL                    = 'X'
*   NO_AL_DOCS             = ' '
*   NO_GOS_DOCS            = 'X'
*   CHECK_STATE            = ' '
* IMPORTING
*   COUNT                  =
    TABLES
*   SIGNATURE              =
      all_connections        = all_connections_wd
*   FRAMEWORK              =
* EXCEPTIONS
*   NO_OBJECTS_FOUND       = 1
*   ERROR_KPRO             = 2
*   INTERNAL_ERROR         = 3
*   NOT_AUTHORIZED         = 4
*   OTHERS                 = 5
            .

DATA: ob_wd_document_ui TYPE REF TO cl_hap_wd_document_ui.

        CREATE OBJECT ob_wd_document_ui.
        lv_aid = lw_all_connections_wd-loio_id.

        DATA: lv_hap_attachment_type TYPE hap_attachment_type.
        lv_hap_attachment_type = lw_all_connections_wd-docuclass.

        CALL METHOD ob_wd_document_ui->attachment_get_detail
          EXPORTING
            attachment_id      = lv_aid
            attachment_type    = lv_hap_attachment_type
            attachment_storage = 'BDS'
          IMPORTING
            file_content       = lv_fcon
            file_content_hex   = lv_fchex
            mime_file_type     = lv_mftyp
            s_return           = lv_ret.


        DATA:
        l_file    TYPE string,
        l_mime    TYPE string,
        pdf_data  TYPE xstring.

        CONCATENATE 'application/' lw_all_connections_wd-docuclass INTO l_mime.

        l_file = lw_all_connections_wd-comp_id .

        CALL METHOD cl_wd_runtime_services=>attach_file_to_response
          EXPORTING
            i_filename  = l_file
            i_content   = lv_fchex
            i_mime_type = l_mime.

former_member206441
Contributor
0 Kudos

Dear Prathamesh,

Try the below code. It will allow you to download all type of file

wdr_task=>client_window->client->attach_file_to_response(  i_filename  = ls_files-filename

                                                             i_content   = ls_files-data

                                                             i_mime_type = ls_files-filetype

                                                             i_in_new_window = 'X'

                                                             i_inplace       = 'X'

                                                              ).

Thanks & Regards

Arun.K.P