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: 

PDF

Former Member
0 Kudos

HI SDN's

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

2 REPLIES 2

Former Member
0 Kudos

Find the below code for converting to pdf and sending mail

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.

0 Kudos

i have written the code, and getting the error which is mentioned above.. How to resolve it?