cancel
Showing results for 
Search instead for 
Did you mean: 

File download from DMS into Webdynpro for ABAP application

Former Member
0 Kudos

I need to download the file from DMS content server on the PC and with my application on clicking of file name, file needs to be displayed.

To achieve the downloading part I tried BAPI_DOCUMENT_CHECKOUTVIEW2, but it is not working.

If I pass the parameters

PF_HTTP_DEST = 'SAPHTTPA'

PF_FTP_DEST = 'SAPFTPA', then it returns error message saying file can not be saved.

If I don't pass above parameters then it gives me 'RFC_START_PROGRAM' error.

How to download the file from DMS in WebDynpro and read/display the content?

Please help.

Thanks, in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I had the same problem, but found a solution. All I changed was the hostname to 'DEFAULT'

Use the code below:

DATA: lt_drao TYPE TABLE OF drao,

         wa_drao TYPE drao,

         wa_bin TYPE x LENGTH 2550,

         lt_bin LIKE TABLE OF wa_bin,

         file_data TYPE xstring,

         v_line TYPE i,

         size TYPE i.

   CALL FUNCTION 'CVAPI_DOC_CHECKOUTVIEW_DIALOG'

     EXPORTING

       pf_dokar                 = ls_input-dokar

       pf_doknr                 = ls_input-doknr

       pf_dokvr                 = ls_input-dokvr

       pf_doktl                 = ls_input-doktl

*     PF_FTP_DEST              = 'SAPFTPA'

*     PF_HTTP_DEST             = ' '

      pf_hostname              = 'DEFAULT'

      pf_content_provide       = 'TBL'

*     PS_API_CONTROL           =

*   IMPORTING

*     PSX_MESSAGE              =

*     PSX_FILE                 =

*     PSX_DRAW                 =

    TABLES

      ptx_content              = lt_drao.

   LOOP AT lt_drao INTO wa_drao.

     wa_bin = wa_drao-orblk.

     APPEND wa_bin TO lt_bin.

   ENDLOOP.

   DESCRIBE TABLE lt_drao LINES v_line.

   size = 2550 * v_line.

   CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

     EXPORTING

       input_length       = size

*     FIRST_LINE         = 0

*     LAST_LINE          = 0

    IMPORTING

      buffer             = file_data

     TABLES

       binary_tab         = lt_bin

*   EXCEPTIONS

*     FAILED             = 1

*     OTHERS             = 2

             .

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

     EXPORTING

       i_filename      = 'abc.pdf'

       i_content       = file_data

       i_mime_type     = 'application/pdf'

*     i_in_new_window = ABAP_FALSE

*     i_inplace       =  ABAP_FALSE

     .


Answers (4)

Answers (4)

0 Kudos

Hi ,

If you know the document number and its type etc then you can try below code. this code will display your DMS document in a new window from any webdynpro component

CALL FUNCTION 'C_DESK_DOC_GET_URL'

EXPORTING

pf_dokar =

pf_doknr =

pf_dokvr =

pf_doktl =

IMPORTING

pt_url = lt_url.

READ TABLE lt_url INTO ls_url INDEX 1.

lv_url = ls_url-url.

DATA lo_window_manager TYPE REF TO if_wd_window_manager.

DATA lo_api_component TYPE REF TO if_wd_component.

DATA lo_window TYPE REF TO if_wd_window.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

CALL METHOD lo_window_manager->create_external_window

EXPORTING

url = lv_url

title = 'Document Details'

modal = abap_false

has_menubar = abap_true

is_resizable = abap_true

has_scrollbars = abap_true

has_statusbar = abap_true

has_toolbar = abap_true

has_location = abap_true

RECEIVING

window = lo_window.

lo_window->open( ).

christoph_nagl
Participant
0 Kudos

Hey,

I had the same problem. I have a webdynpro and want to save the file to the application server with the following function:

CALL FUNCTION 'CVAPI_DOC_CHECKOUTMODIFY'

EXPORTING

pf_dokar = ls_draw-dokar

pf_doknr = ls_draw-doknr

pf_dokvr = ls_draw-dokvr

pf_doktl = ls_draw-doktl

  • PS_DOC_STATUS =

pf_ftp_dest = 'SAPFTPA'

pf_http_dest = 'SAPHTTPA'

  • PF_HOSTNAME = ' '

  • PS_API_CONTROL =

  • PF_REPLACE = ' '

  • PF_CONTENT_PROVIDE = 'SRV'

