Send mail of excel file on pc
Hello gurus,
I have a requirement,
I have an excel file on presentation server.
which i have to download send to mail id.
I now how to build and send an excel file programaticlly.
but i want that excel file should be with multiple sheets thats why iam asking for download(like gui_download) and attach it ti mail id.
please replay early.
regards,
padamaja
hello gurus,
I am able to create excel file using abap code and now my problem is for two columns i want to provide the same heading ,
like.
column1 column2
**personal details*(heading)
ram ap
raj ap
that heading i want to provide for both the columns.
kindly provide the solution ..
regards,
padmaja.
Similar Messages
-
Sending mail with excel attachment-improper format
Dear experts,
I am sending a mail to outlook with an excel attachment. The mail is sent with attachment and the data, but all in one cell.
I am using SO_NEW_DOCUMENT_ATT_SEND_API1. What parameters do i need to manipulate to have data in different columns of excel? I am using "packing_list" table of FM. But dont know the exact parameters to be passed. Can anyone help with the same please?
Best regards and thanks!
Sumit Nene.Hello Sumit,
I am using same function module to send mail with excel attachment.
Below I am attaching my own code for your reference.
Data which u want to add in excel file is maintain in IT_OBJBIN i.e. document information.
CLEAR :IMESSAGE,IT_OBJBIN,IT_OBJPACK,IT_RECLIST.
REFRESH: IMESSAGE[ ] , IT_OBJBIN[ ] , IT_OBJPACK[ ] , IT_RECLIST[ ].
" populate the text for body of the mail
CLEAR WA_IMESSAGE.
CONCATENATE 'Board : ' P_BOARD ':' 'Please find the excel attached for the list of Material whose routing is created' INTO WA_IMESSAGE-LINE.
APPEND WA_IMESSAGE TO IMESSAGE.
"document information
W_DOC_CHNG-OBJ_NAME = 'Excel'.
IF NOT P_BOARD IS INITIAL.
CONCATENATE 'Board : ' P_BOARD ':' 'List Of Routing Materials' INTO W_DOC_CHNG-OBJ_DESCR.
ELSE.
CONCATENATE 'List Of' ' Routing Materials' INTO W_DOC_CHNG-OBJ_DESCR.
ENDIF.
W_DOC_CHNG-SENSITIVTY = 'F'. " ->Functional object
" displaying material , plant in the excel
CONCATENATE 'BOARD NO : ' P_BOARD INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
CONCATENATE 'MATERIAL' 'PLANT' 'DESCRIPTION' INTO WA_OBJBIN SEPARATED BY C_TAB.
CONCATENATE C_RET WA_OBJBIN INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
CLEAR : WA_OBJBIN.
LOOP AT IT_DOWNLOAD INTO WA_DOWNLOAD. "It_orders is the internal table to be transferred to excel
CONCATENATE WA_DOWNLOAD-MATNR WA_DOWNLOAD-WERKS WA_DOWNLOAD-DESC INTO WA_OBJBIN SEPARATED BY C_TAB.
CONCATENATE C_RET WA_OBJBIN INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
ENDLOOP.
DESCRIBE TABLE IT_OBJBIN LINES V_LINES_BIN. " no of lines for excel data
" pack the data as RAW
CLEAR WA_IT_OBJPACK-TRANSF_BIN. "Obj. to be transported not in binary form
WA_IT_OBJPACK-HEAD_START = 1. "Start line of object header in transport packet
WA_IT_OBJPACK-HEAD_NUM = 0. "Number of lines of an object header in object packet
WA_IT_OBJPACK-BODY_START = 1. "Start line of object contents in an object packet
WA_IT_OBJPACK-BODY_NUM = MESSAGE_LINES. "Number of lines of the mail body
WA_IT_OBJPACK-DOC_TYPE = 'RAW'.
APPEND WA_IT_OBJPACK TO IT_OBJPACK.
" pack the data as excel
WA_IT_OBJPACK-TRANSF_BIN = 'X'.
WA_IT_OBJPACK-HEAD_START = 1.
WA_IT_OBJPACK-HEAD_NUM = 1.
WA_IT_OBJPACK-BODY_START = 1.
WA_IT_OBJPACK-BODY_NUM = V_LINES_BIN. "no of lines of it_orders to give no of unprocessed orders
WA_IT_OBJPACK-DOC_TYPE = 'XLS'. " -> excel fomat
WA_IT_OBJPACK-OBJ_NAME = 'EXCEL ATTACHMENT'.
" attachment name
IF NOT P_BOARD IS INITIAL.
CONCATENATE P_BOARD '.XLS' INTO WA_IT_OBJPACK-OBJ_DESCR.
ELSE.
CONCATENATE 'LIST' '.XLS' INTO WA_IT_OBJPACK-OBJ_DESCR.
ENDIF.
WA_IT_OBJPACK-DOC_SIZE = V_LINES_BIN * 255.
APPEND WA_IT_OBJPACK TO IT_OBJPACK.
" creating email id
DATA: STR1 TYPE STRING,
STR2 TYPE STRING,
STR3 TYPE STRING,
ITAB TYPE TABLE OF STRING.
DATA : WA_I LIKE LINE OF ITAB.
SPLIT P_EMAIL AT ',' INTO: TABLE ITAB.
e-mail receivers.
CLEAR WA_IT_RECLIST.
LOOP AT ITAB INTO WA_I.
WA_IT_RECLIST-RECEIVER = WA_I.
WA_IT_RECLIST-RECEIVER = V_MAILADDR.
WA_IT_RECLIST-EXPRESS = 'X'.
WA_IT_RECLIST-REC_TYPE = 'U'. "-> Internet address
APPEND WA_IT_RECLIST TO IT_RECLIST.
CLEAR WA_IT_RECLIST.
ENDLOOP.
" sending mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = IT_OBJPACK
OBJECT_HEADER =
CONTENTS_BIN = IT_OBJBIN
CONTENTS_TXT = IMESSAGE
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = IT_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
COMMIT WORK.
IF SY-SUBRC = 0.
MESSAGE I001 WITH 'Routing is Created for Board' P_BOARD 'and Mail send on e-mail id :' P_EMAIL.
ENDIF. -
FM to mail a excel file generated by XML
Hi All,
I have a requirement to generate fancy excel file as attachment in mail.
Please help with some FM to send mail with excel as attachment,
I have used a code like the sample code given below.
*&----
**& Report ZTEST_NP_EXCEL_XML
**&
**& Download the formatted excel file using XML
*&----
report Z_IXML.
TABLES USR02.
TYPES XMLLINE(1024) TYPE C.
DATA IT_XML TYPE XMLLINE OCCURS 0.
DATA WA_XML TYPE XMLLINE.
DATA FNAME(60) TYPE C VALUE '/ft/D02/001/test.xls'.
\ Build-up of xml in internal table
\\* Opening tags
APPEND '<?xml version="1.0"?>' TO IT_XML.
APPEND '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"'
TO IT_XML.
APPEND 'xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
TO IT_XML.
APPEND ' <Worksheet ss:Name="Tabelle1">' TO IT_XML.
APPEND ' <Table>' TO IT_XML.
\\* The actual data from table USR02
SELECT * FROM USR02.
APPEND ' <Row>' TO IT_XML.
CONCATENATE ' <Cell><Data ss:Type="String">'
USR02-BNAME '</Data></Cell>' INTO WA_XML.
APPEND WA_XML TO IT_XML.
CONCATENATE ' <Cell><Data ss:Type="String">'
USR02-TRDAT '</Data></Cell>' INTO WA_XML.
APPEND WA_XML TO IT_XML.
APPEND ' </Row>' TO IT_XML.
ENDSELECT.
\*Closing tags
APPEND ' </Table>' TO IT_XML.
APPEND ' </Worksheet>' TO IT_XML.
APPEND '</Workbook>' TO IT_XML.
DATA: window_title TYPE string,
fullpath TYPE string,
path TYPE string,
user_action TYPE i,
default_extension TYPE string,
default_file_name TYPE string,
file_filter TYPE string,
filename TYPE string,
initialpath TYPE string.
File selection
MOVE '.XLS' TO default_extension.
MOVE 'XLS files (.XLS)|.XLS' TO file_filter.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = default_extension
default_file_name = default_file_name
file_filter = file_filter
initial_directory = initialpath
CHANGING
filename = filename
path = path
fullpath = fullpath
user_action = user_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = fullpath
filetype = 'ASC'
TABLES
data_tab = it_xml
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Please help
I am giving a sample code howHi Supratik,
Please refer to these two links:
Send email with 1 excel file and multiple sheet
How to Convert file to excel and send it via email
Hope this will resolve your issue. -
Send mails with csv file as an attachment through oracle(SQL SCripts / Stor
Hello Everybody,
I have recently come across a requirement in which I am supposed to send mails with csv file as an attachment through oracle(SQL SCripts / Stored Procedure) .
The contents of the csv file are to be retreived from the Database as well as the content of the mail and to whom it needs to be sent has also to be picked up from the database.
Can somebody suggest me with a suitable code for the same?
Would be of great help..!!
Thanks & Regards,
- VR
Edited by: user646716 on Dec 18, 2009 10:44 AMread below links
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:255615160805
http://www.orafaq.com/wiki/Send_mail_from_PL/SQL#Send_mail_with_UTL_TCP_-withattachments
How to send csv file as an attachment -
Convert Screen(spool) to PDF file sending mail with attach file
Hi :
I'd like convert spool list to pdf and sending file...
so, I read thread about spool convert to PDF before,
and know how to convert Spool to PDF file and send mail with attach file.
but I have a problem.
my solution as:
step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
I want to showing word is wider that 255.
and then I find a manual method as:
After program finished.
Function Menu -> system -> List -> Send
use Prog: "Create Document and Send"
I use this prog sending mail and attached file ,
PDF file do <b>NOT</b> have 255 word limit !
finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
which Function I have to use?...
Please help me, Thanks!Hi,
Check this sample code of sending spool as attachment to an email address..
Parameters.
PARAMETERS: p_email(50) LOWER CASE.
PARAMETERS: p_spool LIKE tsp01-rqident.
Data declarations.
DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: document_data LIKE sodocchgi1.
DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA: real_type LIKE soodk-objtp.
DATA: sp_lang LIKE tst01-dlang.
DATA: line_size TYPE i VALUE 255.
DATA: v_name LIKE soextreci1-receiver.
DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
Get the spool data.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = p_spool
first_line = 1
last_line = 0
desired_type = ' '
IMPORTING
real_type = real_type
sp_lang = sp_lang
TABLES
buffer = so_ali
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error'.
LEAVE LIST-PROCESSING.
ENDIF.
Prepare the data.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 0.
plist-body_num = 0.
plist-doc_type = 'RAW'.
plist-obj_descr = 'Test ALV'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
DESCRIBE TABLE so_ali LINES plist-body_num.
plist-doc_type = real_type.
Get the size.
READ TABLE so_ali INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( so_ali ).
APPEND plist.
Move the receiver address.
MOVE: p_email TO rec_tab-receiver,
'U' TO rec_tab-rec_type.
APPEND rec_tab.
IF NOT sp_lang IS INITIAL.
document_data-obj_langu = sp_lang.
ELSE.
document_data-obj_langu = sy-langu.
ENDIF.
v_name = sy-uname.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'B'
TABLES
packing_list = plist
contents_bin = so_ali
receivers = rec_tab
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 e208(00) WITH 'Error'.
ENDIF.
COMMIT WORK.
Send the email immediately.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
Thanks,
Naren -
Sending mail without attachment file
Hi Sapfans:
I would like to send mail without attachment file, just a notice,
needing multiple receiver, can change the mail title,
Which function shoud I use?
I just found out sending mail with attachment file there,
Thanks a lot!Hi Alchie,
Please take a look at my example below. It sens e-mail to multiple recipients without attachments.
FUNCTION-POOL zts0001 MESSAGE-ID sv.
INCLUDE lsvimdat . "general data decl.
INCLUDE lzts0001t00 . "view rel. data dcl.
*/ Author: Aris Hidalgo
*/ Created on: September 7, 2006
*/ Purpose of program: This will send out e-mails to specified users in
*/ custom table ZSHIPTO_EMAIL whenever records have been deleted or
*/ modified via the maintenance view of ZTS0001. The changes will also
*/ be reflected in custom table ZTS_STPGEOLOC.
TABLES: zts_stpgeoloc,
zshipto_email,
kna1.
FIELD-SYMBOLS: <fs_old_total> TYPE ANY.
* CLASS lcl_main DEFINITION ABSTRACT
CLASS lcl_main DEFINITION ABSTRACT.
PUBLIC SECTION.
TYPES: BEGIN OF t_zts0001_old,
kunnr TYPE zts0001-kunnr,
cdseq TYPE zts0001-cdseq,
zaddress TYPE zts0001-zaddress,
zcperson TYPE zts0001-zcperson,
zcnumber TYPE zts0001-zcnumber,
END OF t_zts0001_old.
TYPES: BEGIN OF t_zts0001_new,
kunnr TYPE zts0001-kunnr,
cdseq TYPE zts0001-cdseq,
zaddress TYPE zts0001-zaddress,
zcperson TYPE zts0001-zcperson,
zcnumber TYPE zts0001-zcnumber,
END OF t_zts0001_new.
TYPES: BEGIN OF t_zts_stpgeoloc,
kunnr TYPE zts_stpgeoloc-kunnr,
cdseq TYPE zts_stpgeoloc-cdseq,
zaddress TYPE zts_stpgeoloc-zaddress,
zcperson TYPE zts_stpgeoloc-zcperson,
zcnumber TYPE zts_stpgeoloc-zcnumber,
END OF t_zts_stpgeoloc.
TYPES: BEGIN OF t_del_entries,
kunnr TYPE zts0001-kunnr,
cdseq TYPE zts0001-cdseq,
zaddress TYPE zts0001-zaddress,
zcperson TYPE zts0001-zcperson,
zcnumber TYPE zts0001-zcnumber,
name1 TYPE kna1-name1,
END OF t_del_entries.
TYPES: BEGIN OF t_modified_entries,
kunnr TYPE zts0001-kunnr,
cdseq TYPE zts0001-cdseq,
old_address TYPE zts0001-zaddress,
new_address TYPE zts0001-zaddress,
old_person TYPE zts0001-zcperson,
new_person TYPE zts0001-zcperson,
old_number TYPE zts0001-zcnumber,
new_number TYPE zts0001-zcnumber,
name1 TYPE kna1-name1,
END OF t_modified_entries.
DATA: gt_zts0001_old TYPE STANDARD TABLE OF t_zts0001_old,
gt_zts0001_new TYPE HASHED TABLE OF t_zts0001_new
WITH UNIQUE KEY kunnr cdseq,
gt_zts_stpgeoloc TYPE STANDARD TABLE OF t_zts_stpgeoloc,
gt_del_entries TYPE STANDARD TABLE OF t_del_entries,
gt_modified_entries TYPE STANDARD TABLE OF t_modified_entries,
gt_zshipto_email TYPE STANDARD TABLE OF zshipto_email,
t_maildata TYPE sodocchgi1,
gt_mailtxt TYPE STANDARD TABLE OF solisti1,
gt_mailrec TYPE STANDARD TABLE OF somlreci1.
DATA: v_old_total TYPE i,
v_new_total TYPE i,
v_flag(1) TYPE c,
v_counter(1) TYPE c,
v_contents(255) TYPE c.
ENDCLASS.
* CLASS lcl_get_old_recs DEFINITION
CLASS lcl_get_old_recs DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: export_old_recs.
ENDCLASS.
* CLASS lcl_get_old_recs IMPLEMENTATION
CLASS lcl_get_old_recs IMPLEMENTATION.
METHOD export_old_recs.
SELECT kunnr cdseq zaddress zcperson zcnumber
FROM zts0001
INTO TABLE gt_zts0001_old.
v_old_total = sy-dbcnt.
ASSIGN v_old_total TO <fs_old_total>.
EXPORT gt_zts0001_old = gt_zts0001_old TO MEMORY ID 'AVH'.
CLEAR gt_zts0001_old. REFRESH gt_zts0001_old.
ENDMETHOD.
ENDCLASS.
* CLASS lcl_old_and_new DEFINITION
CLASS lcl_old_and_new DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: compare_old_and_new.
ENDCLASS.
* CLASS lcl_old_and_new IMPLEMENTATION
CLASS lcl_old_and_new IMPLEMENTATION.
METHOD compare_old_and_new.
DATA: wa_del_entries LIKE LINE OF gt_del_entries.
FIELD-SYMBOLS: <fs_old> LIKE LINE OF gt_zts0001_old,
<fs_new> LIKE LINE OF gt_zts0001_new.
SELECT kunnr cdseq zaddress zcperson zcnumber
FROM zts0001
INTO TABLE gt_zts0001_new.
v_new_total = sy-dbcnt.
IF v_new_total <> <fs_old_total>.
IMPORT gt_zts0001_old = gt_zts0001_old FROM MEMORY ID 'AVH'.
LOOP AT gt_zts0001_old ASSIGNING <fs_old>.
READ TABLE gt_zts0001_new WITH TABLE KEY kunnr = <fs_old>-kunnr
cdseq = <fs_old>-cdseq
ASSIGNING <fs_new>.
IF sy-subrc <> 0.
MOVE-CORRESPONDING <fs_old> TO wa_del_entries.
APPEND wa_del_entries TO gt_del_entries.
CLEAR wa_del_entries.
DELETE FROM zts_stpgeoloc
WHERE kunnr = <fs_old>-kunnr
AND cdseq = <fs_old>-cdseq.
ENDIF.
ENDLOOP.
IF NOT gt_del_entries[] IS INITIAL.
EXPORT gt_del_entries = gt_del_entries TO MEMORY ID 'DEL'.
ENDIF.
REFRESH gt_zts0001_old.
ENDIF.
ENDMETHOD.
ENDCLASS.
* CLASS lcl_check_changes DEFINITION
CLASS lcl_check_changes DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: check_for_changes.
ENDCLASS.
* CLASS lcl_check_changes IMPLEMENTATION
CLASS lcl_check_changes IMPLEMENTATION.
METHOD check_for_changes.
TYPES: BEGIN OF t_zts_stpgeoloc,
mandt TYPE zts_stpgeoloc-mandt,
kunnr TYPE zts_stpgeoloc-kunnr,
cdseq TYPE zts_stpgeoloc-cdseq,
zcgeoloc TYPE zts_stpgeoloc-zcgeoloc,
zaddress TYPE zts_stpgeoloc-zaddress,
zcperson TYPE zts_stpgeoloc-zcperson,
zcnumber TYPE zts_stpgeoloc-zcnumber,
END OF t_zts_stpgeoloc.
DATA: wa_modified_entries LIKE LINE OF gt_modified_entries,
lt_zts_stpgeoloc TYPE HASHED TABLE OF t_zts_stpgeoloc
WITH UNIQUE KEY kunnr cdseq,
wa_zts_stpgeoloc LIKE LINE OF lt_zts_stpgeoloc.
FIELD-SYMBOLS: <fs_zts0001_old> LIKE LINE OF gt_zts0001_old,
<fs_zts0001_new> LIKE LINE OF gt_zts0001_new.
IMPORT gt_zts0001_old = gt_zts0001_old FROM MEMORY ID 'AVH'.
SELECT kunnr cdseq zcgeoloc zaddress zcperson zcnumber
FROM zts_stpgeoloc
INTO CORRESPONDING FIELDS OF TABLE lt_zts_stpgeoloc.
SELECT kunnr cdseq zaddress zcperson zcnumber
FROM zts0001
INTO TABLE gt_zts0001_new.
LOOP AT gt_zts0001_old ASSIGNING <fs_zts0001_old>.
READ TABLE gt_zts0001_new WITH TABLE KEY
kunnr = <fs_zts0001_old>-kunnr
cdseq = <fs_zts0001_old>-cdseq
ASSIGNING <fs_zts0001_new>.
IF sy-subrc = 0.
READ TABLE lt_zts_stpgeoloc WITH TABLE KEY
kunnr = <fs_zts0001_new>-kunnr
cdseq = <fs_zts0001_new>-cdseq
INTO wa_zts_stpgeoloc.
IF sy-subrc = 0.
wa_zts_stpgeoloc-mandt = sy-mandt.
wa_zts_stpgeoloc-kunnr = <fs_zts0001_new>-kunnr.
wa_zts_stpgeoloc-cdseq = <fs_zts0001_new>-cdseq.
wa_zts_stpgeoloc-zcgeoloc = space.
wa_zts_stpgeoloc-zaddress = <fs_zts0001_new>-zaddress.
wa_zts_stpgeoloc-zcperson = <fs_zts0001_new>-zcperson.
wa_zts_stpgeoloc-zcnumber = <fs_zts0001_new>-zcnumber.
MODIFY zts_stpgeoloc FROM wa_zts_stpgeoloc.
COMMIT WORK AND WAIT.
ENDIF.
* address
IF <fs_zts0001_old>-zaddress <> <fs_zts0001_new>-zaddress.
MOVE: <fs_zts0001_new>-kunnr TO wa_modified_entries-kunnr,
<fs_zts0001_new>-cdseq TO wa_modified_entries-cdseq,
<fs_zts0001_old>-zaddress TO wa_modified_entries-old_address,
<fs_zts0001_new>-zaddress TO wa_modified_entries-new_address.
v_flag = 1.
ENDIF.
* person
IF <fs_zts0001_old>-zcperson <> <fs_zts0001_new>-zcperson.
MOVE: <fs_zts0001_new>-kunnr TO wa_modified_entries-kunnr,
<fs_zts0001_new>-cdseq TO wa_modified_entries-cdseq,
<fs_zts0001_old>-zcperson TO wa_modified_entries-old_person,
<fs_zts0001_new>-zcperson TO wa_modified_entries-new_person.
v_flag = 1.
ENDIF.
* number
IF <fs_zts0001_old>-zcnumber <> <fs_zts0001_new>-zcnumber.
MOVE: <fs_zts0001_new>-kunnr TO wa_modified_entries-kunnr,
<fs_zts0001_new>-cdseq TO wa_modified_entries-cdseq,
<fs_zts0001_old>-zcnumber TO wa_modified_entries-old_number,
<fs_zts0001_new>-zcnumber TO wa_modified_entries-new_number.
v_flag = 1.
ENDIF.
ENDIF.
IF v_flag = 1.
APPEND wa_modified_entries TO gt_modified_entries.
CLEAR wa_modified_entries.
ENDIF.
* update ZTS_STPGEOLOC based from the modified records in ZTS0001
IF v_flag = 1.
CLEAR v_flag.
UPDATE zts_stpgeoloc SET zaddress = <fs_zts0001_new>-zaddress
zcperson = <fs_zts0001_new>-zcperson
zcnumber = <fs_zts0001_new>-zcnumber
WHERE kunnr = <fs_zts0001_new>-kunnr
AND cdseq = <fs_zts0001_new>-cdseq.
ENDIF.
ENDLOOP.
IF NOT gt_modified_entries[] IS INITIAL.
EXPORT gt_modified_entries = gt_modified_entries TO MEMORY ID 'MOD'
ENDIF.
ENDMETHOD.
ENDCLASS.
* CLASS lcl_messages DEFINITION
CLASS lcl_messages DEFINITION INHERITING FROM lcl_main.
PUBLIC SECTION.
METHODS: create_message.
ENDCLASS.
* CLASS lcl_messages IMPLEMENTATION
CLASS lcl_messages IMPLEMENTATION.
METHOD create_message.
FIELD-SYMBOLS: <fs_email> LIKE LINE OF gt_zshipto_email,
<fs_del> LIKE LINE OF gt_del_entries,
<fs_mod> LIKE LINE OF gt_modified_entries.
DATA: wa_mailtxt LIKE LINE OF gt_mailtxt,
wa_mailrec LIKE LINE OF gt_mailrec.
IMPORT gt_modified_entries = gt_modified_entries
FROM MEMORY ID 'MOD'.
IMPORT gt_del_entries = gt_del_entries FROM MEMORY ID 'DEL'.
SELECT * FROM zshipto_email INTO TABLE gt_zshipto_email
WHERE zevent = '2'.
IF sy-dbcnt > 0.
*/ routine for records that were deleted
IF NOT gt_del_entries[] IS INITIAL.
t_maildata-obj_name = 'Record Deleted in table ZTS0001'.
t_maildata-obj_descr = 'Record Deleted in table ZTS0001'.
t_maildata-obj_langu = sy-langu.
CLEAR: v_flag, v_counter.
LOOP AT gt_zshipto_email ASSIGNING <fs_email>.
LOOP AT gt_del_entries ASSIGNING <fs_del>.
* get name of dealer
SELECT SINGLE name1 FROM kna1
INTO <fs_del>-name1
WHERE kunnr = <fs_del>-kunnr.
IF v_counter IS INITIAL.
CONCATENATE: 'FYI: The ff record/s were deleted in tables'
'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
ENDIF.
APPEND wa_mailtxt TO gt_mailtxt. "Extra space for message
CONCATENATE: 'Dealer :' <fs_del>-kunnr '-'
<fs_del>-name1
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Ship-To:' <fs_del>-cdseq
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Address:' <fs_del>-zaddress
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Contact person:' <fs_del>-zcperson
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Contact number:' <fs_del>-zcnumber
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
v_counter = 1.
ENDLOOP.
wa_mailrec-receiver = <fs_email>-zemail.
wa_mailrec-rec_type = 'U'.
APPEND wa_mailrec TO gt_mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = t_maildata
document_type = 'RAW'
put_in_outbox = 'X'
* commit_work = 'X'
TABLES
* object_header = mailtxt
object_content = gt_mailtxt
receivers = gt_mailrec
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 sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR: wa_mailtxt, wa_mailrec.
REFRESH: gt_mailtxt, gt_mailrec.
ENDLOOP.
ENDIF.
CLEAR wa_mailtxt.
REFRESH gt_mailtxt.
*/ routine for records that were modified
IF NOT gt_modified_entries[] IS INITIAL.
CLEAR t_maildata.
t_maildata-obj_name = 'Record changed in table ZTS0001'.
t_maildata-obj_descr = 'Record changed in table ZTS0001'.
t_maildata-obj_langu = sy-langu.
CLEAR v_counter.
LOOP AT gt_zshipto_email ASSIGNING <fs_email>.
CONCATENATE: 'FYI: The ff records were changed in tables'
'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
LOOP AT gt_modified_entries ASSIGNING <fs_mod>.
* get name of dealer
SELECT SINGLE name1 FROM kna1
INTO <fs_mod>-name1
WHERE kunnr = <fs_mod>-kunnr.
APPEND wa_mailtxt TO gt_mailtxt.
CONCATENATE: 'Dealer :' <fs_mod>-kunnr '-'
<fs_mod>-name1
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Ship-To:' <fs_mod>-cdseq
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
* address
IF NOT <fs_mod>-old_address IS INITIAL AND
NOT <fs_mod>-new_address IS INITIAL.
CONCATENATE: 'Address from:' <fs_mod>-old_address
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Address to :' <fs_mod>-new_address
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
ENDIF.
* person
IF NOT <fs_mod>-old_person IS INITIAL AND
NOT <fs_mod>-new_person IS INITIAL.
CONCATENATE: 'Contact person from:'
<fs_mod>-old_person
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Contact person to :'
<fs_mod>-new_person
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
ENDIF.
* number
IF NOT <fs_mod>-old_number IS INITIAL AND
NOT <fs_mod>-new_number IS INITIAL.
CONCATENATE: 'Contact number from:'
<fs_mod>-old_number
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
CONCATENATE: 'Contact number to :'
<fs_mod>-new_number
INTO v_contents
SEPARATED BY space.
wa_mailtxt-line = v_contents.
APPEND wa_mailtxt TO gt_mailtxt.
CLEAR: wa_mailtxt, v_contents.
ENDIF.
ENDLOOP.
wa_mailrec-receiver = <fs_email>-zemail.
wa_mailrec-rec_type = 'U'.
APPEND wa_mailrec TO gt_mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = t_maildata
document_type = 'RAW'
put_in_outbox = 'X'
* commit_work = 'X'
TABLES
* object_header = mailtxt
object_content = gt_mailtxt
receivers = gt_mailrec
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 sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR: wa_mailtxt, wa_mailrec.
REFRESH: gt_mailtxt, gt_mailrec.
ENDLOOP.
ENDIF.
ENDIF.
FREE MEMORY ID 'AVH'.
FREE MEMORY ID 'DEL'.
FREE MEMORY ID 'MOD'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* FORM get_orig_contents_of_zts0001 *
*/ before saving the data in the database
FORM get_orig_contents_of_zts0001.
DATA: get_old_recs TYPE REF TO lcl_get_old_recs.
CREATE OBJECT get_old_recs.
CALL METHOD get_old_recs->export_old_recs.
ENDFORM.
* FORM get_rev_contents_of_zts0001 *
*/ after saving the data in the database
FORM get_rev_contents_of_zts0001.
DATA: old_and_new TYPE REF TO lcl_old_and_new,
check_changes TYPE REF TO lcl_check_changes,
messages TYPE REF TO lcl_messages.
CREATE OBJECT: old_and_new, check_changes, messages.
CALL METHOD old_and_new->compare_old_and_new.
CALL METHOD check_changes->check_for_changes.
CALL METHOD messages->create_message.
ENDFORM.
* FORM move_latest_date_and_user *
FORM move_latest_date_and_user.
zts0001-zcreated_by = sy-uname.
zts0001-zchanged_date = sy-datum.
ENDFORM.
Hope it helps...
P.S. Please award points if it helps... -
Send mail with attached file without using Repository
Hello,
I want to know if have a way to Send mail with attached file without using Repository.
Regards
EladElad,
Check this article where a image has been picked by the file adapter and sent as an attachment to the mail adapter.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816">Sending an Image File Through XI in a File-to-Mail Scenario</a>
For how to proceed without integration repository content look into this blog,
<a href="/people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository">How to send any data (even binary) through XI, without using the Integration Repository</a>
Combining these 2 you have the solution.
Regards
Bhavesh -
Problem in excel format while sending mail with excel attachment.
Hi Gurus ,
I am sending a email with Excel attachment using FM SO_DOCUMENT_SEND_API1 or SO_NEW_DOCUMENT_ATT_SEND_API1.
I am able to send a mail with excel attachment with a piece of code which I got from SDN itself.
But the problem is when I am trying to open the attachment, <b>A pop up comes which says that it is not in recognizable format. Would you like to open it?
and several other lines of caution.</b>
When i choose to open it, i get the correct data in one excel sheet. Certain vertical lines of the excel sheet is missing. <b>But no data is missing. </b>
I am attaching the code below. Can any one please tell me where is the problem in this code ?
Thanx in advance
types: begin of t_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
meins type mara-meins,
end of t_mara.
data: gt_mara type table of t_mara,
wa_mara like line of gt_mara,
it_packing_list type table of SOPCKLSTI1,
wa_packing_list like line of it_packing_list,
it_receivers type table of SOMLRECI1,
wa_receivers like line of it_receivers,
it_mailbody type table of SOLISTI1,
wa_mailbody like line of it_mailbody,
it_attachment type table of SOLISTI1,
wa_attachment like line of it_attachment.
data: la_doc type SODOCCHGI1.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
* get material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
* Populate the subject/generic message attributes
la_doc-obj_langu = sy-langu.
la_doc-obj_descr = 'Material Details' . "Mail Header
la_doc-sensitivty = 'F'.
la_doc-doc_size = 1.
* Add the recipients email address
CLEAR wa_receivers.
REFRESH it_receivers.
wa_receivers-receiver = 'PCSDEVL'.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers to it_receivers.
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody to it_mailbody.
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
ENDLOOP.
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list to it_packing_list.
* Create attachment notification
wa_packing_list-transf_bin = 'X'.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
wa_packing_list-obj_descr = ' '.
concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
separated by space.
wa_packing_list-doc_size = wa_packing_list-body_num * 255.
APPEND wa_packing_list to it_packing_list.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = la_doc
PUT_IN_OUTBOX = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
tables
packing_list = it_packing_list
* OBJECT_HEADER =
CONTENTS_BIN = it_attachment
CONTENTS_TXT = it_mailbody
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_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
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.REPORT Zex5 LINE-SIZE 255 LINE-COUNT 255 .
class CL_ABAP_CHAR_UTILITIES definition load. "-->
TABLES : vbap.
SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
DATA : BEGIN OF itab OCCURS 1,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
END OF itab.
parameters : p_email like somlreci1-receiver
DATA: tlines type i.
DATA: itmessage LIKE solisti1 OCCURS 1 WITH HEADER LINE. "Ok
DATA: itattach LIKE solisti1 OCCURS 2 WITH HEADER LINE. "Ok
DATA: itpacklist LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: itreclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
data: itattachment like solisti1 OCCURS 2 WITH HEADER LINE.
start-of-selection.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE itab
WHERE vbeln IN s_vbeln.
**Make the internal table data to be compatible in excel format .
PERFORM BUILD_XLS_FORMAT.
**Populate message of body text.
clear itmessage.
refresh itmessage.
itmessage = 'Please find attached Excel file'.
append itmessage.
PERFORM send_mail_as_xls_attachment tables itmessage
itattach
using p_email 'Excel Attachment' 'TXT' " 'XLS'
using p_email 'TEXT Attachment' 'TXT' " 'XLS'
'TestFileName'
'SalesOrders' .
*& Form BUILD_XLS_FORMAT
text
--> p1 text
<-- p2 text
form BUILD_XLS_FORMAT.
previosuly we were using for unicode ..now replaced
**Declare constants for the spacing .
*Constants : con1 type x value '0D',
con2 type x value '09'.
Constants : con1 type c
value CL_ABAP_CHAR_UTILITIES=>CR_LF,
con2 type c
value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
**For the Header descriptions.
Concatenate 'SalesORdNo'
'Item'
'Materialno' into itattach separated by con2.
Concatenate con1 itattach into itattach.
Append itattach.
**Now align the items in the itab as above .
Loop at Itab.
concatenate itab-vbeln
itab-posnr
itab-matnr into itattach separated by con2.
concatenate con1 itattach into itattach .
Append itattach.
endloop.
endform. " BUILD_XLS_FORMAT
*& Form send_mail_as_xls_attachment
text
-->P_ITMESSAGE text
-->P_ITATTACH text
-->P_P_EMAIL text
-->P_0116 text
-->P_0117 text
-->P_0118 text
-->P_0119 text
form send_mail_as_xls_attachment tables p_itmessage
p_itattach
using p_email
p_mtitle
p_format
p_filename
p_attdescription.
Data : xdocdata like sodocchgi1,
xcnt type i.
*Fill the document data.
xdocdata-doc_size = 1.
*Populate the subject/generic message attributes.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_langu = sy-langu.
xdocdata-obj_descr = p_mtitle.
*Fill the document data and fetch size of attachment.
clear xdocdata.
read table itattach index xcnt.
xdocdata-doc_size = ( xcnt - 1 ) * 255 + strlen( itattach ).
xdocdata-doc_size = ( xcnt - 1 ) * 255.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_langu = sy-langu.
xdocdata-obj_descr = p_mtitle.
clear itattachment. refresh itattachment.
itattachment[] = p_itattach[].
*Describe the body of the message.
clear itpacklist. refresh itpacklist.
itpacklist-transf_bin = 'X'.
itpacklist-head_start = '1'.
itpacklist-head_num = '0'.
itpacklist-body_start = '1'.
describe table itattachment lines itpacklist-body_num .
itpacklist-doc_type = 'TXT'.
itpacklist-doc_type = 'XLS'.
append itpacklist.
*Create attachment notification.
itpacklist-transf_bin = 'X'.
itpacklist-head_start = '1'.
itpacklist-head_num = '1'.
itpacklist-body_start = '1'.
describe table itattachment lines itpacklist-body_num .
itpacklist-doc_type = p_format.
itpacklist-obj_name = p_filename.
itpacklist-obj_descr = p_attdescription.
itpacklist-doc_size = itpacklist-body_num * 255 .
append itpacklist.
*FIll the receivers list.
Clear itreclist. refresh itreclist.
itreclist-receiver = p_email.
itreclist-rec_type = 'U'.
itreclist-com_type = 'INT'.
itreclist-notif_del = 'X'.
itreclist-notif_ndel = 'X'.
*itreclist-notif_read = 'X'.
append itreclist.
*CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = xdocdata
PUT_IN_OUTBOX = 'X'
commit_work = 'X'
SENDER_ADDRESS = SY-UNAME
tables
packing_list = itpacklist
CONTENTS_BIN = itattachment
CONTENTS_TXT = itmessage
receivers = itreclist
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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = xdocdata
PUT_IN_OUTBOX = 'X'
TABLES
packing_list = itpacklist
CONTENTS_BIN = itattachment
CONTENTS_TXT = itmessage
receivers = itreclist
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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " send_mail_as_xls_attachment
Just execute the above code and let me know.
What is the sap version u r using .
Vijay -
Error in Sending Mail with excel attachment
Hi All,
While sending a mail with excel attachment it is getting successfully send but when i am opening the excel it gives a popup saying "The file is not in recognizable format", and when i click OK the data is getting displayed.
So anybody has any idea of how to remove the popup??
I am using SO_NEW_DOCUMENT_ATT_SEND_API1 FM for sending the mail.
Can anybody help me regarding this.
Thanks
SalishHi,
I was facing the issue when I did not populate the parameters packing_list, object_header,contents_bin, contents_txt of the FM
SO_NEW_DOCUMENT_ATT_SEND_API1 properly.
Also the possible cause could be the configuration in SCOT, not very sure about this. Check with the BASIS guy.
Regards,
Sagar -
Creating an e-mail with excel file attachment
Morning,
Does anyone know how to create an e-mail with a spreadsheet attachment (in foreground and background). I can create an e-mail (in foreground and background) with a text (tab delimited) file attachment with a suffix of .xls. I have created the file by writing text to a string and then putting it into a text format using the function module SCMS_STRING_TO_FTEXT.
Thanks and regards
John.See the following simple ex:
DATA: P_EMAIL TYPE SOMLRECI1-RECEIVER.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
***Sending mail to the receipients
if not it_final[] is initial.
PERFORM SUB_GET_MAIL_ADDR.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Sales Register Report - Set Top Box / Accessories'
'XLS'
'SSTB'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
endif.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM BUILD_XLS_DATA_TABLE .
data: wa_itab like it_final.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'Business Place' 'Region Code' 'Region' 'Branch Code'
'Branch' 'Material Desc' 'Area off Code'
'Area Name' 'Zone code' 'Zone Name' 'Cust No' 'Cust Name'
'Bill Doc No' 'Bill Date' 'Base Val' 'Total Val' 'Quantity'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_FINAL INTO WA_ITAB.
CONCATENATE WA_ITAB-BUSINESS_PLACE
WA_ITAB-KVGR1
WA_ITAB-REGION
WA_ITAB-VKBUR
WA_ITAB-SALES_OFF
WA_ITAB-ARKTX
WA_ITAB-vkgrp
WA_ITAB-sales_grp
WA_ITAB-bzirk
WA_ITAB-zone
WA_ITAB-kunnr
WA_ITAB-name
WA_ITAB-vbeln
WA_ITAB-fkdat
WA_ITAB-base_value
WA_ITAB-total_value
WA_ITAB-fkimg
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form POPULATE_EMAIL_MESSAGE_BODY
text
--> p1 text
<-- p2 text
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO G_DATE.
IT_MESSAGE = 'Please find attached excel sheet.'.
APPEND IT_MESSAGE.
IT_MESSAGE = 'Report'.
APPEND IT_MESSAGE.
Concatenate 'Report generated date' ':' G_Date '.' into IT_MESSAGE.
APPEND IT_MESSAGE.
clear it_message.
append it_message.
IT_MESSAGE = 'This is an autogenerated mail, please do not reply'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
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-OBJ_NAME = 'stb'.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-DOC_TYPE = 'XLS'.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_DESCR = 'Sales_STB'.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-OBJ_NAME = 'stb'.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
LOOP AT IT_RECV.
T_RECEIVERS-RECEIVER = IT_RECV-EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-COPY = 'X'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_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
OTHERS = 8.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
text
--> p1 text
<-- p2 text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = ''
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM -
Sending email with excel file as an attachment
Hi,
In my procedure I am creating one excel file and keeping that excel file in one location as specified in UTL_FILE_DIR.Now my requirement is to pick that excel file from that path and send it as an attachment through an Email.
Can anyone please give me the code to do that and what are the required set up to be done before sending the mail.
Please help me in this regard. This is an urgent requirement.
Thanks
SubhabrataHi,
Please refer the following link:
http://www.dbasupport.com/oracle/ora10g/10g_PLSQL02.shtml
There is para headed Sending E-Mail and Attachments with UTL_MAIL will clarify all your doubts. Link Listing 2.6
is good example.
If you get stuck while coding, get back to us.
Twinkle -
Problem when sending mails with excel attached
Hi
I'm tryin to send mails via SAPOffice with attached excel documents. I'm using FM SO_NEW_DOCUMENT_ATT_SEND_API1. I have a problem with the code. Here I post it:
DATA: ti_objbin LIKE solisti1 OCCURS 150 WITH HEADER LINE,
ti_objhex LIKE solix OCCURS 150 WITH HEADER LINE.
DATA: BEGIN OF i_excel,
sobid(8) TYPE c,
tab1 TYPE X VALUE 09, "tab code
name(80) TYPE c,
tab2 TYPE X VALUE 09, "tab code
city(40) TYPE c,
tab3 TYPE X VALUE 09, "tab code
kostl(10) TYPE c,
tab4 TYPE X VALUE 09, "tab code
ktext(20) TYPE c,
tab5 TYPE X VALUE 09, "tab code
fasig(10) TYPE c,
tab6 TYPE X VALUE 09, "tab code
ruta(255) TYPE c,
fin TYPE X VALUE 13, "carriage return
END OF i_excel.
i_excel-sobid = wa_datos-sobid.
i_excel-name = wa_datos-name.
i_excel-city = wa_datos-city.
i_excel-kostl = wa_datos-kostl.
i_excel-ktext = wa_datos-ktext.
i_excel-fasig = wa_datos-fasig.
i_excel-ruta = wa_datos-ruta.
WRITE i_excel TO ti_objbin-line.
APPEND ti_objbin.
CLEAR ti_objbin.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
TABLES
packing_list = ti_objpack
object_header = ti_objhead
contents_bin = ti_objbin
contents_txt = ti_objtxt
* contents_hex = ti_objhex
receivers = ti_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.
I have used this code before, in 4.6C release and it works fine, but now I'm on ECC5.0 and when i check the code, the next error message is generated: ""I_EXCEL" cannot be converted to a character-type field." If i try using MOVE i_excel TO i_objbin-line instead of WRITE, the error message changes to: ""TI_OBJBIN-LINE" and "I_EXCEL" are not mutually convertible in a Unicode program. program.". I have tried using ti_objhex table instead of ti_objbin in order to use 'context_hex' parameter (instead of 'context_bin') on FM, but i get the same result.
I've been searching any other FM to do this, and i've found more FM of SOI1 function group but i didn´t get the expected result. So i need to send the message with the excel attached, using this FM or any other, but I need some help. Anyone can help me?
Thanks and Regardshi this is a simple example to send the excel sheet as a mail
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver .
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM build_xls_data_table.
data: ld_store(50) type c. "Leading zeros
CONSTANTS: con_cret(5) TYPE c VALUE '0D', "OK for non Unicode
con_tab(5) TYPE c VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
*Modification to retain leading zeros
inserts code for excell REPLACE command into ld_store
=REPLACE("00100",1,5,"00100")
concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
wa_charekpo-ebelp '")' into ld_store .
concatenate ld_store into .xls file instead of actual value(ebelp)
CONCATENATE wa_charekpo-ebeln ld_store wa_charekpo-aedat wa_charekpo-matnr INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
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.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_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
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
regards,
venkat. -
Sender "Mail" adapter - CSV file attachment
Hi there
I'm looking for some help in configuring a sender mail adapter that receives ".csv" files. I did read some blogs that mention using the "PayloadSwapBean" module to read the mail attachment instead of the mail content. My problem is to now convert the ".csv" file into a message. Is there a module that I can use ( is it the "MessageTransfomBean" ) and how. Any help would be appreciated.
Thanks
SalilHi Salil,
If you want to send a mail with a body and attachments, the message sender HAS to provide an XI message with attachments. I doubt a CSV file does justice.
As Renjith said you need to convert CSV to XmL.
A short description about the Standard Modules:
MessageTransformationBean is a standard module used to apply the XSLT mapping to the adapter module by using <i>Transform.class</i> ( This xslt mapping is done to create a mail package, Dont confuse with the actual mapping in your case this is NOT for converting csv to xml).
Also this module can be used to change the name and type of payloads by using <i>Transform.contentType</i>, <i>Transform.contentDisposition</i>, <i>Transform.contentDescription</i>.
PayloadSwapbean is a standard module for replacing payloads with other payloads (SWAP)
If you want to give each attachment a certain name use Parameters, <i>swap.keyname</i> for name of the payload and <i>swap.keyvalue</i>.
I Hope the use of standard modules is understood. -
Sending mail with excel more than 255 character in a line
Dears,
In my program , I use SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with EXCEL attacment.
But when i want output a line more than 255 characters in the excel I met the problem, it only appeared 255 characters
describe table mailbin lines tab_lines.
mailpack-transf_bin = c_checked.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = c_xls.
mailpack-obj_name = space.
mailpack-obj_descr = lv_mail_title. "the excel file name
mailpack-doc_size = tab_lines * 255.
append mailpack.
* Sending the document
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = space
commit_work = c_checked
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.
But i have to output those characters in one line.
Anyone could help me?
Thanks a lot.
Sincerely,
Juliedata: objpack like sopcklsti1 occurs 2 with header line.
data: objhead like solisti1 occurs 1 with header line.
data: objbin like solisti1 occurs 10 with header line,
is_objbin type solisti1 .
data: objtxt like solisti1 occurs 10 with header line,
is_objtxt type solisti1 .
data: l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab,
con_cret type c value cl_abap_char_utilities=>cr_lf.
data: tab_lines like sy-tabix,
: tab_lines1 like sy-tabix.
data : lenth_string type string,
s_string type string.
data : L type i, i type i,cplen type i, balance type i,
before describe table mailbin lines tab_lines ... Use below logic.
Loop at your_internaltable.
concatenate field_1
field_2
field_3
into lenth_string separated by l_tab.
concatenate lenth_string con_cret into lenth_string.
concatenate s_string lenth_string into s_string.
endloop.
L = strlen( s_string ).
i = 0.
cplen = 255.
balance = l.
do.
if balance <= 0.
exit.
endif.
if balance < 255.
cplen = balance.
else.
cplen = 255.
endif.
objbin = s_string+i(cplen).
i = i + cplen.
balance = balance - cplen.
append objbin.
enddo.
...... after this use ur exesting code....describe table mailbin lines tab_lines and so
describe table objbin lines tab_lines1.
clear objpack-transf_bin.
objpack-transf_bin = ' '.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines1.
objpack-obj_langu = 'E'.
objpack-doc_type = 'XLS'.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
-tables
packing_list = objpack
object_header = objhead
contents_bin = objbin
receivers = reclist
Regards,
Sri.
Edited by: sridhar arjunan on Jul 28, 2009 4:22 PM
Edited by: sridhar arjunan on Jul 28, 2009 4:23 PM -
Send mail by zip file format..
Hi ALL,
I have a one problem in sending mail through SAP. I have file with more than 5MB in pdf format, this file i am unble to send. but below 5MB its successfully sending.
so i m doubt is i have to zip the file, means if that file is more than 5MB.
please any one tell me for above problem.
Thanks,
Srinivas.Take a look to the class CL_ABAP_GZIP.
Regards.
Maybe you are looking for
-
Jabber for IPad Directory Issue
Guys, I'm been beating my head against this issue for the last couple of days and I think a new idea would be extremely helpful! Problem: No Corporate Directory being shown at all. Jabber for IPad client Version 9.1 CUCM 8.5 CUP 8.6(3) Microsoft AD E
-
Problem with FX5600VTDR in Games andMedia Deluxe II
Can you help me with my problems? When I start MSI Media deluxe II studio there are no letters. Except the letters there are only squares. Everything other (windows and colors) is correct. My next problem is with some games. For example in Comm
-
Hi to everyone, No doubt this house is full of geniuses. Problem i have in my application is I have a main tab canvas which has two tab pages 1. Main 2. Details on detail page i want to display multiple subtab pages. What I want to achieve is when I
-
Get smartview data for another application
Is there a supported API call I can make via HTTP to consume the same data that smartview uses? Could I just make the same HTTP calls that the smartview plugin uses? Thank you!
-
Como hago validar el programa?
instale el programa, cuando quiero abrir para trabajar me dice qe inicie sesión y que me pone "validar numero de serie" PEro no se como se hace, o qe debo hacer.