10-10-2007 3:49 PM
Hello All,
I am using the function module SO_DOCUMENT_SEND_API1 to send an e-mail with an excel attachment.
The code works fine for less than 255 characters in each row of excel file.But for more than 255 characters , the excel file received has data upto 255 characters only.
Can someone please suggest how to send excel file with more than 255 characters in each row ?
Regards,
KK
10-10-2007 3:57 PM
if u downaload directly to the excel sheet , it wont take more thatn 255. so better to try this
get all the data into one internal table and pass this internal table to the excel.
Thanks
null
10-10-2007 4:00 PM
Hi,
Please check the link.
<a href="http://www.sapdev.co.uk/reporting/email/attachhome.htm">http://www.sapdev.co.uk/reporting/email/attachhome.htm</a>
10-11-2007 5:15 AM
Hi Sriram,
I have created my program on grounds of the program mentioned in this link only.
But it is not working for more than 255 characters.
Any suggestion?
Thanks!
10-10-2007 4:12 PM
check below code
FORM excelrep .
DATA :l_syuzeit TYPE sy-uzeit,
l_time(5) TYPE c,
l_ampm(2) TYPE c,
l_subject(255) TYPE c.
CLEAR t_xls.
REFRESH t_xls.
l_syuzeit = sy-uzeit.
IF t_final_data1[] IS NOT INITIAL.
PERFORM fill_header.
LOOP AT t_final_data1 WHERE status NE space.
t_xls-jobname = t_final_data1-jobname.
WRITE t_final_data1-act_start_date TO t_xls-act_start_date.
WRITE t_final_data1-est_start_time TO t_xls-est_start_time.
WRITE t_final_data1-act_start_time TO t_xls-act_start_time.
WRITE t_final_data1-est_end_time TO t_xls-est_end_time.
WRITE t_final_data1-act_end_time TO t_xls-act_end_time.
t_xls-est_duration = t_final_data1-est_duration.
t_xls-act_duration = t_final_data1-duration.
t_xls-status = t_final_data1-comment.
t_xls-process = t_final_data1-desc.
t_xls-fill10 = c_0d.
t_xls-fill1 = c_09.
t_xls-fill2 = c_09.
t_xls-fill3 = c_09.
t_xls-fill4 = c_09.
t_xls-fill5 = c_09.
t_xls-fill6 = c_09.
t_xls-fill7 = c_09.
t_xls-fill8 = c_09.
t_xls-fill9 = c_09.
APPEND t_xls.
CLEAR t_xls.
ENDLOOP.
l_ampm = c_am.
IF l_syuzeit GT c_125959.
l_syuzeit = l_syuzeit - c_120000.
l_ampm = c_pm.
ELSEIF l_syuzeit GT c_120000.
l_ampm = c_pm.
ELSEIF l_syuzeit LT c_010000.
l_syuzeit = l_syuzeit + c_120000.
l_ampm = c_am.
ENDIF.
WRITE l_syuzeit TO l_time USING EDIT MASK c_edmask.
CONCATENATE text-070 l_time l_ampm INTO l_subject
SEPARATED BY space.
CLEAR w_doc_chng.
w_doc_chng-obj_name = l_subject.
w_doc_chng-obj_descr = l_subject.
CLEAR t_objtxt.
REFRESH t_objtxt.
t_objtxt = text-068.
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = space.
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = text-069.
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = space.
APPEND t_objtxt.
CLEAR t_objtxt.
MOVE w_sysinfo TO t_objtxt.
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = space.
APPEND t_objtxt.
CLEAR t_objtxt.
CLEAR w_tab_lines.
DESCRIBE TABLE t_objtxt LINES w_tab_lines.
w_doc_chng-doc_size = w_tab_lines * c_255.
CLEAR t_objpack.
REFRESH t_objpack.
t_objpack-body_start = c_1.
t_objpack-body_num = w_tab_lines * c_255.
t_objpack-doc_type = c_txt.
APPEND t_objpack.
CLEAR t_objpack.
CLEAR t_objbin.
REFRESH t_objbin.
LOOP AT t_xls.
t_objbin = t_xls.
APPEND t_objbin.
CLEAR t_objbin.
ENDLOOP.
CLEAR w_tab_lines.
DESCRIBE TABLE t_objbin LINES w_tab_lines.
CLEAR l_subject.
CONCATENATE text-083 sy-datum l_time l_ampm INTO l_subject
SEPARATED BY c_uscore.
CLEAR t_objhead.
REFRESH t_objhead.
t_objhead = l_subject.
APPEND t_objhead.
CLEAR t_objhead.
t_objpack-transf_bin = c_x.
t_objpack-head_start = c_1.
t_objpack-head_num = c_1.
t_objpack-body_start = c_1.
t_objpack-body_num = w_tab_lines.
t_objpack-doc_type = c_xls.
t_objpack-obj_name = text-070.
t_objpack-obj_descr = text-070.
t_objpack-doc_size = w_tab_lines * c_255.
t_objpack-mess_type = space.
APPEND t_objpack.
CLEAR t_objpack.
CLEAR t_reclist.
REFRESH t_reclist.
IF s_email[] IS NOT INITIAL.
LOOP AT s_email.
t_reclist-receiver = s_email-low.
t_reclist-rec_type = c_u.
APPEND t_reclist.
CLEAR t_reclist.
ENDLOOP.
ENDIF.
PERFORM mail_report.
ELSE.
MESSAGE e015 WITH text-072.
ENDIF.
CLEAR : w_doc_chng,
t_objpack,
t_objhead,
t_objbin,
t_objtxt.
REFRESH : t_objpack,
t_objhead,
t_objbin,
t_objtxt,
t_reclist.
ENDFORM. " excelrep_criticaljobs
&----
*& Form mail_report
&----
text
----
--> p1 text
<-- p2 text
----
FORM mail_report .
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
commit_work = c_x
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
receivers = t_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 NE 0.
CASE sy-subrc.
WHEN 1.
MESSAGE i015 WITH text-071.
WHEN 2.
MESSAGE i015 WITH text-072.
WHEN 4.
MESSAGE i015 WITH text-073.
WHEN OTHERS.
MESSAGE i015 WITH text-074.
ENDCASE.
ELSE.
MESSAGE s015 WITH text-081.
ENDIF.
ENDFORM. " mail_report
10-11-2007 5:10 AM
Hi,
I am using a similar code.But the probelm is that the table CONTENTS_BIN to which internal table with attachment data is passed has a line type of 255 characters only.
So it is working for only 255 characters.
Changing the type of this table by creating a custom module is also not working.
Any suggestions?
thanks
kk
10-10-2007 4:20 PM
hi
good
REPORT ZSEND .
TABLES: KNA1.
data for send function
DATA DOC_DATA LIKE SODOCCHGI1.
DATA OBJECT_ID LIKE SOODK.
DATA OBJCONT LIKE SOLI OCCURS 10 WITH HEADER LINE.
DATA RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.
SELECT * FROM KNA1 WHERE ANRED LIKE 'C%'.
WRITE:/ KNA1-KUNNR, KNA1-ANRED.
send data internal table
CONCATENATE KNA1-KUNNR KNA1-ANRED
INTO OBJCONT-LINE SEPARATED BY SPACE.
APPEND OBJCONT.
ENDSELECT.
insert receiver (sap name)
REFRESH RECEIVER.
CLEAR RECEIVER.
MOVE: SY-UNAME TO RECEIVER-RECEIVER,
'X' TO RECEIVER-EXPRESS,
'B' TO RECEIVER-REC_TYPE.
APPEND RECEIVER.
insert mail description
WRITE 'Sending a mail through abap'
TO DOC_DATA-OBJ_DESCR.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_DATA
IMPORTING
NEW_OBJECT_ID = OBJECT_ID
TABLES
OBJECT_CONTENT = OBJCONT
RECEIVERS = RECEIVER
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.
<b><REMOVED BY MODERATOR></b>
thanks
mrutyun^
Message was edited by:
Alvaro Tejada Galindo