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: 

regarding the uploading the pdf file to the application server

Former Member
0 Kudos

hi,

iam getting this error while uploading the pdf file to the applicatioin server.

"There was an error while trying to parse an image"

to convert smartform into PDF file we ll use convert_otf FM.

If see that FM data ll be stored in it_tline structure ok.

For sending to application server we ll use

OPEN DATASET p_arch for OUTPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.

LOOP AT it_tline.

TRANSFER it_tline to p_arch.

ENDLOOP.

CLOSE DATASET p_arch.

Ok

For getting data from internal table we ll use

OPEN DATASET p_arch FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS

do.

READ DATASET p_arch INTO it_tline.

if sy-subrc = 0.

APPEND it_tline.

ELSE .

exit.

endif.

enddo.

CLOSE DATASET p_arch.

LOOP AT it_tline.

TRANSLATE it_tline USING '~'.

CONCATENATE wa_buffer it_tline INTO wa_buffer.

ENDLOOP.

TRANSLATE wa_buffer USING '~'.

DO.

i_record = wa_buffer.

APPEND i_record.

SHIFT wa_buffer LEFT BY 255 PLACES.

IF wa_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

  • Attachment

REFRESH:

i_reclist,

i_objtxt,

i_objbin,

i_objpack.

CLEAR wa_objhead.

i_objbin[] = i_record[].

              • Create Message Body

        • Title and Description

i_objtxt = 'COMMERCIAL INVOICE'.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_lines_txt.

READ TABLE i_objtxt INDEX v_lines_txt.

wa_doc_chng-obj_name = 'COMMERCIAL INVOICE'.

wa_doc_chng-expiry_dat = sy-datum + 10.

wa_doc_chng-obj_descr = 'COMMERCIAL INVOICE'.

wa_doc_chng-sensitivty = 'F'.

wa_doc_chng-doc_size = v_lines_txt * 255.

CLEAR i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

      • Attachment

  • (pdf-Attachment)

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

DESCRIBE TABLE i_objbin LINES v_lines_bin.

READ TABLE i_objbin INDEX v_lines_bin.

i_objpack-doc_size = v_lines_bin * 255 .

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'COMMERCIAL INVOICE'.

i_objpack-obj_descr = 'COMMERCIAL INVOICE'.

APPEND i_objpack.

BREAK-POINT.

IF it_adr6[] IS NOT INITIAL.

LOOP AT it_adr6 INTO wa_adr6.

CLEAR i_reclist.

i_reclist-receiver = wa_adr6-smtp_addr.

i_reclist-rec_type = 'U'.

i_reclist-com_type = 'INT'.

APPEND i_reclist.

ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist.

ENDIF.

The above error I am getting.

Please give your suggestions

Thanks in advance

1 REPLY 1

Former Member
0 Kudos

U can use this code

Reward if useful

REPORT ZMN_PDF_UPLOAD.

data: begin of itab occurs 0,

field(256),

end of itab.

data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\testpdf',

length like sy-tabix,

lengthn like sy-tabix.

call function 'GUI_UPLOAD'

exporting

filename = 'c:\temp\test.pdf'

filetype = 'BIN'

importing

filelength = length

tables

data_tab = itab.

open dataset dsn for output in binary mode.

loop at itab.

transfer itab-field to dsn.

endloop.

close dataset dsn.

clear itab.

refresh itab.

*To crosscheck if it went well

open dataset dsn for input in binary mode.

do.

read dataset dsn into itab-field.

if sy-subrc = 0.

append itab.

else.

exit.

endif.

enddo.

call function 'GUI_DOWNLOAD'

exporting

filename = 'c:\temp\testn.pdf'

filetype = 'BIN'

bin_filesize = length

importing

filelength = lengthn

tables

data_tab = itab.

*Or

*

*Use the TCode

*CG3Z or CG3Y

*for downloading to Application Server.