‎2008 Oct 29 10:12 AM
hi all,
the report displays some PO data, this report run by an ESPBATCH JOB every friday.
now the final data is in the final internal table gt_final.
if the job does not finish successfully , a message should be sent to the some of the email address given in the selection screen.
AS report could not be generated.
please tell me how to run the report as ESPBATCH JOB
and If the job does not run how to send email to the mail address given in the selection screen.
the code i have writeen till the final internal table.
please help with code if possible
‎2008 Oct 29 11:12 AM
Hi SL,
end-of-selection.
if not gt_final[] is initial.
*recipient email id
PERFORM reciever_list.
*fill the content of mail
PERFORM populate_email_ref_data .
*finally send mail
PERFORM mail_send.
endif.
&----
*& Form reciever_list
&----
text
----
--> p1 text
<-- p2 text
----
FORM reciever_list .
gt_reclist-receiver = email-id1.
gt_reclist-rec_type = 'U'.
APPEND gt_reclist.
GT_RECLIST-RECEIVER = email-id2.
GT_RECLIST-REC_TYPE = 'U'.
APPEND GT_RECLIST.
ENDFORM. " reciever_list
&----
*& Form POPULATE_EMAIL_REF_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM populate_email_ref_data .
*Populating body of the mail
gt_objtxt-line = ' report could not be generated'.
DESCRIBE TABLE gt_objtxt LINES g_tab_lines.
Creating the entry for the compressed document
CLEAR gt_objpack-transf_bin.
gt_objpack-transf_bin = ' '.
gt_objpack-head_start = 1.
gt_objpack-head_num = 0.
gt_objpack-body_start = 1.
gt_objpack-body_num = g_tab_lines.
gt_objpack-doc_type = 'RAW'.
APPEND gt_objpack.
ENDFORM. " POPULATE_EMAIL_REF_DATA
&----
*& Form mail_send
&----
text
----
--> p1 text
<-- p2 text
----
FORM mail_send .
Sending the mail with attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = t_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = gt_objpack
object_header = gt_objhead
contents_bin = gt_objbin
contents_txt = gt_objtxt
receivers = gt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
TRY THIS..
need some changes also as per ur req.
thnx Rohit
‎2008 Oct 29 12:08 PM
i think ESPBATCH JOB this is a functional module where incase any problem occurs then it might be returning some error value at that time check condition & if it is true u can send mail using standard mail programs and before that create a customing table where u can store a bunch of emails & can read that into internal table and then u can send them mail