07-20-2009 7:35 AM
+
Dear all ,+
+I am using this Program for sending email through SAP.This Program is working fine, finally i got the message Successfully mail sent.+
+But i checked my external mail id (yahoo) , what i had to sent that is not there in mail .+
+where shall i check the Error? could u explain me.+
----
" Data retrieval related declarations
----
types:
begin of t_emp_dat,
pernr type pa0001-pernr,
persg type pa0001-persg,
persk type pa0001-persk,
plans type pa0001-plans,
stell type pa0001-stell,
end of t_emp_dat.
data:
w_emp_data type t_emp_dat.
data:
i_emp_data type standard table of t_emp_dat.
----
" Mail related declarations
----
"Variables
data :
g_sent_to_all type sonv-flag,
g_tab_lines type i.
"Types
types:
t_document_data type sodocchgi1,
t_packing_list type sopcklsti1,
t_attachment type solisti1,
t_body_msg type solisti1,
t_receivers type somlreci1.
"Workareas
data :
w_document_data type t_document_data,
w_packing_list type t_packing_list,
w_attachment type t_attachment,
w_body_msg type t_body_msg,
w_receivers type t_receivers.
"Internal Tables
data :
i_document_data type standard table of t_document_data,
i_packing_list type standard table of t_packing_list,
i_attachment type standard table of t_attachment,
i_body_msg type standard table of t_body_msg,
i_receivers type standard table of t_receivers.
parameters:p_mail type char120.
----
"Start-of-selection.
----
start-of-selection.
perform get_data.
perform build_xls_data_table.
----
"End-of-selection.
----
end-of-selection.
perform send_mail.
&----
"Form get_data from PA0001
&----
form get_data.
select pernr
persg
persk
plans
stell
from pa0001
into corresponding fields of table i_emp_data
up to 4 rows.
endform. " get_data
&----
"Form build_xls_data_table
&----
form build_xls_data_table.
"If you have Unicode check active in program attributes then
"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 'PERNR' 'PERSG' 'PERSK' 'PLANS' 'STELL'
into w_attachment
separated by con_tab.
concatenate con_cret
w_attachment
into w_attachment.
append w_attachment to i_attachment.
clear w_attachment.
loop at i_emp_data into w_emp_data.
concatenate w_emp_data-pernr
w_emp_data-persg
w_emp_data-persk
w_emp_data-plans
w_emp_data-stell
into w_attachment
separated by con_tab.
concatenate con_cret w_attachment
into w_attachment.
append w_attachment to i_attachment.
clear w_attachment.
endloop.
endform. "build_xls_data_table
&----
"Form send_mail
"----
"PACKING LIST
"This table requires information about how the data in the
"tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are to
"be distributed to the documents and its attachments.The first
"row is for the document, the following rows are each for one
"attachment.
&----
form send_mail .
"Subject of the mail.
w_document_data-obj_name = 'MAIL_TO_HEAD'.
w_document_data-obj_descr = 'Regarding Mail Program by SAP ABAP'.
"Body of the mail
perform build_body_of_mail
using:space,
'Hi,',
'I am fine. How are you? How are you doing ? ',
'This program has been created to send simple mail',
'with Subject,Body with Address of the sender. ',
'Regards,',
'Venkat.O,',
'SAP HR Technical Consultant.'.
"Write Packing List for Body
describe table i_body_msg lines g_tab_lines.
w_packing_list-head_start = 1.
w_packing_list-head_num = 0.
w_packing_list-body_start = 1.
w_packing_list-body_num = g_tab_lines.
w_packing_list-doc_type = 'RAW'.
append w_packing_list to i_packing_list.
clear w_packing_list.
"Write Packing List for Attachment
w_packing_list-transf_bin = 'X'.
w_packing_list-head_start = 1.
w_packing_list-head_num = 1.
w_packing_list-body_start = 1.
describe table i_attachment lines w_packing_list-body_num.
w_packing_list-doc_type = 'XLS'.
w_packing_list-obj_descr = 'Excell Attachment'.
w_packing_list-obj_name = 'XLS_ATTACHMENT'.
w_packing_list-doc_size = w_packing_list-body_num * 255.
append w_packing_list to i_packing_list.
clear w_packing_list.
"Fill the document data and get size of attachment
w_document_data-obj_langu = sy-langu.
read table i_attachment into w_attachment index g_tab_lines.
w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + strlen( w_attachment ).
"Receivers List.
w_receivers-rec_type = 'U'. "Internet address
w_receivers-receiver = p_mail.
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
append w_receivers to i_receivers .
clear:w_receivers.
"Function module to send mail to Recipients
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = w_document_data
put_in_outbox = 'X'
commit_work = 'X'
importing
sent_to_all = g_sent_to_all
tables
packing_list = i_packing_list
contents_bin = i_attachment
contents_txt = i_body_msg
receivers = i_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 i303(me) with 'Mail has been Successfully Sent.'.
else.
wait up to 2 seconds.
"This program starts the SAPconnect send process.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " send_mail
&----
" Form build_body_of_mail
&----
form build_body_of_mail using l_message.
w_body_msg = l_message.
append w_body_msg to i_body_msg.
clear w_body_msg.
endform. " build_body_of_mail
Regards ,
Shankar GJ
07-20-2009 7:38 AM
Hi Shankar,
Please format ur code.Its a bit confusing.
Check in SBWP SAP Business Work Place >u can find the status of the sent mails in Outbox.chk whether it is sent successfully or not.
Else chk tcode SCOT for configuration done correctly or not.
Regards,
Lakshman.
07-20-2009 7:37 AM
Dear,
Please check the configuration in SCOT.
If u want check the status of sent mail use transction SOST.
Regards
07-20-2009 7:38 AM
Hi Shankar,
Please format ur code.Its a bit confusing.
Check in SBWP SAP Business Work Place >u can find the status of the sent mails in Outbox.chk whether it is sent successfully or not.
Else chk tcode SCOT for configuration done correctly or not.
Regards,
Lakshman.
07-20-2009 7:40 AM
hi shankar,
the code is not very clear to read. so please put in proper format.
but any ways.
1. check SOST if you can see the sent mail there or not.
2. if its there in SOSt that means mail is ready to be sent. program is working. next part is SCOT. check scot setting for SMTP. see if it is set correctly or not. contact BASIS guys for this
07-20-2009 7:55 AM
Dear all ,
Thanks for ur Valuable answers.
Then i checked the Status in this T-code - SOST
Its showing Warning Msg : Waiting for communication service
Can u explain me what the next steps i need to do.
Thanks ,
Shankar GJ
07-20-2009 7:57 AM
it might be because:
your SCOT settings are either missing or intentionally disabled by your BASIS guys.
talk to them to check SMTP settings in SCOT
07-20-2009 7:59 AM
for checking from your end:
goto SCOT.
double click on SMTP.
check settings for
Mail Host
Mail Port
07-20-2009 8:00 AM
07-20-2009 8:05 AM
rsconn1 is a very dangerous program. it will trigger all the pending mails even those which are not triggered by you. Please talk to BASIS guys regarding this before taking steps...
07-20-2009 8:06 AM
Dear all ,
Thanks for ur Valuable answers.
Then i checked the Status in this T-code - SOST
Its showing Warning Msg : Waiting for communication service
Can u explain me what the next steps i need to do.
Thanks ,
Shankar GJ
07-20-2009 8:09 AM
Hi,
Ok, If you do not want to send all the mails, then in SOST click on the mail which you want to send then click on "Start send process". This will send only the mail which you selected
Regards
07-20-2009 8:11 AM
07-20-2009 8:15 AM
Dear all ,
Thanks for ur inputs.
My end i checked Mail server and Mail Host . Its maintained correctly. I have to ask basics Consultants .
Thanks to Evryone.
Regards ,
Shankar
07-20-2009 7:42 AM
Hi Shankar,
You should enter the email address in
i_receivers.
Hope this helps.
Benedict
07-20-2009 7:43 AM
Dear Shankar,
check your settings in SCOT & SICF
Check the domain in scot.
instead of yahoo,give the outlook id which is in the domain of scot.
Regards
Sajid
07-20-2009 7:43 AM
07-20-2009 7:48 AM
Hi Shankar,
There is a cofiguration that needs to be done so that SAP can send emails externally. Not sure though who to ask regarding these kinds of issues... BASIS or FUNCTIONALS.
Hope this help.
Benedict
07-20-2009 8:01 AM
Dear shankar ,
please check the reciver List . u did not specify any reciver e-mail id . /Receivers List. w_receivers-rec_type = 'U'./
i_reclist-receiver = sy-uname.
i_reclist-rec_type = 'B'. " for mail within SAP "
+*i_reclist-rec_type = 'U'."for external mail. "+
for sending external mails your mail server should configure . other wise your mail will in the waiting for communication status in SOST.
for configurating look at the link .
[http://mysapinkpot.blogspot.com/2007/11/configuration-sending-mails-from-sap.html]
thanks,
chinnaiya P
07-20-2009 8:11 AM
Hi ,
Take help of a BASIS guy ,check SOST SCOT t-codes ,
Please let me know if you still need any more help.
Thanks and regards,
Rajeshwar
07-20-2009 8:17 AM
Hi Shankar,
Change above code like below and check Inbox in the transaction SBWP. If you get mail then some configuration needs to be done.
"Receivers List.
w_receivers-rec_type = 'U'. "Internet address
w_receivers-receiver = p_mail.
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
append w_receivers to i_receivers .
clear:w_receivers.
Thanks
Venkat.O "Receivers List.
w_receivers-rec_type = 'B'.
w_receivers-receiver = <sap_login_user_id> "Give your SAP User ID.
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
append w_receivers to i_receivers .
clear:w_receivers.