on 04-20-2009 8:42 AM
Dear freinds,
i have to send Payslip as PDF as email attachment. So i have used the FM BAPI_GET_PAYSLIP_PDF and further passed the data to FM
SO_NEW_DOCUMENT_ATT_SEND_API1.
But, now iam not able to open the attachment which is in my inbox and it is giving message as the pdf as file is curropt. please could any one tell me what i have to do in this regard
regards
vamsi.
Hi Sai,
call function 'CONVERT_OTF'
exporting
format = 'PDF'
max_linewidth = 132
importing
bin_filesize = w_filesize
tables
otf = t_otf
lines = t_line
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4.
loop at t_line.
concatenate w_string t_line into w_string.
endloop. " LOOP AT T_LINE
*" convert the 132 line character to 255 character ....................
do.
t_attach = w_string.
append t_attach.
shift w_string left by 255 places.
if w_string is initial.
exit.
endif. " IF W_STRING IS INITIAL
enddo. " DO
t_objbin[] = t_attach[].
*" Body of the mail..................................................
clear t_message. refresh t_message.
t_message = 'This is a mail from SAP ECC6'.
append t_message.
t_message = 'Thanks and Regards'.
append t_message.
t_message = 'Sravanthi'.
append t_message.
describe table t_message lines w_msg.
*" Document data.......................................................
w_docdata-obj_name = 'SAPRPT'.
w_docdata-expiry_dat = sy-datum + 10.
w_docdata-obj_descr = 'Smartform mail from Sravanthi'.
w_docdata-sensitivty = 'F'.
w_docdata-doc_size = w_msg * 255.
w_docdata-obj_langu = sy-langu .
*" Fill the packing list...............................................
clear t_packing_list. refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
t_packing_list-body_num = w_msg.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.
t_packing_list-transf_bin = 'X'.
describe table t_objbin lines w_objbin.
*" doc_size = (lines in pdf table) * 255...............................
t_packing_list-doc_size = w_objbin * 255.
t_packing_list-body_num = w_objbin.
t_packing_list-doc_type = 'PDF'.
t_packing_list-obj_name = 'smart'.
t_packing_list-obj_descr = 'test'.
append t_packing_list.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_docdata
put_in_outbox = 'X'
sender_address = w_sender
commit_work = 'X'
tables
packing_list = t_packing_list
contents_bin = t_objbin
contents_txt = t_message
receivers = t_receivers
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.
if sy-subrc ne 0.
write:/ 'Error When Sending the File', sy-subrc.
else.
write:/ 'Mail sent'.
endif.
Regards,
Sravanthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check this link.
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/mailsendthroughoutputcontrols
Thanks,
Anitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
pass below strcture
objpack-doc_type = 'PDF'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chennakesava,
iam already sending in my code as below
reclist-receiver = 'karan_702000 yahoo com' . "wa_mailst-recepient.
reclist-rec_type = 'U'.
reclist-rec_id = 'satrkn<'.
APPEND reclist.
ENDLOOP.
Mail heading
doc_chng-doc_size = '255'.
MOVE 'Payslip' TO doc_chng-obj_descr.
doc_chng-obj_prio = 1.
creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
OBJBIN[] = IT_LINES5[].
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'Payslip for the month' . "wrk_filename.
APPEND objhead.
creation of the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'Pay'.
objpack-obj_descr = 'Payslip'.
objpack-doc_size = tab_lines * 255.
objpack-doc_size = objpack-doc_size + 100.
APPEND objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
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.
CASE sy-subrc.
WHEN 0.
CLEAR flg_mail.
WRITE: / 'Mail Sent to respective users'.
ENDCASE.
Iam not able to open the attachment.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.