05-13-2018 1:08 PM
Hello All,
I am reading pdf file from application server and attaching it to a document in FB03.
I see that file is successfully attached. However, when i download it, reading is giving error of corrupt file.
Below is code snippet. Could you please let me know where is the issue ?
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0. "Attachment file
READ DATASET p_file INTO l_filestring.
CLOSE DATASET p_file.
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; }
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = l_filestring
IMPORTING
OUTPUT_LENGTH = l_doc_size
tables
binary_tab = lt_doc.
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }
TRY.
swc_create_object l_message 'MESSAGE' l_message_key.
swc_set_element l_message_container 'DOCUMENTTITLE' 'TestGOS'.
swc_set_element l_message_container 'DOCUMENTLANGU' sy-langu.
swc_set_element l_message_container 'NO_DIALOG' 'X'.
swc_set_element l_message_container 'DOCUMENTNAME' 'MESSAGE'.
swc_set_element l_message_container 'DOCUMENTTYPE' 'PDF'.
CATCH cx_root INTO l_cx_root.
ENDTRY.
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; }
TRY.
swc_set_table l_message_container 'Content_Hex' lt_doc1[].
swc_set_element l_message_container 'DOCUMENTSIZE' l_doc_size.
swc_refresh_object l_message.
swc_call_method l_message 'CREATE' l_message_container.
swc_get_object_key l_message l_message_key.
CATCH cx_root INTO l_cx_root.
ENDTRY.
After this called FM BINARY_RELATION_CREATE to create link.
05-14-2018 1:20 PM
Thanks all for your responses.
Not sure why but I removed line with attribute "DOCUMENTSIZE" and it worked.
05-14-2018 12:57 PM
Hello
please check the file size before and after the upload, is it the same?
Best regards
Jozsef H
05-14-2018 1:20 PM
Thanks all for your responses.
Not sure why but I removed line with attribute "DOCUMENTSIZE" and it worked.