cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to download the document

Former Member
0 Kudos

Hello,

When i click on a link, which can show the stored document in DMS, what are the BAPIs called, is it BAPI_DOCUMENT_GETDETAIL2 only or along with it is der any other bapi that will load the document from DMS to portal.

I see that BAPI_DOCUMENT_GETDETAIL2 gives the details of file like storage catagory, file path etc..but it is not fetching the file, Please correct me if i am wrong.

Thanks,

Kishore.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kishore,

Please follow the steps to Download a file from DMS or Display in Browser.

1. Call BAPI u2018BAPI_DOCUMENT_GETDETAIL2u2032

call function u2018BAPI_DOCUMENT_GETDETAIL2u2032

exporting

documenttype = document_key-doctype

documentnumber = document_key-docnumber

documentpart = document_key-docpart

documentversion = document_key-docversion

getcomponents = u2018Xu2019

getdocdescriptions = u2018Xu2019

getdocfiles = u2018Xu2019

getclassification = u2018Xu2019

importing

documentdata = documentdata

return = lv_return

tables

documentdescriptions = it_documentdescriptions

documentfiles = it_documentfiles

characteristicvalues = it_characteristicvalues

classallocations = it_classallocations.

2. Then call BAPI_DOCUMENT_CHECKOUTVIEW2

documentfile-wsapplication = it_documentfiles-wsapplication.

call function u2018BAPI_DOCUMENT_CHECKOUTVIEW2u2032

exporting

documenttype = document_key-doctype

documentnumber = document_key-docnumber

documentpart = document_key-docpart

documentversion = document_key-docversion

documentfile = documentfile

getstructure = u20181u2032

getheader = u2018Xu2019

pf_ftp_dest = u2018SAPFTPAu2019

importing

return = lv_return

tables

documentfiles = it_co_documentfiles.

You need to pass PF_FTP_DEST as SAPFTPA as we are calling this FM from Browser not SAP GUI and if you dont pass this value then the FM errors out because it doesnu2019t find SAP GUI.

3. Now call SCMS_DOC_READ to get the Binary Data of the File.

call function u2018SCMS_DOC_READu2019

exporting

mandt = sy-mandt

stor_cat = c_storage

doc_id = it_co_documentfiles-file_id

tables

access_info = lt_access

content_bin = lt_sdokcntbin.

IT_SDOKCNTBIN is the Binary Data Table of the file you want to download.

Now you have the binary file data which you can write on Application Server or Convert it to XSTRING and show in a web dynpro application. I am not sure how to display in BSP.