Z report to alert you the latest canceled jobs

Posted on Posted in ABAP, Monitoring

Hello,

I had the necessity to check up all the jobs canceled, on the environment that we administer, in a fastest way. So I developed this report, that check which jobs was canceled in the last 24 hours and, in case of had one of it, it sends me an email. It fulfills my need.

You can schedule it to run once a day, or customize as you like.

I would like to share this report, in case of someone else need something similar.

*&———————————————————————*
*& Report ZMAILJOBSCANCEL
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT zmailjobscancel.

* data jobs
DATA: BEGIN OF wa,
job_name TYPE tbtco-jobname,
run_date TYPE tbtco-strtdate,
run_time TYPE tbtco-strttime,
job_stat TYPE tbtco-status,
END OF wa.

DATA: itab LIKE TABLE OF wa.
********

TYPES: BEGIN OF gty_s_tbtco,
job_name TYPE tbtco-jobname,
run_date TYPE tbtco-strtdate,
run_time TYPE tbtco-strttime,
job_stat TYPE tbtco-status,
END OF gty_s_tbtco.

DATA: gs_tbtco TYPE gty_s_tbtco.
** gt_tbtco TYPE TABLE OF t005t.

DATA: new_date TYPE sy-datum,
l_str TYPE string.
new_date = sy-datum – 1.

DATA :
gv_sender TYPE string, ” Sender Email Address
gv_recipient TYPE string, ” Recipients Email Address
gv_title TYPE string, ” Email Subject
gv_soli_tab TYPE soli_tab, ” Email Body
gv_soli_tab_line TYPE LINE OF soli_tab.

gv_title = ‘TITLE’.
gv_sender = ‘sender@mail.com.br’.
gv_recipient = ‘recipient@mail.com.br’.

** Select Canceled Jobs from the last 24 hours.
SELECT jobname strtdate strttime status FROM tbtco INTO TABLE itab WHERE
strtdate >= new_date AND status IN (‘A’).

IF sy-subrc <> 0.
gv_soli_tab_line = ‘None’.
APPEND gv_soli_tab_line TO gv_soli_tab.
ENDIF.

**gv_soli_tab_line = ‘—————————————————————————-‘.
**APPEND gv_soli_tab_line TO gv_soli_tab.

LOOP AT itab INTO gs_tbtco.
** WRITE:/ gs_tbtco-run_date.

CONCATENATE gs_tbtco-run_date(4) gs_tbtco-run_date+4(2) gs_tbtco-run_date+6(2) INTO l_str SEPARATED BY ‘.’.
CONCATENATE gs_tbtco-job_name’ – ‘ l_str INTO gv_soli_tab_line.

APPEND gv_soli_tab_line TO gv_soli_tab.

ENDLOOP.

** SEND MAIL
CALL FUNCTION ‘EFG_GEN_SEND_EMAIL’
EXPORTING
i_title = gv_title
i_sender = gv_sender
i_recipient = gv_recipient
i_flg_send_immediately = ‘X’
TABLES
i_tab_lines = gv_soli_tab
** I_TAB_RECIPIENTS =
“i_flg_commit = ‘X’
EXCEPTIONS
not_qualified = 1
failed = 2
OTHERS = 3.
Regards,
Richard W. L. Brehmer

Total Views: 788 ,

One thought on “Z report to alert you the latest canceled jobs

Leave a Reply

Your email address will not be published. Required fields are marked *