We are emailing a smartform to multiple recipients. The list of recipients is determined dynamically.
The objective is to send a single email with multiplie recipients with the form output as a PDF attachment.
SAP connect is fully configured.
I can generate the email with attachment, however, the pdf file is corrupt and will not open.
Any assistance is appreciated.
I am passing the OTF output of the form to FM "CONVERT_OTF" as shown. "l_t_job_output-otfdata" contains the OTF data.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
max_linewidth = 134
importing
bin_filesize = pdf_bytecount
tables
otf = l_t_job_output-otfdata
lines = objbin
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
if sy-subrc <> 0.
NUM1 = SY-SUBRC.
SX_TRACE_MSG C_SWTMI_SX_CONV 'SX_OBJECT_CONVERT_OTF_PDF'
'E' 032 FORMAT_SRC FORMAT_DST 'CONVERT_OTF' NUM1.
MESSAGE E834 RAISING ERR_CONV_FAILED.
endif.
Next the email is being prepared.
Create Message Body
Title and Description
docdata-obj_name = 'TEST_ALI'.
docdata-obj_descr = 'Test including PDF Attachment'.
Main Text
objtxt = 'Test Document.'.
append objtxt.
objtxt = 'You will find an PDFL attachment in this message.'.
append objtxt.
objtxt = 'Have a nice day.'.
append objtxt.
Write Packing List (Main)
describe table objtxt lines tab_lines.
read table objtxt index tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
clear objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
append objpack.
Create Message Attachment
Write Packing List (Attachment)
att_type = 'PDF'.
describe table objbin lines tab_lines.
read table objbin index tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + strlen( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'Attached Document'.
append objpack.
Create receiver list
reclist-receiver = 'toocanad@yahoo.com.
reclist-rec_type = 'U'.
append reclist.
reclist-receiver = sy-uname.
reclist-rec_type = 'B'.
append reclist.
Send Message
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
OBJECT_PARB =
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 'SO' type 'S' number '023'
with docdata-obj_name.
endif.