Skip to Content
author's profile photo Former Member
Former Member

Error in opening the PDF mail attachment

HI SDN's

I have to send order confirmation thru mail as a pdf attachment as soon as order has been saved.

I have written the code and assigned to output type.

Here I am getting an error opening a converted pdf file with Adobe Reader

The error message reads:

Adobe Reader could not open "filename.PDF" because it is either not a supported file type or because the file has been corrupted (for example, it was sent as an email attachment and wasn't correctly decoded).

Any help would be appreciated.

Thanks in advance

VR

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 24, 2007 at 07:48 PM

    Hi,

    This problem normally occurs if there are gaps or breaks in the prepared output internal table. While preparing the output internal table make sure that the required ouput is continuous.

    Regards,

    Bharat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 24, 2007 at 07:49 PM

    Hi,

    Check the following program:

    http://www.sap-img.com/abap/sending-email-with-attachment.htm

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 24, 2007 at 07:49 PM

    DATA : lt_otf LIKE itcoo OCCURS 200 WITH HEADER LINE.

    DATA : lv_filesize TYPE i,

    lt_doc LIKE docs OCCURS 200 WITH HEADER LINE,

    lt_lines1 LIKE tline OCCURS 200 WITH HEADER LINE,

    gv_buffer TYPE string.

    DATA : gt_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE.

    DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

    DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

    DATA: objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE.

    DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

    DATA: doc_chng LIKE sodocchgi1.

    DATA: objhead TYPE soli_tab,

    l_attachment TYPE i,

    l_testo TYPE i.

    LOOP AT job_output_info-otfdata INTO lt_otf.

    APPEND lt_otf TO lt_otf.

    ENDLOOP.

    CALL FUNCTION 'CONVERT_OTF_2_PDF'

    EXPORTING

    use_otf_mc_cmd = 'X'

    • ARCHIVE_INDEX =

    IMPORTING

    bin_filesize = lv_filesize

    TABLES

    otf = lt_otf

    doctab_archive = lt_doc

    lines = lt_lines1

    EXCEPTIONS

    err_conv_not_possible = 1

    err_otf_mc_noendmarker = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    LOOP AT lt_lines1.

    TRANSLATE lt_lines1 USING ' ~'.

    CONCATENATE gv_buffer lt_lines1 INTO gv_buffer.

    ENDLOOP.

    TRANSLATE gv_buffer USING '~ '.

    DO.

    gt_mess_att = gv_buffer.

    APPEND gt_mess_att.

    SHIFT gv_buffer LEFT BY 255 PLACES.

    IF gv_buffer IS INITIAL.

    EXIT.

    ENDIF.

    ENDDO.

    • Objects to send mail.

    CLEAR: reclist, reclist[],

    objhead, objhead[],

    objtxt, objtxt[],

    objbin, objbin[],

    objpack, objpack[].

    • Object with PDF.

    CLEAR objbin.

    REFRESH objbin.

    objbin[] = gt_mess_att[].

    DESCRIBE TABLE objbin LINES l_attachment.

    • Object with main text of the mail.

    objtxt = 'Invoice'.APPEND objtxt.

    DESCRIBE TABLE objtxt LINES l_testo.

    • Document information.

    doc_chng-obj_name = 'URGENT'.

    doc_chng-expiry_dat = sy-datum + 10.

    CONCATENATE 'Invoice' wa_vbrk-vbeln

    INTO doc_chng-obj_descr SEPARATED BY space.

    • doc_chng-sensitivty = 'F'.

    doc_chng-sensitivty = 'P'.

    doc_chng-obj_prio = '1'.

    doc_chng-doc_size = l_testo * 255.

    • Pack to main body.

    CLEAR objpack-transf_bin.

    objpack-head_start = 1.

    objpack-head_num = 0.

    objpack-body_start = 1.

    objpack-body_num = l_testo.

    objpack-doc_type = 'RAW'.

    APPEND objpack.

    • Pack to PDF.

    objpack-transf_bin = 'X'.

    objpack-head_start = 1.

    objpack-head_num = 1.

    objpack-body_start = 1.

    objpack-body_num = l_attachment.

    objpack-doc_type = 'PDF'.

    objpack-obj_name = 'TEST'.

    CONCATENATE wa_vbrk-vbeln '.pdf'

    INTO objpack-obj_descr.

    objpack-doc_size = l_attachment * 255.

    APPEND objpack.

    CLEAR reclist.

    reclist-copy = 'X'.

    • e-mail receivers.

    reclist-receiver = lv_smtp_addr.

    reclist-express = 'X'.

    reclist-rec_type = 'U'.

    reclist-notif_del = 'X'.

    reclist-notif_ndel = 'X'.

    APPEND reclist.

    • funcion mod for email.

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    • document_type = 'RAW'

    document_data = doc_chng

    put_in_outbox = 'X'

    *& defect # 917....to remove commit_in_posting ghegde Mar-30-2006

    • commit_work = 'X'

    *& end of defect # 917

    TABLES

    packing_list = objpack

    object_header = objhead

    contents_bin = objbin

    contents_txt = objtxt

    receivers = reclist

    EXCEPTIONS

    too_many_receivers = 1

    document_not_sent = 2

    document_type_not_exist = 3

    operation_no_authorization = 4

    parameter_error = 5

    x_error = 6

    enqueue_error = 7

    OTHERS = 8.

    IF sy-subrc <> 0.

    • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'

    EXPORTING

    MSG_ARBGB = 'ZZ_MSG'

    MSG_NR = '000'

    MSG_TY = 'E'

    MSG_V1 = syst-msgv1

    MSG_V2 = syst-msgv2

    MSG_V3 = syst-msgv3

    MSG_V4 = syst-msgv4

    EXCEPTIONS

    OTHERS = 1.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.