on 06-16-2007 12:08 AM
I have a strange problem.
I need to download a pdf doc from DMS. I got the external bapi call that returns the file binary data as array of 2550 length rawdata ('x') type.
I convert this into XSTRING and use filedownloadUI to open it.
Works FINE!!
However, the
following code
, attached to a button action, calling attach_file_to_responsedoes not work.
call method cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = line_Filecontent_Node-filename
i_content = line_Filecontent_Node-filecontent
i_mime_type = line_Filecontent_Node-mimetype.
* i_in_new_window = abap_true
* i_inplace = abap_false.
The following code, linked to
filedownloadUI is working:
types: char3(3).
types: char255(255).
data: dappl type char3.
data: filename type char255.
data: dms_content type table of YBAPI_DMSCONTENT initial size 0.
field-symbols <content> like line of dms_content.
data: BIN_FILESIZE TYPE I.
types: field2550(2550) type x.
data: content_binary type table of field2550 initial size 0.
field-symbols <content_binary_row> like line of content_binary.
data: loopCount type i,
xstringTab type table of xstring.
data xstringRow type xstring.
data datastream type xstring.
***** for xstring conversion ******
data conv_out type ref to cl_abap_conv_out_ce.
conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
loopCount = 0.
data: counter type i,
xlen type i,
totalRead type i,
remain2read type i.
loop at dms_content assigning <content>.
bin_filesize = <content>-length.
counter = <content>-counter.
loopCount = loopCount + 1.
xlen = 2550.
at last.
totalRead = ( loopCount - 1 ) * 2550.
remain2read = <content>-length - totalRead.
xlen = remain2read . "603.
endat.
conv_out->convert(
exporting
data = <content>-data(xlen)
importing
buffer = xstringRow ).
append xstringRow to xstringTab.
endloop.
concatenate LINES OF xstringTab into datastream in byte mode.
Stru_Filecontent_Node-FILECONTENT = datastream.
case dappl.
when 'doc' or 'DOC'.
Stru_Filecontent_Node-MIMETYPE = 'application/word'.
when 'xls' or 'XLS'.
Stru_Filecontent_Node-MIMETYPE = 'application/excel'.
when 'pdf' or 'PDF'.
Stru_Filecontent_Node-MIMETYPE = 'application/pdf'.
when others.
Stru_Filecontent_Node-MIMETYPE = 'plain/text'.
endcase.
node->bind_structure( Stru_Filecontent_Node ).
endmethod.
However, both segments of code works for other types of file, like office docs, tiff image, jpg, etc.
Only on PDF, we have problem.
Please help.
Hello Cathy:
What' s the external bapi call that returns the file binary data as array of 2550 length rawdata ('x') type???.
Regards.
Ana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What do you mean with "does not work"?
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cathy,
Im also developing a WDA application to download a document from DMS, Can u share the Function module which returns the X string value, so that i can use the file download UI element to download the Document...
Actually i tried calling the FM CV120_Start_application, but im getting "Not supported by Gui" Exception...
Please help me Cathy, its really urgent....
Thanks in advance....
James...
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.