‎2006 Nov 30 4:23 PM
I have send an e-mail of the job logs to the enduser. How do I do that ??
‎2006 Nov 30 4:35 PM
Hi..
Try using this function module ..
&----
*& Form send_mail
&----
Subroutine to send mail
----
form send_mail.
data: l_message(150) type c, " Message line
l_gcftype like sood-objtp value 'RAW',
l_docsize type i.
Populating the subject for the email
l_message = 'List of error records in Kit Purchase Plan'(015).
x_object_hd_change-objdes = l_message.
x_object_hd_change-objla = sy-langu.
x_object_hd_change-objpri = '5'.
x_object_hd_change-objsns = 'F'.
x_object_hd_change-objlen = l_docsize.
Call function SO_OBJECT_SEND to send email
call function 'SO_OBJECT_SEND'
exporting
object_hd_change = x_object_hd_change
object_type = l_gcftype
outbox_flag = 'X'
owner = ' '
check_send_authority = ' '
tables
objcont = tb_objcont
receivers = tb_reclist
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
originator_not_exist = 20
x_error = 21
others = 22.
if sy-subrc <> 0.
case sy-subrc.
when 1.
tb_msg_list-mesg = 'active_user_not_exist'.
when 2.
tb_msg_list-mesg = 'communication_failure'.
when 3.
tb_msg_list-mesg = 'component_not_available'.
when 4.
tb_msg_list-mesg = 'folder_not_exist'.
when 5.
tb_msg_list-mesg = 'folder_no_authorization'.
when 6.
tb_msg_list-mesg = 'forwarder_not_exist'.
when 7.
tb_msg_list-mesg = 'note_not_exist'.
when 8.
tb_msg_list-mesg = 'object_not_exist'.
when 9.
tb_msg_list-mesg = 'object_not_sent'.
when 10.
tb_msg_list-mesg = 'object_no_authorization'.
when 11.
tb_msg_list-mesg = 'object_type_not_exist'.
when 12.
tb_msg_list-mesg = 'operation_no_authorization'.
when 13.
tb_msg_list-mesg = 'owner_not_exist'.
when 14.
tb_msg_list-mesg = 'parameter_error'.
when 15.
tb_msg_list-mesg = 'substitute_not_active'.
when 16.
tb_msg_list-mesg = 'substitute_not_defined'.
when 17.
tb_msg_list-mesg = 'system_failure'.
when 18.
tb_msg_list-mesg = 'too_much_receivers'.
when 19.
tb_msg_list-mesg = 'user_not_exist'.
when 20.
tb_msg_list-mesg = 'originator_not_exist'.
when 21.
tb_msg_list-mesg = 'x_error'.
when 22.
tb_msg_list-mesg = 'others'.
endcase.
tb_msg_list-type = c_e.
append tb_msg_list.
clear tb_msg_list.
else.
loop at tb_reclist.
if tb_reclist-rcode = 0.
tb_msg_list-type = c_s.
concatenate 'Mail sent successfully to'(016)
tb_reclist-adr_name
into tb_msg_list-mesg
separated by space.
else.
tb_msg_list-type = c_e.
concatenate 'Mail could not be sent to'(017)
tb_reclist-adr_name
into tb_msg_list-mesg
separated by space.
endif.
append tb_msg_list.
clear tb_msg_list.
endloop.
endif.
endform. " send_mail
Regards,
Jayaram..
‎2006 Nov 30 4:56 PM
Hi Jayaram,
How do I define x_object_hd_change ?? ... I wrote
DATA : x_object_hd_change LIKE SOOD1(216) but it is giving syntax error.
‎2011 Mar 16 3:20 AM
‎2006 Nov 30 4:35 PM
U can read the log using FM BP_JOBLOG_READ
and email the same to user using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 as an attachment.
Regards
Anurag
‎2006 Nov 30 4:45 PM
Hi Anurag,
& What paramaters do I pass to both of the FM's??
-SB.
Message was edited by:
S B
‎2006 Nov 30 4:52 PM
FM
CALL FUNCTION 'BP_JOBLOG_READ'
EXPORTING
CLIENT = SY-MANDT
JOBCOUNT = "JOB COUNT
JOBNAME = "JOBNAME
TABLES
JOBLOGTBL = DATATBL.
Also you can get the job overview from TBTCO table.
Please assign points for helpful answers!!
Message was edited by:
Anurag Bankley
‎2006 Nov 30 4:56 PM
FM for Email
form SEND_EMAIL tables IT_MESSAGE type T_MESSAGE.
data: IS_DOCDATA type SODOCCHGI1,
IS_RECEIVERS type SOMLRECI1,
IS_RECEIVERS_COPY type SOMLRECI1,
IT_RECEIVERS type table of SOMLRECI1,
IS_CONTENT type SOLISTI1,
IT_CONTENT type table of SOLISTI1,
*500369789+
l_txt(255) type c,
lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
l_tab_lines TYPE i,
l_att_type LIKE soodk-objtp.
*500369789+
IS_DOCDATA-OBJ_NAME = 'MAIL'.
IS_DOCDATA-PRIORITY = 5.
IS_DOCDATA-OBJ_LANGU = SY-LANGU.
IS_DOCDATA-NO_CHANGE = 'X'.
IS_DOCDATA-OBJ_DESCR = SY-CPROG.
loop at IT_MESSAGE into IS_MESSAGE.
clear : IS_CONTENT, l_txt. "500369789+
move is_message-line to l_txt. "500369789+
move IS_MESSAGE-LINE to IS_CONTENT-LINE. "500369789-
move l_txt to IS_CONTENT-LINE. "500369789+
append IS_CONTENT to IT_CONTENT.
endloop.
*---select_email_address
select single
EMAILADDR
CCEMAILADDR
into (IS_RECEIVERS-RECEIVER, IS_RECEIVERS_COPY-RECEIVER)
from ZGL_EMAILCTRL
where IDENT = ''
and ZPROGRAM = 'Z_L_SO_CREA'
and ACTIVE = 'X'.
if IS_RECEIVERS-RECEIVER is not initial.
IS_RECEIVERS-REC_TYPE = 'U'.
IS_RECEIVERS_COPY-REC_TYPE = 'U'.
IS_RECEIVERS_COPY-COPY = 'X'.
append IS_RECEIVERS to IT_RECEIVERS.
append IS_RECEIVERS_COPY to IT_RECEIVERS.
*500369789+
lt_objhead-line = 'USA Order Report'.
append lt_objhead.
DESCRIBE TABLE lt_objhead LINES l_tab_lines.
CLEAR lt_objpack-transf_bin.
lt_objpack-doc_size = STRLEN( lt_objhead ).
lt_objpack-head_start = 1.
lt_objpack-head_num = 1.
lt_objpack-body_start = 1.
lt_objpack-body_num = 1.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
l_att_type = 'RAW'.
DESCRIBE TABLE it_content LINES l_tab_lines.
READ TABLE it_content into is_content INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255.
lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( is_content ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 2.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'ATTACHMENT'.
concatenate 'Usa' SY-DATUM6(2) SY-DATUM4(2) into
lt_objpack-obj_descr. "#EC *
APPEND lt_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = IS_DOCDATA
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_txt = lt_objhead
contents_bin = it_content
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.
endform.