11-11-2005 7:40 AM
11-11-2005 9:19 AM
Hi,
If you smartform,then you can send the output as attachment in pdf through mail.
Check this link and reward points by clicking the star on the left of reply,if it helps.
11-11-2005 7:46 AM
Mavrick,
You can send the report to print spool, read the spool from there convert that into PDF and send it as a mail using the function below.
Or you can directly attach the output as you will have that in an internal table using the function module.
SO_NEW_DOCUMENT_ATT_SEND_API1.
Please close your previous posts and award points for the posts that have helped you.
Regards,
Ravi
11-11-2005 8:10 AM
Hi Mavrick,
You need to associate the exchange server to the SAP system to send the mail outsise. This is called SAPconnect. You can use transaction SCOT in R/3 system. Contact your basis team about setting up this.
Also, pls make sure that your user id has a valid email address attached to it via Transaction SU01.
Now check out these links for sample codes:
http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
http://www.sapgenie.com/abap/code/abap31.htm
/people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface, for 46D and lower
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface, for 610 and higher
http://www.sap-img.com/fu016.htm
Best Regards,
Anjali
11-11-2005 8:57 AM
Hi,
If you want to send a report in background to mail.
Refer this link.
http://www.sap-img.com/abap/sending-mail-with-attachment-report-in-background.htm
Regards,
Sailaja.
11-11-2005 9:19 AM
Hi,
If you smartform,then you can send the output as attachment in pdf through mail.
Check this link and reward points by clicking the star on the left of reply,if it helps.
11-11-2005 9:27 AM
sorry friends i am not clear with the answers i got.I have some 10 lines of report output in the list format which i have send to mail ( ex: Yahoo ).... Its appreciated if anyone can provide the simplest solution for this.... Can anyone pls give the code for that...
11-11-2005 9:38 AM
Hi mavric,
check this links it may help you...
http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
reward points for helpfull answers and close the thread if your question is solved.
regards,
venu.
11-11-2005 9:38 AM
Hi,
In output,you will be having a option list->send to->mail receipient
Try that.
Kindly reward points if it helps by clicking the star on the left of reply.
11-11-2005 9:53 AM
Hi Mavrick,
If u want to send only the ouput data to mail then fill the data to internal table(IT_MAIL) and use the below code.
Hope this helps u.
&----
*& Form F_SEND_MAIL
&----
Send the mail to SAP inbox for corresponding user
----
FORM F_SEND_MAIL.
DATA : LV_TABLE_LINES LIKE SY-TABIX. " table index
CLEAR: V_MSG1, IT_RECLIST.
REFRESH IT_RECLIST.
*-popualate email ids
IT_RECLIST-RECEIVER = V_UNAME.
IT_RECLIST-REC_TYPE = 'B'.
IT_RECLIST-SAP_BODY = C_X.
IT_RECLIST-EXPRESS = C_X.
*-append receiver table
APPEND IT_RECLIST.
CLEAR IT_RECLIST.
*-populate document attributes
CLEAR: X_DOC_CHNG.
X_DOC_CHNG-OBJ_NAME = 'Error'(M01).
X_DOC_CHNG-OBJ_DESCR = 'ERROR REPORT'(M02).
*-populate body text
IT_OBJTXT = 'Error file is attached'(M03).
APPEND IT_OBJTXT.
*-document size
CLEAR : LV_TABLE_LINES.
DESCRIBE TABLE IT_OBJTXT LINES LV_TABLE_LINES.
READ TABLE IT_OBJTXT INDEX LV_TABLE_LINES.
X_DOC_CHNG-DOC_SIZE =
( LV_TABLE_LINES - 1 ) * 255 + STRLEN( IT_OBJTXT ).
*-populate packing list for body text
CLEAR IT_OBJPACK-TRANSF_BIN.
IT_OBJPACK-HEAD_START = 1.
IT_OBJPACK-HEAD_NUM = 0.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = LV_TABLE_LINES.
IT_OBJPACK-DOC_TYPE = C_DOCTYP.
APPEND IT_OBJPACK.
CLEAR IT_OBJPACK.
*-populate object header
IT_OBJHEAD = 'INET TO SAP Error Report'(M04).
APPEND IT_OBJHEAD.
CLEAR IT_OBJHEAD.
*--for attachment ---start
*-populate object bin table for attachment
*-column header
LOOP AT IT_MAIL.
IT_OBJBIN = IT_MAIL.
APPEND IT_OBJBIN.
CLEAR IT_OBJBIN.
ENDLOOP.
*-get total no.of lines of Object table(attachment)
CLEAR : LV_TABLE_LINES.
DESCRIBE TABLE IT_OBJBIN LINES LV_TABLE_LINES.
*-populate object header
IT_OBJHEAD = 'Report'(M05).
APPEND IT_OBJHEAD.
CLEAR IT_OBJHEAD.
*-packing list for attachment
IT_OBJPACK-TRANSF_BIN = C_X.
IT_OBJPACK-HEAD_START = 1.
IT_OBJPACK-HEAD_NUM = 1.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = LV_TABLE_LINES .
IT_OBJPACK-DOC_TYPE = C_DOCTYP .
IT_OBJPACK-OBJ_NAME = 'ABCD'.
IT_OBJPACK-OBJ_DESCR = 'ERROR REPORT'(M02).
IT_OBJPACK-DOC_SIZE = LV_TABLE_LINES * 255.
APPEND IT_OBJPACK.
CLEAR IT_OBJPACK.
*--code for attachment -- end
*-Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = X_DOC_CHNG
PUT_IN_OUTBOX = C_X
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = IT_OBJPACK
OBJECT_HEADER = IT_OBJHEAD
CONTENTS_BIN = IT_OBJBIN
CONTENTS_TXT = IT_OBJTXT
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
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 INTO V_MSG1.
MESSAGE I000 WITH V_MSG1.
ENDIF.
ENDFORM. " F_SEND_MAIL
&----
*& Form F_FILL_MAILDATA
&----
Fill the data which needs to be sent in mail
----
FORM F_FILL_MAILDATA USING P_MSG.
IT_MAIL-MSG = P_MSG.
MOVE-CORRESPONDING IT_INFILE TO IT_MAIL.
APPEND IT_MAIL.
CLEAR IT_MAIL.
ENDFORM. " F_FILL_MAILDATA
11-11-2005 9:54 AM
Hi Mavrick,
Pls edit the mail id..before executing.
*&---------------------------------------------------------------------*
*& Report ZSENDEMAIL *
*& *
*&---------------------------------------------------------------------*
*& Example of sending external email via SAPCONNECT *
*& *
*&---------------------------------------------------------------------*
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Testing',
p_email(40) type c default 'anjali.devi@wipro.com'.
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*&---------------------------------------------------------------------*
*& Form POPULATE_MESSAGE_TABLE
*&---------------------------------------------------------------------*
* Adds text to email text table
*----------------------------------------------------------------------*
form populate_message_table.
Append 'Line1' to it_message.
Append 'Line2' to it_message.
Append 'Line3' to it_message.
Append 'Test- 1' to it_message.
endform. " POPULATE_MESSAGE_TABLE
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
* Send email message
*----------------------------------------------------------------------*
form send_email_message.
* Fill the document data.
gd_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
* Describe the body of the message
* Information about structure of data tables
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
* Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
append it_receivers.
* Call the FM to post the message to SAPMAIL
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
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.
* Store function module return code
gd_error = sy-subrc.
* Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------
* Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
*
You have lots of sample codes in the above links.
If your SAPCONNECT is proper, it will trigger a mail.
Regards,
Anjali
11-11-2005 9:56 AM
*-popualate email ids
IT_RECLIST-RECEIVER = V_UNAME.
U can use how many user id's u want either external email ids(yahoo) or internal (SAP inbox).Fill the value in V_UNAME and append to IT_RECLIST internal table
11-11-2005 9:25 AM
Hi Mavrick,
If you are interested in sending only the data and not the format and layout in which the data is being printed,
then you can directly use the FM
SO_NEW_DOCUMENT_SEND_API1, passing the internal table with the data to be printed in the report.
Regards,
Ravi