ODI send email with latest error file attachment
We have kick-out/error file with the format *err.txt. Whenever error occurs the same gets overwritten by the latest file. We are attaching this error file on the completion of the job. If error file generates, everything is fine. But, on the successful run, I mean when there are no error file generation, it attaches the previous run error file.
Anyone of you help me how to handle this situation. Is there any way to validate the file generation date before attaching the file.
Thanks in advance
Edited by: user12958295 on Oct 30, 2012 7:42 AM
Hi,
Thanks for the response.
As of now we are following that as a workaround. However our client wants to avoid the manual work of delete/move/renaming the error file.
Is it possible to check the file generated date with sysdate for attaching the error file by odisendmail.
Thanks!
BRM
Similar Messages
-
when I send an email with a photoshop file attached, the recipient receives it "flattened". How do I change this?
I've sent psd files to various people without issues, however you might want to try something like www.filedropper.com to make sure it's not that they can't open your version of psd file.
You may also want to zip the file using the built in archiving software, simply right click (or control click) the file and choose Compress ...., then you can email it to the person as a compressed archive. That should preserve all the aspects of the file properly without any modifications. -
Why is gmail blocking me from sending email with a "pages" document attached?
Why is gmail blocking me from sending email with a "pages" document attached? I've checked the document for viruses with "MacKeeper" and it's clean.
Google reads your emails, in case you did not know that. Unless you are sending an email containing content Google can extract and add to its vast database of personal information, Google has no use for it.
Google Mail is becoming progressively useless. It won't accept .zip attachments, at least not the last time I tried, it will eventually prevent you from using an email client unless you visit their web mail interface, and it will disable your account if you attempt to log in from someplace Google deems is not where Google thinks you ought to be.
Gmail is worth every cent you paid.
Get rid of MacKeeper. It is capable of doing nothing beneficial and will only cause problems. -
OWA Email Prompt Before Sending Email With Spelling Errors
Looking for a way to configure OWA so that it does not send, or at least prompts you before sending, an email that has spelling errors?
ThanksHi FaeB,
Thank you for your question.
Exchange 2013 OWA didn’t just receive email without any development.
When we send email with spelling error, OWA will display the red line under incorrect word, as the following snapshot:
In snapshot, I make the word of “email” and “error” incorrect. If we didn’t modify it, OWA will not give another reminder when we send emails.
If there are any questions regarding this issue, please be free to let me know.
Best Regard,
Jim -
Send email with existing excel-file as attachment
Is there a function to send an e-mail with an attachment which is an existing excel-file on my C:\-drive.
I found lots of possibilities to send mail with internal tables as attachment but in my case the attachment is an existing excel-file (c:\test.xls)...
thanxHi,
FOund these function modules
Try this out.
ISR_FI_SEND_EMAIL
ISR_FI_SEND_EMAIL_NEW_USER
SLS_CUST_SEND_EMAIL_TOOL
OR
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Thanks & Regards,
Judith. -
Sending emails with both body and attachment to multiple recipients
I have a requirement to send email with body and attachment to multiple recipients.
Body of the email is a standard text. It is a proxy-to-mail scenario.
Here is what I've done: (I'm using PI 7.11)
One mapping from Source to Target structure (format of the attachment text file)
Second mapping from Target Structure to Mail Package format.
In the second mapping I'm concatenating the output of first step into "Content" of the Mail Package.
"XIPAYLOAD" is the message protocol used.
The "Keep attachments" option in the Mail adapter allows only to send "Content" as attachment or as body of the email.
How to send an email with both content and text?
The other problem is even with using ASMA, I can't send email to multiple recipients. I can only do CC and TO for 1 person each - a total of 2. Although I can resolve this by creating mailing lists, it is better if this can be addressed in PI.
Thanks for any input you can provide!
Edited by: crazylad on Jan 18, 2012 3:39 PMThank you for your response Mikael.
For the first question, I was able to find the solution in the following blog:
XI Mail Adapter : Dynamically building attachment and message body content using a simple UDF
(I just needed to search with the right set of key words )
The key is to set the "Content Encoding" as "None" in the mail adapter. If this is not done, the mail will be sent with an attachment - untitled.bin containing both the mail body and the attachment text. Also, don't forget to check the "Keep Attachments" checkbox in the mail adapter.
Multiple recipients could be added by separating the email IDs with a Comma. I have used ASMA to set the recipients. -
To send email with editable PDF/XLS attachment
Hi All,
Is it possible to send editable PDF/XLS attachment in a mail to the customer via SAP, if yes how?
Please Help! Urgenthi,
*Sending mail with attachment
* This program will allowed you to send email with attachment.
* First, specify the attachment file from your local hardisk and execute.
* Next, specify the sender email address and click the send button.
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
* Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
* PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
* EXCEPTIONS
* USER_NOT_EXIST = 1
* PARAMETER_ERROR = 2
* X_ERROR = 3
* OTHERS = 4
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
* FOLMEM_DATA =
* RECEIVE_DATA =
* File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Hope this helps, Do reward. -
Can't send email with large (over 1MB) attachment
Win 7 64-bit, Thunderbird 31.2.0, eSet antivirus (but disabling it for email doesn't help), godaddy email server (works fine from godaddy web mail), port 80 (been using this port for years; 25 doesn't work)
Sending email with a 974KB attachment works. Email with a 1.4MB (and larger) attachment doesn't work. The error message appears pretty quickly (5 seconds at the most).
The message is "the connection to SMTP server smtpout.secureserver.net timed out".
This problem seem to appear at random, then go away and all is well (for a while).No. The modem is an Arris obtained from Comcast on 6/9/2014 after the prior one failed.
-
Sending email with 1-2 MB attachment
Why sending email with small attachment in iPad IOS7 feels like waiting for a flight delay without announcement ?
Very embarrassing for Apple to missed this issue....
Internet connection is fine, but email could not get through the outbox.... Oh my God...Hey,
Many people have expirienced this...
The problem for most people were their, internet connection, or their device.
This might not work, for some people.
I would recommend holding down the power button and the home button until the apple logo shows up.
Then you can open mail and send your attachment, hopefully.
If that was successfull, have a good evening!
-- Shamurocks45 -
Send email with spool in excel attachment
Hi,
I have this function:
CALL FUNCTION 'Z_SEND_EMAIL_SPOOL_PDF'
EXPORTING
application = 'EMAIL'
emailtitle = texttitle
recextnam = email
src_spoolid = tsp01-rqident
TABLES
texttab = body.
And code:
FUNCTION z_send_email_spool_pdf .
*"*"Interfase local
*" IMPORTING
*" REFERENCE(APPLICATION) LIKE SOOD1-OBJNAM DEFAULT 'EMAIL'
*" REFERENCE(EMAILTITLE) LIKE SOOD1-OBJDES
*" VALUE(RECEXTNAM) LIKE SOOS1-RECEXTNAM
*" REFERENCE(SRC_SPOOLID) LIKE TSP01-RQIDENT
*" TABLES
*" TEXTTAB STRUCTURE SOLI
*- local data declaration
DATA: ohd LIKE sood1,
oid LIKE soodk,
to_all LIKE sonv-flag,
okey LIKE swotobjid-objkey.
DATA: g_document LIKE sood4,
g_header_data LIKE sood2,
g_authority LIKE sofa-usracc,
lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE,
l_folder_id LIKE sofdk,
l_objcont LIKE soli OCCURS 0 WITH HEADER LINE,
i_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
l_objhead LIKE soli OCCURS 0 WITH HEADER LINE,
folder_id LIKE soodk,
object_id LIKE soodk,
link_folder_id LIKE soodk,
hd_dat LIKE sood1.
DATA: desired_type LIKE sood-objtp,
real_type LIKE sood-objtp,
attach_type LIKE sood-objtp,
otf LIKE sood-objtp VALUE 'OTF', " SAPscript Ausgabeformat
ali LIKE sood-objtp VALUE 'ALI', " ABAP lists
pdf LIKE sood-objtp VALUE 'PDF', "PDF format
pbyte TYPE i,
t_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
objtype LIKE rststype-type,
type LIKE rststype-type.
CONSTANTS: ou_fol LIKE sofh-folrg VALUE 'O',
c_objtp LIKE g_document-objtp VALUE 'RAW',
c_file_ext LIKE g_document-file_ext VALUE 'PDF'.
DATA: BEGIN OF receivers OCCURS 0.
INCLUDE STRUCTURE soos1.
DATA: END OF receivers.
* Fist part: Verify if the spool really exists
SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
CHECK sy-subrc = 0.
*- fill odh
CLEAR ohd.
ohd-objla = sy-langu.
ohd-objnam = application.
ohd-objdes = emailtitle.
ohd-objpri = 3.
ohd-objsns = 'F'.
ohd-ownnam = sy-uname.
*- send Email
CONDENSE recextnam NO-GAPS.
CHECK recextnam <> space AND recextnam CS '@'.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = tsp01-rqclient
name = tsp01-rqo1name
part = 1
IMPORTING
type = type
objtype = objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4
OTHERS = 5.
attach_type = c_objtp.
desired_type = pdf.
IF objtype(3) = 'OTF'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = src_spoolid
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_pdf.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = src_spoolid
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_pdf.
ENDIF.
PERFORM convertir_tabla_pdf_2 TABLES t_pdf l_objcont.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
owner = sy-uname
region = ou_fol
IMPORTING
folder_id = l_folder_id
EXCEPTIONS
OTHERS = 5.
* fill out informations about the header of the email
CLEAR: g_document.
g_document-foltp = l_folder_id-foltp.
g_document-folyr = l_folder_id-folyr.
g_document-folno = l_folder_id-folno.
g_document-objtp = c_objtp.
g_document-objdes = emailtitle.
g_document-file_ext = c_file_ext.
g_header_data-objdes = emailtitle.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'SAVE'
office_user = sy-uname
IMPORTING
authority = g_authority
TABLES
objcont = texttab
attachments = lt_attachments
CHANGING
document = g_document
header_data = g_header_data
EXCEPTIONS
OTHERS = 1.
object_id-objtp = c_objtp.
object_id-objyr = g_document-objyr.
object_id-objno = g_document-objno.
folder_id-objtp = l_folder_id-foltp.
folder_id-objyr = l_folder_id-folyr.
folder_id-objno = l_folder_id-folno.
link_folder_id-objtp = l_folder_id-foltp.
link_folder_id-objyr = l_folder_id-folyr.
link_folder_id-objno = l_folder_id-folno.
hd_dat-file_ext = pdf.
hd_dat-objdes = emailtitle.
CALL FUNCTION 'SO_ATTACHMENT_INSERT'
EXPORTING
object_id = object_id
attach_type = attach_type
object_hd_change = hd_dat
owner = sy-uname
TABLES
objcont = l_objcont
objhead = l_objhead
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
object_type_not_exist = 17
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
x_error = 1000.
* FORM SO_OBJECT_SEND_REC *
FORM so_object_send_rec
TABLES objcont STRUCTURE soli
receivers STRUCTURE soos1
USING object_hd STRUCTURE sood1
folder_id
object_id
link_folder_id.
DATA: oid LIKE soodk,
to_all LIKE sonv-flag,
okey LIKE swotobjid-objkey.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
extern_address = 'X'
* object_hd_change = object_hd
* object_type = 'RAW'
outbox_flag = 'X'
sender = sy-uname
owner = sy-uname
folder_id = folder_id
object_id = object_id
store_flag = 'X'
link_folder_id = link_folder_id
IMPORTING
object_id_new = oid
sent_to_all = to_all
office_object_key = okey
TABLES
objcont = objcont
receivers = receivers
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
x_error = 20
OTHERS = 21.
IF sy-subrc <> 0.
RAISE others.
ENDIF.
ENDFORM.
* FORM INIT_REC *
FORM init_rec TABLES receivers STRUCTURE soos1.
CLEAR receivers.
REFRESH receivers.
MOVE sy-datum TO receivers-rcdat .
MOVE sy-uzeit TO receivers-rctim.
MOVE '1' TO receivers-sndpri.
MOVE 'X' TO receivers-sndex.
MOVE 'U-' TO receivers-recnam.
MOVE 'U' TO receivers-recesc.
MOVE 'INT' TO receivers-sndart.
MOVE '5' TO receivers-sortclass.
APPEND receivers.
ENDFORM.
With this function I can send a spool in pdf format by email. But, now I need send a spool in Excel (xls) format by email. I try to disconnect 'CONVERT_OTFSPOOLJOB_2_PDF' and 'CONVERT_ABAPSPOOLJOB_2_PDF' but doesnt work.
Can you help me?
A lot of thanks in advance.
Best regards.Hi.
I do not think it is feasible to create a worthwhile Excel file from a SAP spool file.
I have reports that send output as Excel attachments to email, but the code (including function modules etc) is too much to post here.
You can use OLE to create an Excel file, but this will not generally work when the report is run in the background.
So my approach is to make the report write an Excel XML file (that's just text after all), and send that as an XLS email attachment. When the email receiver double-clicks on the attachment, it fires up Excel and brings in the data. Most users would not realise that it's not a native Excel file.
One nice touch is to have two sheets in the Excel file, one with the main report and the other with the selection criteria.
Of course there is a lot of work getting started with this.
John -
Send email with 1 excel file and multiple sheet
Hi,
I need to send an email with attachment file in excel format. The problem is now the requirement requires 2 worksheets/tabs in 1 excel file.
For example: I need to put details data in sheet1 and summary data in sheet2 and this program should be working also if it is run in background mode.
Currently, Im using cl_document_bcs to create document, but could not find a way to create 2 tabs in the excel file.
Has anyone got an ideas on how it should done?Hi,
Welcome to SDN.
check these links :
/people/sap.user72/blog/2006/02/07/downloading-data-into-excel-with-format-options
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c
Regards
Appana
*reward Points for helpful answers -
Send Email with more existing files
Hi,
Does anybody explain to me if ...
Is there a function in ABAP to send an external email with more than one files that exist already?
Something like : a function with parameters
- a table for the directory\name(attachments).
- a table for the text lines for the email.
- a table for the internet addres.
I must send an email wiht 3 different kind of files (pdf, txt and xls) and some text to explain the content of them.
Thak you,For sending mails with attachment of text and xls you can refer the following code:
REPORT Z34332_MAIL_WITH_ATTACHMENT1.
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.
But to send attachment of pdf , refer the following process:
DATA: BEGIN OF i_mara OCCURS 0,
matnr LIKE mara-matnr.
DATA: END OF i_mara.
DATA: v_dest LIKE tsp01-rqdest,
v_handle LIKE sy-tabix,
v_spool_id LIKE tsp01-rqident,
v_rc TYPE c,
v_errmessage(100) TYPE c,
v_text(70) TYPE c.
START-OF-SELECTION.
SELECT matnr FROM mara INTO TABLE i_mara.
CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LOCL'
LAYOUT =
NAME =
SUFFIX1 =
SUFFIX2 =
COPIES =
PRIO =
IMMEDIATE_PRINT =
AUTO_DELETE =
TITLELINE =
RECEIVER =
DIVISION =
AUTHORITY =
POSNAME =
ACTTIME =
LIFETIME = '8'
APPEND =
COVERPAGE =
CODEPAGE =
DOCTYPE =
IMPORTING
handle = v_handle
spoolid = gd_spool_nr
rc = v_rc
errmessage = v_errmessage.
LOOP AT i_mara.
v_text = i_mara-matnr.
CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = v_handle
text = v_text
LENGTH =
CODEPAGE =
TRUNCATE =
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = v_handle
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
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 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
get the spool number
Declaration of local variables.
DATA:
LV_RQ2NAME LIKE TSP01-RQ2NAME.
CONCATENATE SY-REPID+0(8)
SY-UNAME+0(3)
INTO LV_RQ2NAME SEPARATED BY '_'.
Get the spool number.
SELECT * FROM TSP01 WHERE RQ2NAME = LV_RQ2NAME
ORDER BY RQCRETIME DESCENDING.
V_RQIDENT = TSP01-RQIDENT.
EXIT.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR V_RQIDENT.
ENDIF
Pablo
Reward points if helful -
Send email with spool as PDF attachment using class CL_BCS
Hi,
I am converting a spool to PDF using the function module CONVERT_OTFSPOOLJOB_2_PDF. The spool contains graphic images etc just like a script output.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = v_rqident
no_dialog = 'X'
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11.
After this I want to attach the pdf as an attachment to an email and send it. For this purpose I am using the code found in the example BCS_EXAMPLE_5.
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'My attachment'
i_att_content_hex = binary_content.
How do I convert the script text into binary content, could you please suggest some help.Old code, but I use:
DATA: lt_pdf TYPE soli_tab,
lt_pdfbin TYPE solix_tab.
* Convert the lines
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
transfer_bin = 'X'
TABLES
content_in = i_pdf
content_out = lt_pdf
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc NE 0.
RAISE convert_error.
ENDIF.
lt_pdfbin = lt_pdf.
Also, keep in mid that that OTF convert function has a 99 page limit - if you can potentially reach that limit, you need to handle the background job process and retrieval of the RAW data from the spool. -
Need to send email with excel sheet as attachment: URGENT
Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
NandaHi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
Nanda -
Sending email with multiple attachments
Hi forum,
I am able to send email with a single attachment using maildemo.sql from: http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
But now I am trying to send email with more than 1 attachment and it does not work. My code that calls the above mentioned package is as follows:
<code>
PROCEDURE send (
psender VARCHAR2,
precipients VARCHAR2,
pcc VARCHAR2,
pbcc VARCHAR2,
psubject VARCHAR2,
pmessage VARCHAR2,
pnumattach NUMBER) -- The number of attachments that need to be sent
IS
p_blob BLOB;
p_filename VARCHAR2(200);
p_filetype VARCHAR2(200);
p_currSeq NUMBER;
conn utl_smtp.CONNECTION;
i NUMBER;
j NUMBER;
len NUMBER;
BEGIN
IF pnumattach > 1
THEN
conn := SEND_EMAIL_HELPER.begin_mail(
sender => psender,
recipients => precipients,
subject => psubject,
mime_type => send_email_helper.MULTIPART_MIME_TYPE);
j := 0;
SELECT seq_attach_transact_id.CURRVAL INTO p_currSeq FROM dual; -- seq_attach_transact_id is a primary key that identifies every single attachment in the table
WHILE (j < pnumattach) LOOP
p_currSeq := p_currSeq - j;
SELECT blob_content INTO p_blob FROM wwdoc_document WHERE transaction_id = p_currSeq;
SELECT name INTO p_filename FROM wwdoc_document WHERE transaction_id = p_currSeq;
SELECT mime_type INTO p_filetype FROM wwdoc_document WHERE transaction_id = p_currSeq;
SEND_EMAIL_HELPER.begin_attachment(
conn => conn,
mime_type => p_filetype,
inline => TRUE,
filename => p_filename,
transfer_enc => 'base64');
-- split the Base64 encoded attachment into multiple lines
i := 1;
len := DBMS_LOB.getLength(p_blob);
WHILE (i < len) LOOP
IF(i + SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH < len)THEN
UTL_SMTP.Write_Raw_Data (conn,
UTL_ENCODE.Base64_Encode(
DBMS_LOB.SUBSTR(p_blob, SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH, i)));
ELSE
UTL_SMTP.Write_Raw_Data (conn,
UTL_ENCODE.Base64_Encode(
DBMS_LOB.SUBSTR(p_blob, (len - i)+1, i)));
END IF;
UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
i := i + SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH;
END LOOP;
SEND_EMAIL_HELPER.end_attachment(conn => conn);
END LOOP;
SEND_EMAIL_HELPER.attach_text(
conn => conn,
data => pmessage,
mime_type => 'text/html');
SEND_EMAIL_HELPER.end_mail( conn => conn );
ELSE
utl_mail.send(psender,precipients,pcc,pbcc,psubject,pmessage);
END IF;
END send;
</code>
Can anyone please tell me where am i going wrong.
Message was edited by:
MonkThe easiest is to send an e-mail with multiple attachments to yourself and then view the message in raw to see how it is formatted - how the boundaries work. what the boundary headers are, etc.
Then you use that as a template for your PL/SQL code to generate a MIME body for an e-mail that has multiple attachments.
To debug.. have your PL/SQL code send sample e-mails with multiple attachment to your account, view it in raw format and compare that to the original format you've based your template on.
And none of this is really a PL/SQL issue.. it is all about formatting a valid MIME message for an e-mail.
Maybe you are looking for
-
how do i unauthorize all computers and reauthorize without fear of losing all data, personal, and account settings. Apple says I have five already as i count four and want to add another
-
I want to re-install an older version of Flash Player but...
I hope this is the right place to ask this question... I have a new dual processor pentium laptop and I upgraded to Flash V10.1 a couple of days ago. One web site I access regularly has now slowed right down and the video is unwatchable. My CPU meter
-
Shouldnt my Macbook Pro be able to play HD?
shouldnt a MacBookPro be able to play this? I am stunned that my new Macbookpro cant play HD video content! Here is the Url, http://www.hellgatelondon.com/news/view/24/#fancy_panel I want to know is there something wrong with my Macbookpro? I plan to
-
Action Script and button Behavior
Imported a bmp as png, made it into a movie clip. Setup the AS to call for page 4. It works great. I would now like to have a text box come up on the rollover. I tried to nest the mc into a button. I can make the text box work but the script won't wo
-
Comcast Cable Internet not working with router (WRT54G), but network is fine?
My Comcast Cable Internet is not working with my router (WRT54G), but my home network is fine. The internet works without router. I have a WRT54G Wireless-G Broadband Router from Linksys. I was using Bellsouth DSL Internet up until two weeks ago. I h