12-24-2015 9:54 AM
hi,
My code is as below.
* Code for processing Email
LOOP AT gt_final INTO gw_final.
gv_str1 = gw_final-rate_type.
gv_str2 = gw_final-from_curr.
gv_str3 = gw_final-to_currncy.
gv_str4 = gw_final-exch_rate.
gv_str5 = gw_final-valid_from.
gv_str6 = gw_final-from_factor.
gv_str7 = gw_final-to_factor.
CONCATENATE gv_str1 gv_str2 gv_str3 gv_str4 gv_str5 gv_str6 gv_str7
INTO gw_objbin_final SEPARATED BY ','.
CONDENSE gw_objbin_final.
APPEND gw_objbin_final TO gt_objbin_final.
CLEAR: gv_str1, gv_str2, gv_str3, gv_str3, gv_str4, gv_str5, gv_str6,gw_objbin_final.
ENDLOOP.
LOOP AT gt_return INTO gw_return.
gv_str1 = gw_return-type.
gv_str2 = gw_return-message.
CONCATENATE gv_str1 gv_str2
INTO gw_objbin_final SEPARATED BY '-'.
CONDENSE gw_objbin_final.
APPEND gw_objbin_final TO gt_objbin_final.
CLEAR: gv_str1, gv_str2,gw_objbin_final.
ENDLOOP.
*Body of the mail
docdata-obj_name = 'Forex exchange rate upload'.
docdata-obj_descr = 'Please go through attached files'.
gw_objtxt = 'Please go through attached files'.
APPEND gw_objtxt TO gt_objtxt.
CLEAR gw_objtxt.
DESCRIBE TABLE gt_objtxt LINES tab_lines.
READ TABLE gt_objtxt INTO gw_objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( gw_objtxt ).
CLEAR gw_objpack-transf_bin.
gw_objpack-head_start = 1.
gw_objpack-head_num = 0.
gw_objpack-body_start = 1.
gw_objpack-body_num = tab_lines.
gw_objpack-doc_type = 'RAW'.
APPEND gw_objpack TO gt_objpack.
*First Attachment
* CLEAR tab_lines.
n = 1.
DESCRIBE TABLE gt_final LINES tab_lines.
gw_objpack-doc_size = tab_lines * 255.
gw_objpack-transf_bin = 'X'.
gw_objpack-head_start = 1.
gw_objpack-head_num = 0.
gw_objpack-body_start = n.
gw_objpack-body_num = tab_lines.
gw_objpack-doc_type = 'XLS'.
docdata-obj_name = 'Excel_File_Attachment1'.
gw_objpack-obj_descr = 'Input Forex exhchange rate File'.
APPEND gw_objpack TO gt_objpack.
* n = n + tab_lines.
* Second attachment
* CLEAR tab_lines.
n = n + tab_lines.
DESCRIBE TABLE gt_return LINES tab_lines.
gw_objpack-doc_size = tab_lines * 255.
gw_objpack-transf_bin = 'X'.
gw_objpack-head_start = 1.
gw_objpack-head_num = 0.
gw_objpack-body_start = n.
gw_objpack-body_num = tab_lines.
gw_objpack-doc_type = 'XLS'.
docdata-obj_name = 'Excel_File_Attachment1'.
gw_objpack-obj_descr = 'Messages file'.
APPEND gw_objpack TO gt_objpack.
* n = n + tab_lines.
* Append receivers mail addresses on this location
gw_reclist-receiver = 'firstname.lastname@domain.com'. "e_mail address
gw_reclist-rec_type = 'U'.
gw_reclist-express = 'X'.
APPEND gw_reclist TO gt_reclist.
gw_reclist-receiver = 'othername.someoneelse@domain.com. "e_mail address
gw_reclist-rec_type = 'U'.
gw_reclist-express = 'X'.
APPEND gw_reclist TO gt_reclist.
* FM for sending an email.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' " Obsolete function module; use CL_BCS classes instead.
EXPORTING
document_data = docdata
* PUT_IN_OUTBOX = ' '
commit_work = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = gt_objpack
* OBJECT_HEADER =
contents_bin = binary_content "gt_objbin_final
contents_txt = gt_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = gt_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.
* Implement suitable error handling here
ENDIF.
In Excel file data records getting displayed in one row not in column..
Please help.
darshan.
Message was edited by: Matthew Billingham - Anonymised email addresses.
12-24-2015 10:03 AM
12-24-2015 10:03 AM
12-24-2015 10:11 AM
HI Eitan,
thanks for replying.
Please guide,
how should i add newline at end of each line.
Thanks,
darshan
12-24-2015 10:12 AM
12-24-2015 10:23 AM
CONCATENATE long_text line cl_abap_char_utilities=>newline INTO long_text .
12-24-2015 10:23 AM
12-24-2015 10:46 AM
12-24-2015 10:55 AM
Moderator message The function module for sending emails is obsolete. There are also a number of problems with it. Instead you should use the CL_BCS suite of classes, which are much more flexible and easy to use.