2006 Sep 01 5:01 AM
Hi,
I manage to send pdf to email with attachment, but getting this error
"An unrecognized token BT28.35" was found"
My code:
statics: ls_doc type sodocchgi1,
lv_lines type i,
ls_objhead type soli_tab,
i_objpack type table of sopcklsti1 WITH HEADER LINE,
i_objtxt type table of solisti1 WITH HEADER LINE,
i_objbin type table of solisti1 WITH HEADER LINE,
i_reclist type table of somlreci1 wiTH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = lv_filesize
TABLES
OTF = gs_output-otfdata
LINES = gt_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
refresh: i_objpack, i_objtxt, i_objbin, i_reclist.
convert to bin
LOOP AT gt_lines into gs_lines.
TRANSLATE gs_lines USING '~'.
CONCATENATE gs_buffer gs_lines INTO gs_buffer.
ENDLOOP.
TRANSLATE gs_buffer USING '~'.
DO.
i_objbin = gs_buffer.
APPEND i_objbin.
SHIFT gs_buffer LEFT BY 255 PLACES.
IF gs_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Create Message Body
Title and Description
concatenate 'Invoice' ls_rseg-belnr
into i_objtxt separated by space.
append i_objtxt.
describe table i_objtxt lines lv_lines.
read table i_objtxt index lv_lines.
ls_Doc-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into ls_Doc-obj_descr
separated by space.
ls_doc-expiry_dat = sy-datum + 10.
ls_Doc-sensitivty = 'F'.
ls_Doc-doc_size = lv_lines * 255.
clear i_reclist.
i_reclist-receiver = gv_emailaddr.
i_reclist-rec_type = 'U'.
append i_reclist.
clear i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'RAW'.
append i_objpack.
(pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
Länge des Attachment ermitteln
describe table i_objbin lines lv_lines.
read table i_objbin index lv_lines.
i_objpack-doc_size = lv_lines * 255.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into i_objpack-obj_descr
separated by space.
append i_objpack.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = ls_objhead
CONTENTS_BIN = i_objbin
contents_txt = i_objtxt
receivers = i_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 e398(00) with 'Email ERS invoice failed'
ls_rseg-belnr into g_dummy.
cf_retcode = sy-subrc.
PERFORM protocol_update.
endif.
Hi,
I manage to send pdf to email with attachment, but getting this error
"An unrecognized token BT28.35" was found"
My code:
statics: ls_doc type sodocchgi1,
lv_lines type i,
ls_objhead type soli_tab,
i_objpack type table of sopcklsti1 WITH HEADER LINE,
i_objtxt type table of solisti1 WITH HEADER LINE,
i_objbin type table of solisti1 WITH HEADER LINE,
i_reclist type table of somlreci1 wiTH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = lv_filesize
TABLES
OTF = gs_output-otfdata
LINES = gt_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
refresh: i_objpack, i_objtxt, i_objbin, i_reclist.
convert to bin
LOOP AT gt_lines into gs_lines.
TRANSLATE gs_lines USING '~'.
CONCATENATE gs_buffer gs_lines INTO gs_buffer.
ENDLOOP.
TRANSLATE gs_buffer USING '~'.
DO.
i_objbin = gs_buffer.
APPEND i_objbin.
SHIFT gs_buffer LEFT BY 255 PLACES.
IF gs_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Create Message Body
Title and Description
concatenate 'Invoice' ls_rseg-belnr
into i_objtxt separated by space.
append i_objtxt.
describe table i_objtxt lines lv_lines.
read table i_objtxt index lv_lines.
ls_Doc-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into ls_Doc-obj_descr
separated by space.
ls_doc-expiry_dat = sy-datum + 10.
ls_Doc-sensitivty = 'F'.
ls_Doc-doc_size = lv_lines * 255.
clear i_reclist.
i_reclist-receiver = gv_emailaddr.
i_reclist-rec_type = 'U'.
append i_reclist.
clear i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'RAW'.
append i_objpack.
(pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
Länge des Attachment ermitteln
describe table i_objbin lines lv_lines.
read table i_objbin index lv_lines.
i_objpack-doc_size = lv_lines * 255.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into i_objpack-obj_descr
separated by space.
append i_objpack.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = ls_objhead
CONTENTS_BIN = i_objbin
contents_txt = i_objtxt
receivers = i_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 e398(00) with 'Email ERS invoice failed'
ls_rseg-belnr into g_dummy.
cf_retcode = sy-subrc.
PERFORM protocol_update.
endif.
2006 Sep 01 5:06 AM
hi
good
where you r passing the email id in your report, i think there is some problem with getting the host where you r sending the email, plz check that.
thanks
mrutyun
2006 Sep 01 5:13 AM
i am receiving the pdf in my email, but with the error i mentioned in my first posting.
email is in field gv_emailaddr.
2006 Sep 01 9:53 AM
HI
GOOD
GO THROUGH THIS LINK WHICH LL GIVE YOU BRIEF IDEA ABOUT SENDING PDF FILE USING MAIL, THAT YOU CAN IMPLEMNET IN YUOR PROGRAM
http://www.sapgenie.com/abap/example_code.htm
/people/emmanuele.prudenzano/blog/2006/08/03/an-advanced-solution-for-sending-email-from-solution-manager-or-crm
THANKS
MRUTYUN
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |