Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GUI_Download: Error opennig the document, file is damaged and could not be repaired

sachin_s_panchal
Explorer
0 Kudos

Hi ,

I am using SCMS_XSTRING_TO_BINARY FM to convert the Xstring data to binary data.

And then using GUI_download to generate PDF.

but the generated pdf file is damaged and not able to read it.

Below is the code:

REPORT Z_XSTRING_TO_PDF.

data: data_tab type table of x255,
lv_content TYPE Xstring,
len type i,
filename TYPE STRING.
Filename = 'C:\Users\panchasa\Desktop\test1.pdf'.
"passing the Xstring data to lv_content .
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = lv_content
* APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH = len
TABLES
BINARY_TAB = data_tab.
.
cl_gui_frontend_services=>gui_download(

exporting

BIN_FILESIZE = len

filename = FILENAME

filetype = 'BIN'

changing

data_tab = data_tab ).

cl_gui_frontend_services=>execute(
exporting
document = filename ) .

Can you please help me to findout, what I am doing wrong?

Regards,

Sachin.

4 REPLIES 4

horst_keller
Product and Topic Expert
Product and Topic Expert

"using GUI_download to convert it to pdf."

Since when does GUI_download convert data?

Why do you expect it to do so?

In binary mode it simply writes binary data and apparently you write wrong data.

0 Kudos

Hi ,

Thank you for your response.

Sorry, that was a typo, i am using GUI_download to generate the PDF file by using the data in "data_tab[]" .

but the generated file is damaged , and not able to open it.

sachin_s_panchal
Explorer
0 Kudos

Closing the thread. Got the answer.

<moderator edit - reopened so OP can share answer>

We are a community. You came to the community asking for help. People were prrepared to share their knowledge, time and effort trying to help you. Therefore it's only fair that you share with us what the answer is, so that other people can share your knowledge.

I have reopened the thread for you to provide that information, since I'm sure that really, you are a community minded person.