IMPORTING

psx_message = ls_message_cvapi

TABLES

pt_files = lt_originals

  • PT_COMP_X =

  • PT_CONTENT =

.

But I got the error that the creation of the file was not possible. Do you have any idea what was wrong?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Have you tested the SAPFTPA or SAPHTTPA destinations from SM59 to make sure they are correctly setup? Do you have any error details which you can share? This is an older thread and you probably shouldn't be posting a new question here, eventhough it is somewhat related.

Former Member
0 Kudos

Hi,

You can try this.

1.Call the FM BAPI_DOCUMENT_CHECKOUTVIEW2

EXPORTING

documenttype

documentnumber

docpart

docversion

documentfile

getcomponents = 'X'

getstructure = '1'

getheader = 'X'

pf_ftp_dest = 'SAPFTPA'

IMPORTING

return

TABLES

documentfiles = lt_co_docfiles.

- do not pas pf_http_dest in the call to FM above.

2. lt_co_docfiles will have the DMS file along with all of its attachments.

3. now loop through lt_co_docfiles and call SCMS_DOC_READ followed by SCMS_BINARY_TO_XSTRING.

At the end of these you will have the XSTRING of the file. Which you can use to download to desktop using the attach_file_to_response method.

Thanks,

Abhishek

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

SAPHTTPA and SAPFTPA both write to the file system of the Application Server (hence the A at the end) and not the presentation server (clinet PC). They can be used in Web Dynpro becuase they write to the local filesystem of the application server since this doesn't require a SAPGUI connection. If you want the PC to be able to access these files as well, then you need a network file share that is mounted to both your SAP Application Servers and all PCs.

You can't use SAPHTTP or SAPFTP because they connections use the SAPGUI to communicate with the PC. There is of course no SAPGUI connection when running Web Dynpro in Browser. From the Browser access to the client machine is limited for security reasons. Web Dynpro can download files via FileDownload UI element or on 7.01 via ACFUpDownload. However these older BAPI APIs don't offer any Web Dynpro specific funtionliaty. You either need to use the Application Server file system based approach described above or read the file content directly into an ABAP variable (XSTRING) so that it can be downloaded via WDA mechanisms.

Former Member
0 Kudos

Thanks for your quick reply.

Are there any function module to achieve the downloading?

Please share.

Thank you.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Thanks for your quick reply.

> Are there any function module to achieve the downloading?

> Please share.

>

> Thank you.

What exactly do you want? I've already described your options. There are no function modules for downloading in Web Dynpro ABAP in general . You either use the FileDownload UI element (or the ACFUpDownload in 7.01+) or use the cl_wd_runtime_services=>attach_file_to_response class.

There is certainly no function module that will allow you to bypass the browser security mechanisms or to connect to the SAPGUI when no connection exsists.

Former Member
0 Kudos

Hi TRUPTI KALLURWAR,

You can use the following FM's to get the XStrings you need. Then use method described by Thomas to get the Xstring to the browser. There might be easier solutions, not sure, but this works.

Call FM ''CV120_KPRO_MASTER_DATA_GET' with the key document data.

The ptx_data table is a complex table. You need the tbl_phios table, specifically the ph_objid field.

Call FM 'CV120_KPRO_CHECKOUT_TO_TABLE' using the ph_objid field.

You now have a XString table of the file.

Call FM 'SCMS_BINARY_TO_XSTRING' to convert the table to a XString.

Call the method described by Thomas to get the file to the browser.

Cheers

JS

Former Member
0 Kudos

Thomas, I am little confused here.

I understood the FileDownload UI element can be used to download the file(s). But what I have read on sdn about this UI element is this UI element is useful for opening/displaying the file from the file explorer of local drive.(This is my first WebDynpro application and did not use FileDownload UI element before)

Question remains from my side is how do we download the files from DMS content server?

I will appreciate details of this.

Thanks.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

FileDownload UI element downloads content from ABAP memory on the application server to the Client side browser.

>But what I have read on sdn about this UI element is this UI element is useful for opening/displaying the file from the file explorer of local drive.

You have incorrect information then. This isn't what it is for. It is used to download content to the local drive.

>Question remains from my side is how do we download the files from DMS content server?

Use the function modules that schujk suggested to get the file content from the DMS Content Server into ABAP memory. Then you can use the FileDownload UI element to download the content from application server memory to the client side.