2012 Jun 28 4:05 PM
Dear all,
I'd like to download PDF that is stored in table as rawstring using ABAP program. Here's the scenario.
Users upload the PDF using webdynpro application. The PDF is then saved into a custom table with field of type rawstring. I need to create an ABAP program to retrieve the PDF and save into local pc. I've no authorization to run or test to debug the webdynpro application.
I'd like to know how do I convert the rawstring back into PDF using ABAP program and eventually download into local pc? I've tried using several FM like SCMS_XSTRING_TO_BINARY and etc., and download it using GUI_DOWNLOAD or cl_gui_frontend_services=>gui_download but it always dump giving error about the rawstring.
Basically what I want to achieve is using table control to list all the PDF, then users can double click on the file they want to see or save into local pc. Kindly advise on how to convert rawstring back to PDF. Is it even possible to download the PDF using ABAP program or this function is specific to webdynpro only?
Thanks in advance.
Dear all,
I'd like to download PDF that is stored in table as rawstring using ABAP program. Here's the scenario.
Users upload the PDF using webdynpro application. The PDF is then saved into a custom table with field of type rawstring. I need to create an ABAP program to retrieve the PDF and save into local pc. I've no authorization to run or test to debug the webdynpro application.
I'd like to know how do I convert the rawstring back into PDF using ABAP program and eventually download into local pc? I've tried using several FM like SCMS_XSTRING_TO_BINARY and etc., and download it using GUI_DOWNLOAD or cl_gui_frontend_services=>gui_download but it always dump giving error about the rawstring.
Basically what I want to achieve is using table control to list all the PDF, then users can double click on the file they want to see or save into local pc. Kindly advise on how to convert rawstring back to PDF. Is it even possible to download the PDF using ABAP program or this function is specific to webdynpro only?
Thanks in advance.
2012 Jun 28 6:12 PM
Hi Liang,
what error are you getting? I've done this lots of times using SCMS_XSTRING_TO_BINARY and
cl_gui_frontend_services=>gui_download and it has worked fine!
Cheers,
Kimon
2012 Jun 29 2:27 AM
Hi Kimon,
I got error in FM SCMS_XSTRING_TO_BINARY:
| Code |
|---|
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' // cl_gui_frontend_services=>gui_download here |
gw_test-content = CCBC65706449922D2C66662C31B394C2123333ABC45CC212B34ACCCCCCCCCCCCCCCC8C25A6123E754FEFCECC7E6DFBCDAF672FCDD222EECD88C8F0E37E3CFCBA792699BCB0281D133D2B3CD9EEDED41C3C0C2B2B072123A18DC177786E6E0669736B637D3B733763234226066942560033232B831C212B1B23830821130B13132B832C213B8332212B0B3B070B8338A11621800340C8CCC2A6CDCB0B6F6C6DF4C73A84FFE3F5F91DECCCFFFC0E6163431B2363797D3B2BFBCF2B211B4B472B6B7B420083BC9DB191B9A1838D1D2113332F2F83A8B9A583B11D83A8A5BE83F13FA63048086B71B3B0710A323309B2723271703202004C9C006101514E414600
lv_length = 54205
2012 Jun 29 6:18 AM
Hi Liang,
I just executed as below and it didnt give any dump.
DATA: gt_content TYPE TABLE OF xstring WITH HEADER LINE,
lv_length TYPE i,
gt_text TYPE TABLE OF sdokcntasc,
gt_data TYPE TABLE OF x255.
gt_content = 'CCBC65706449922D2C66662C31B394C2123333ABC45CC212B34ACCCCCCCCCCCCCCCC8C25A6123E754FEFCECC7E6DFBCDAF672FCDD222EECD88C8'.
APPEND gt_content.
gt_content = 'F0E37E3CFCBA792699BCB0281D133D2B3CD9EEDED41C3C0C2B2B072123A18DC177786E6E0669736B637D3B733763234226066942560033232B83'.
APPEND gt_content.
gt_content = '1C212B1B23830821130B13132B832C213B8332212B0B3B070B8338A11621800340C8CCC2A6CDCB0B6F6C6DF4C73A84FFE3F5F91DECCCFFFC0E61'.
APPEND gt_content.
gt_content = '63431B2363797D3B2BFBCF2B211B4B472B6B7B420083BC9DB191B9A1838D1D2113332F2F83A8B9A583B11D83A8A5BE83F13FA63048086B71B3B0'.
APPEND gt_content.
gt_content = '710A323309B2723271703202004C9C006101514E414600'.
APPEND gt_content.
LOOP AT gt_content.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = gt_content
append_to_table = 'X'
IMPORTING
output_length = lv_length
TABLES
binary_tab = gt_data.
ENDLOOP.
2012 Jun 29 7:25 AM
Hi Shambu,
Yes, it does not result in dump now. But after download, I can't open the PDF. It's corrupted. I suspect it's been compressed when saved into the table, so I use method cl_abap_gzip=>decompress_binary to decompress, but the file is still corrupted.
Regards,
Liang
2012 Jun 29 7:27 AM
2012 Jun 29 7:41 AM
It's being saved into the table through a Webdynpro interface. I don't really know the technical details or the code because I don't have the authorization to debug it.
Regards,
Liang
2012 Jun 29 7:39 AM
Hi,
How are you downloading the binary file on local PC.
Can you pls provide the code ...
***You can also use XSTRING_TO_SOLIX method of Cl_BCS_Convert .
and download solix tab to local PC by passing format 'BIN'.
i think you must try this ...
Deeps
2012 Jun 29 7:49 AM
The code is the same as Shambu's. I added this download code below it. The lv_length variable, I've tried with 255 and also the original length 54205. The file is still corrupted.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = lv_length
filename = 'C:\test\test.pdf'
filetype = 'BIN'
* IMPORTING
* filelength =
CHANGING
data_tab = gt_data
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Regards,
Liang
2012 Jun 29 10:15 AM
Hello,
Try this.
DATA: filename TYPE string,
path TYPE string,
fullpath TYPE string,
default_extension TYPE string VALUE 'PDF'.
cl_gui_frontend_services=>file_save_dialog(
EXPORTING
default_extension = default_extension
CHANGING
filename = filename
path = path
fullpath = fullpath ).
CHECK fullpath IS NOT INITIAL.
DATA: data_tab TYPE TABLE OF x255.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = fp_formoutput-pdf
TABLES
binary_tab = data_tab.
*filename = 'E:\adobe\emptest.pdf'.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = filename
filetype = 'BIN'
CHANGING
data_tab = data_tab ).
cl_gui_frontend_services=>execute(
EXPORTING
document = filename ).
Good Luck,
Kiron
2012 Aug 13 1:52 PM
Hi Kiron,
I think you have to parse the rawstring so that it will be converted from rawstring to string.
I have faced a similar issue when I was uploading a pdf and I wanted the data into a structure.
Is this what you want ?, please confirm, so that I can provide you the code for the same.
Regards,
Aakash Awasthi