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 tbtcojobname,

   run_date TYPE tbtcostrtdate,

   run_time TYPE tbtcostrttime,

   job_stat TYPE tbtcostatus,

   END OF wa.

DATA: itab LIKE TABLE OF wa.

********

TYPES: BEGIN OF gty_s_tbtco,

   job_name TYPE tbtcojobname,

   run_date TYPE tbtcostrtdate,

   run_time TYPE tbtcostrttime,

   job_stat TYPE tbtcostatus,

   END OF gty_s_tbtco.

DATA: gs_tbtco TYPE gty_s_tbtco.

**  gt_tbtco TYPE TABLE OF t005t.

DATA: new_date TYPE sydatum,

       l_str TYPE string.

       new_date = sydatum 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 sysubrc <> 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_tbtcorun_date(4) gs_tbtcorun_date+4(2) gs_tbtcorun_date+6(2) INTO l_str SEPARATED BY ‘.’.

   CONCATENATE gs_tbtcojob_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

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply