04-16-2007 11:50 AM
Hi,
My program sends an Email to the customer with an attachment. In the attachment, there are some junk characters in every alternate line of the attachment.
I have tried to debug the FM <b>SO_DOCUMENT_SEND_API1</b> and found that it is due to the code in FM <b>SO_CONVERT_CONTENTS_BIN</b> which is called in <b>SO_DOCUMENT_SEND_API1</b> where it is checking for the offset of the line and setting the l_convert flag (in case of UNICODE systems) and doing the actual changes. Please suggest me how to correct this.
Thanks in Advance.
Best Regards,
Phani Kumar.
04-16-2007 11:54 AM
04-16-2007 11:56 AM
Hi Chandra Sekhar,
If you have any sample program, can you please post it or send it to s.phanikumar@rediffmail.com.
Also kindly confirm whether this can be used to send email with attachments?
Regards,
Phani.
Message was edited by:
Sivapuram Phani Kumar
04-16-2007 11:58 AM
hi chk this sample prog:
report zMAIL_PROG.
data: itcpo like itcpo,
tab_lines like sy-tabix.
Variables for EMAIL functionality
data: maildata like sodocchgi1.
data: mailpack like sopcklsti1 occurs 2 with header line.
data: mailhead like solisti1 occurs 1 with header line.
data: mailbin like solisti1 occurs 10 with header line.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: solisti1 like solisti1 occurs 0 with header line.
perform send_form_via_email.
************************************************************************
FORM SEND_FORM_VIA_EMAIL *
************************************************************************
form send_form_via_email.
clear: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
refresh: mailtxt, mailbin, mailpack, mailhead, mailrec.
Creation of the document to be sent File Name
maildata-obj_name = 'TEST'.
Mail Subject
maildata-obj_descr = 'Subject'.
Mail Contents
mailtxt-line = 'Here is your file'.
append mailtxt.
Prepare Packing List
perform prepare_packing_list.
Set recipient - email address here!!!
mailrec-receiver = you@yourcompany.com'.
mailrec-rec_type = 'U'.
append mailrec.
Sending the document
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = ' '
tables
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
endform.
************************************************************************
Form PREPARE_PACKING_LIST
************************************************************************
form prepare_packing_list.
clear: mailpack, mailbin, mailhead.
refresh: mailpack, mailbin, mailhead.
describe table mailtxt lines tab_lines.
read table mailtxt index tab_lines.
maildata-doc_size = ( tab_lines - 1 ) * 255 + strlen( mailtxt ).
Creation of the entry for the compressed document
clear mailpack-transf_bin.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'RAW'.
append mailpack.
mailhead = 'TEST.TXT'.
append mailhead.
File 1
mailbin = 'This is file 1'.
append mailbin.
describe table mailbin lines tab_lines.
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'TXT'.
mailpack-obj_name = 'TEST1'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
*File 2
mailbin = 'This is file 2'.
append mailbin.
data: start type i.
data: end type i.
start = tab_lines + 1.
describe table mailbin lines end.
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = start.
mailpack-body_num = end.
mailpack-doc_type = 'TXT'.
mailpack-obj_name = 'TEST2'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
endform.
**reward if helpful
regards,
madhu
04-16-2007 11:59 AM
04-16-2007 12:04 PM
DATA: w_path LIKE rlgrap OCCURS 0 WITH HEADER LINE,
lt_index TYPE sy-tabix,
doc_type(3) TYPE c,
descr LIKE it_objpack_basis-obj_descr,
temp_data LIKE w_path,
temp1 TYPE string,
tab_lines TYPE i,
langu(15) TYPE c,
expirydate TYPE so_obj_edt,
L_FILE1(100).
CONCATENATE 'C:' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.
W_PATH-FILENAME = L_FILE1.
APPEND w_path.
CLEAR w_path.
wa_doc_chng-obj_descr = 'User List not logged on for 180 days'.
wa_doc_chng-obj_langu = 'E'.
wa_doc_chng-obj_expdat = sy-datum.
CLEAR w_subject.
CONCATENATE 'Please find attached document with list of users'
'not logged on for 180 days for client' sy-mandt
INTO w_subject SEPARATED BY space.
it_objtxt_basis-line = w_subject.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
it_objtxt_basis-line = text-004.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
CLEAR w_tab_line.
DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.
READ TABLE it_objtxt_basis INDEX w_tab_line INTO l_cline.
wa_doc_chng-doc_size =
( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).
CLEAR it_objpack_basis-transf_bin.
it_objpack_basis-head_start = 1.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = 1.
it_objpack_basis-body_num = w_tab_line.
it_objpack_basis-doc_type = 'RAW'.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
LOOP AT w_path.
temp1 = w_path.
descr = w_path.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = ''
string = descr
IMPORTING
head = descr
tail = temp_data.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = '.'
string = descr
IMPORTING
head = temp_data
tail = doc_type.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = temp1
filetype = 'BIN'
header_length = 0
read_by_line = 'X'
replacement = '#'
TABLES
data_tab = it_upload.
DESCRIBE TABLE it_upload LINES tab_lines.
DESCRIBE TABLE it_objbin_basis LINES lt_index.
lt_index = lt_index + 1.
LOOP AT it_upload.
wa_objbin_basis-line = it_upload-line.
APPEND wa_objbin_basis TO it_objbin_basis.
CLEAR wa_objbin_basis.
ENDLOOP.
it_objpack_basis-transf_bin = 'X'.
it_objpack_basis-head_start = 0.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = lt_index.
it_objpack_basis-body_num = tab_lines.
it_objpack_basis-doc_type = doc_type.
it_objpack_basis-obj_descr = descr.
it_objpack_basis-doc_size = tab_lines * 255.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
ENDLOOP.
it_reclist_basis-receiver = 'XXX@.com'.
it_reclist_basis-rec_type = 'U'.
APPEND it_reclist_basis.
CLEAR it_reclist_basis.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack_basis
contents_txt = it_objtxt_basis
contents_bin = it_objbin_basis
receivers = it_reclist_basis
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc EQ 0.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
04-16-2007 11:58 AM
Hi,
See the sample code using the fun module 'SO_NEW_DOCUMENT_ATT_SEND_API1':
also check the SMLT Transaction for the language related Unicode errors.
----
INCLUDE ZINCUSMAIL *
----
include <symbol>.
data : i_doc_data like sodocchgi1.
data : begin of i_pack_list occurs 0.
include structure sopcklsti1.
data : end of i_pack_list.
data : begin of i_receivers occurs 0.
include structure somlreci1.
data : end of i_receivers.
data : begin of i_contents occurs 0.
include structure solisti1.
data : end of i_contents.
data : begin of i_header occurs 0.
include structure solisti1.
data : end of i_header.
data : begin of i_att occurs 0.
include structure solisti1.
data : end of i_att.
Internal Table for Internet address.
data: begin of it_inad occurs 0,
kunnr like kna1-kunnr, " Customer Code
name1 like kna1-name1, " Customer Name
ssobl like knkk-ssobl, " Security Deposit
klimk like knkk-klimk, " Credit Limit
opbal like bsid-wrbtr, " Opening Balance
clbal like bsid-wrbtr, " Closing Balance
smtp like adr6-smtp_addr, " Internet mail (SMTP) address
end of it_inad.
data : pdf_line(134),
asdf like pdf_line occurs 0 with header line.
data : pdf_table like tline occurs 0 with header line,
pdf_fsize type i.
data : stuff(65000),
len type i,
pos type i,
tab_lines like sy-tabix.
data: spoolid type tsp01-rqident,
spdel type tsp01sys.
data: v_gjahrt like bsid-gjahr,
fmondest(10),
tmondest(10),
kunnr1 like kna1-kunnr,
gjah(4),
fmon(10).
&----
*& Form hide_write
&----
form hide_write.
new-page print on
line-size 160
line-count 58
no-title
no-heading
destination 'LOCL'
immediately ' '
new list identification 'X'
no dialog.
set blank lines on.
endform. " hide_write
&----
*& Form end_write
&----
form end_write using kunnr1.
set blank lines off.
new-page print off.
***Using Spoolid we are getting PDF formated file
spoolid = spdel-rqident = sy-spono.
spdel-sys = sy-sysid.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = spoolid
no_dialog = 'X'
importing
pdf_bytecount = pdf_fsize
tables
pdf = pdf_table
exceptions
others = 0.
***Delleting Spool request
call function 'RSPO_IDELETE_SPOOLREQ'
exporting
spoolreq = spdel
exceptions
others = 2.
***Converting PDF table line size 134 into standard list size 255
loop at pdf_table into pdf_line.
if pos = 34170.
perform attach.
endif.
stuff+pos(134) = pdf_line.
add 134 to pos.
endloop.
if not ( stuff is initial ).
perform attach.
endif.
clear pdf_line.
clear pdf_table[].
describe table i_att lines tab_lines.
i_pack_list-transf_bin = 'X'.
i_pack_list-head_start = '1'.
i_pack_list-head_num = '1'.
i_pack_list-body_start = '1'.
i_pack_list-body_num = tab_lines.
i_pack_list-doc_type = 'PDF'.
i_pack_list-obj_name = 'LedgerMail'.
concatenate fmon '-' gjah into i_pack_list-obj_descr.
*i_pack_list-obj_descr = '2092-Oct03'.
i_pack_list-obj_langu = 'E'.
i_pack_list-doc_size = tab_lines * 255.
append i_pack_list.
***Data for receivers list
loop at it_inad where kunnr eq kunnr1.
i_receivers-receiver = it_inad-smtp.
i_receivers-rec_type = 'U'.
i_receivers-rec_date = sy-datum.
i_receivers-express = 'X'.
i_receivers-com_type = 'INT'.
i_receivers-notif_del = 'X'.
append i_receivers.
endloop.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = i_doc_data
PUT_IN_OUTBOX = ' '
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
packing_list = i_pack_list
object_header = i_header
contents_bin = i_att
contents_txt = i_contents
receivers = i_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
others = 8
.
refresh i_att. clear i_att.
refresh i_receivers. clear i_receivers.
delete i_pack_list where doc_type = 'PDF'.
*refresh i_header.
*refresh i_contents.
*clear i_doc_data.
endform. " end_write
&----
*& Form doc_data
&----
form doc_data using fmondest v_gjahrt.
gjah = v_gjahrt.
fmon = fmondest.
***Data for Document Data
i_doc_data-obj_name = 'LedgerMail'.
concatenate 'Customer Ledger for : ' fmondest gjah
into i_doc_data-obj_descr separated by space.
i_doc_data-obj_langu = 'E'.
i_doc_data-obj_prio = '1'.
i_doc_data-no_change = 'X'.
i_doc_data-doc_size = '5101'.
***Data for Packing list
i_pack_list-head_start = '1'.
i_pack_list-head_num = '1'.
i_pack_list-body_start = '1'.
i_pack_list-body_num = '20'.
i_pack_list-doc_type = 'RAW'.
i_pack_list-obj_langu = 'E'.
append i_pack_list.
***Data for Header
i_header-line = 'Header'. append i_header.
***Data for contents
i_contents-line = 'Dear Customer,'. append i_contents.
i_contents-line = ' '. append i_contents.
concatenate 'Please find your enclosed Ledger for the month of : '
fmondest gjah into i_contents-line separated by space.
append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'This is a computer generated document and does not
require a signature.'. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'Note : If you do not have Acrobat Reader please click
on the below link.'. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'http://www.adobe.com/products/acrobat/readstep2.html'
. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
endform. " doc_data
&----
*& Form attach
&----
form attach.
clear pos.
len = strlen( stuff ).
while len > 0.
subtract 255 from len.
i_att = stuff+pos(255).
append i_att.
add 255 to pos.
endwhile.
clear pos.
clear stuff.
endform. " attach
reward if useful
regards,
Anji
04-16-2007 12:06 PM
Hi Anji Reddy,
As per your suggestion, I have used the FM <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b>. Even now the attachment consists of some junk characters.
For Example lets suppose that the attachment should consist of,
TEST1
TEST2
It consists of,
TEST1
䜀䤀 琀椀
TEST2
䜀䤀 琀椀.
Regards,
Phani.
04-16-2007 12:35 PM
Hi,
Reason for this is, length of the line is more than 128 characters. Tried by dividing the string up to 128 characters and attach to the tables parameter CONTENTS_BIN. Now, there are no junk characters. But the data that should come in one line is coming in two lines...!!!
Any one suggest me in solving the issue. Tried using the FM...<b>SO_NEW_DOCUMENT_ATT_SEND_API1</b> also. But no use... as this FM in turn calling <b>SO_DOCUMENT_SEND_API1</b>.
Regards,
Phani.
Message was edited by:
Sivapuram Phani Kumar
04-18-2007 1:48 PM
Used FM <b>SO_OBJECT_SEND</b> and the problem is solved.
Regards,
Phani.