Proposal:


Sometimes we may be struggling to find out all the list of Direct & Event scheduled process chains. Also as part of SAP BW Support activity, during GMW (Global Maintenance Window) we are carrying few activities manually which needs to be done before the start date of GMW. Analyzing and de-scheduling the process chains (PC) depends upon the down-time duration of the GMW falls under this activity. It takes long time for identifying the process chains which are Direct or Start using Meta chain/API. So here I have developed a ABAP code to get the list.


Benefits:


Using this program we can achieve the following advantages:


  1. Easily gets the list of direct scheduled chains in a click which should be De-scheduled within the downtime window.
  2. Minimize the manual work like checking the individual chains whether it’s direct or meta/API scheduled and then De-scheduling it. Instead we can directly go to the chain and De-schedule it.
  3. Fatigue will be null as there won’t be repeated work like checking the each and every process chains.


Program:


” user interface screen declarations start

selection-screen begin of block block1 with frame title text001.

selection-screen comment 1(55) text007 .

selection-screen begin of line .
selection-screen comment 1(12) text002 .
parameters: str_date type sydatum default sydatum .
selection-screen comment 30(12) text003 .
parameters: end_date type sydatum default sydatum .
selection-screen end of line .

selection-screen begin of line .
selection-screen comment 1(12) text004 .
parameters: str_time type syuzeit default ‘000000’ .
selection-screen comment 30(12) text005 .
parameters: end_time type syuzeit default ‘235959’ .
selection-screen end of line .

selection-screen skip.

selection-screen begin of line .
selection-screen comment 1(39) text006 .
selection-screen position 50.
parameters: cb_dir as checkbox .
selection-screen end of line .

selection-screen begin of line .
selection-screen comment 1(38) text008 .
selection-screen position 50.
parameters: cb_event as checkbox .
selection-screen end of line   .

selection-screen end of block block1 .

” user interface screen declarations end
*************************************************************************

” Data type & table declarations start

types: begin of l_s_scheduled,
jobname           type tbtcojobname,
jobcount          type tbtcojobcount,
sdlstrtdt         type tbtcosdlstrtdt,
sdlstrttm         type tbtcosdlstrttm,
eventid           type tbtcoeventid ,
hourly            type tbtcoprdhours ,
daily             type tbtcoprddays ,
weekly            type tbtcoprdweeks ,
monthly           type tbtcoprdmonths ,
progname          type tbtcpprogname,
variant           type tbtcpvariant,
chain             type rspc_chain,
parent_chain(30type c ,
datetime_str(14type c ,
datetime_end(14type c ,
end of l_s_scheduled.

data: l_t_scheduled type standard table of l_s_scheduled,
wa_scheduled type l_s_scheduled,
l_t_valtab    type standard table of rsparams .

data:
l_w_valtab          type rsparams,
lv_date             type rspclogchaindatum ,
lv_time             type rspclogchainzeit ,
lv_datetime_str(14) type c,
lv_datetime_end(14) type c,
lv_dst              type abap_bool,
lv_timestamp        type rspcprocesslogendtimestamp ,
date(19)            type c ,
time(17)            type c ,
frequency(10)       type c ,
lv_event(30)        type c ,
lv_date_time(14)    type c ,
lv_next_date(10)    type c ,
lv_next_time(8)     type c ,
lv_last_date(10)    type c ,
lv_last_time(10)    type c ,
lv_datetime_remark  type timestamp ,
lv_check_end        type rspcprocesslogendtimestamp ,
lv_datetime_dummy(14) type c ,
lv_check_end_dummy(14) type c .

field-symbols    <l_f_scheduled> type l_s_scheduled.

” Data type & table declarations end
*************************************************************************

” Get data based on user selections start

concatenate end_date end_time into lv_check_end_dummy .
move lv_check_end_dummy to lv_check_end .

” If requirement is to show based on specific date and time
if cb_dir <> ‘X’ and cb_event <> ‘X’ .

   select a~jobname a~jobcount a~sdlstrtdt a~sdlstrttm a~eventid a~prdhours a~prddays a~prdweeks a~prdmonths b~progname b~variant
   into    corresponding fields of table l_t_scheduled
   from    tbtco as a join tbtcp as b
   on      a~jobname = b~jobname
   and     a~jobcount = b~jobcount
   where   a~jobname = ‘BI_PROCESS_TRIGGER’
   and     a~status = ‘S’  “Scheduled
   and     a~sdlstrtdt >= str_date and a~sdlstrtdt <= end_date .

   concatenate str_date str_time into lv_datetime_str .
   concatenate end_date end_time into lv_datetime_end .

   loop at l_t_scheduled into wa_scheduled .
     concatenate wa_scheduledsdlstrtdt wa_scheduledsdlstrttm into wa_scheduleddatetime_str .
     concatenate wa_scheduledsdlstrtdt wa_scheduledsdlstrttm into wa_scheduleddatetime_end .
     modify l_t_scheduled from wa_scheduled .
   endloop .

   delete l_t_scheduled where datetime_str < lv_datetime_str .
   delete l_t_scheduled where datetime_end >  lv_datetime_end .

   ” If requirement is to show all direct and event scheduled chains
elseif cb_event = ‘X’ and cb_dir = ‘X’ .

   select  a~jobname a~jobcount a~sdlstrtdt a~sdlstrttm a~eventid a~prdhours a~prddays a~prdweeks a~prdmonths b~progname b~variant
   into    corresponding fields of table l_t_scheduled
   from    tbtco as a join tbtcp as b
   on      a~jobname = b~jobname and
           a~jobcount = b~jobcount
   where   a~jobname = ‘BI_PROCESS_TRIGGER’
   and     a~status = ‘S’ . “Scheduled

   ” If requirement is to show all direct scheduled chains
elseif cb_dir = ‘X’ and cb_event <> ‘X’ .

   select  a~jobname a~jobcount a~sdlstrtdt a~sdlstrttm a~eventid a~prdhours a~prddays a~prdweeks a~prdmonths b~progname b~variant
   into    corresponding fields of table l_t_scheduled
   from    tbtco as a join tbtcp as b
   on      a~jobname = b~jobname and
           a~jobcount = b~jobcount
   where   a~jobname = ‘BI_PROCESS_TRIGGER’
   and     a~status = ‘S’ . “Scheduled

   delete l_t_scheduled where eventid <> ‘ ‘ .

   ” If requirement is to show all event scheduled chains
elseif cb_event = ‘X’ and cb_dir <> ‘X’ .

   select  a~jobname a~jobcount a~sdlstrtdt a~sdlstrttm a~eventid a~prdhours a~prddays a~prdweeks a~prdmonths b~progname b~variant
   into    corresponding fields of table l_t_scheduled
   from    tbtco as a join tbtcp as b
   on      a~jobname = b~jobname and
           a~jobcount = b~jobcount
   where   a~jobname = ‘BI_PROCESS_TRIGGER’
   and     a~status = ‘S’ . “Scheduled

   delete l_t_scheduled where sdlstrtdt <> ‘ ‘ .

endif.

sort l_t_scheduled by sdlstrtdt sdlstrttm ascending.

” Get data based on user selections end
*************************************************************************

” write the output on screen in table format start

uline (163).

write :/ ‘|’ , ‘                         ‘, ‘|’ ,‘      Last Run         ‘, ‘|’ ,
‘      Next Run         ‘ , ‘|’ , ‘                                                                               ‘ , ‘|’ .

uline (163).

write :/ ‘|’ , ‘Chain Name               ‘, ‘|’ ,‘Start Date’, ‘|’, ‘Start Time’ , ‘|’ , ‘Start Date’, ‘|’, ‘Start Time’
, ‘|’ , ‘Parent Chain                  ‘ , ‘|’ , ‘Event ID                        ‘ , ‘|’  , ‘Frequency  ‘ , ‘|’  .

new-line .

uline (163).

” Pass the parameter to get Process chain name start
loop at l_t_scheduled assigning <l_f_scheduled>.
   refresh l_t_valtab.
   call function ‘RS_VARIANT_CONTENTS’
     exporting
       report               = <l_f_scheduled>progname
       variant              = <l_f_scheduled>variant
     tables
       valutab              = l_t_valtab
     exceptions
       variant_non_existent = 1
       variant_obsolete     = 2
       others               = 3.
   if sysubrc = 0.
     read table l_t_valtab into l_w_valtab
     with key selname = ‘CHAIN’.
     if sysubrc = 0.
       <l_f_scheduled>chain = l_w_valtablow.
     endif.

     ” Take last run process chains details start
     select datum zeit from rspclogchain into (lv_date, lv_time) up to 1 rows
       where     chain_id = <l_f_scheduled>chain
       order by  datum descending zeit descending .
     endselect.

     concatenate lv_date lv_time into lv_date_time.
     move lv_date_time to lv_timestamp .

     ” Convert timestamp sysdate to correct time.
     convert time stamp lv_timestamp time zone syzonlo
     into date lv_date time lv_time
     daylight saving time lv_dst.

     concatenate lv_date+6(2) ‘.’ lv_date+4(2) ‘.’ lv_date+0(4) into lv_last_date .
     concatenate lv_time+0(2) ‘:’ lv_time+2(2) ‘:’ lv_time+4(2) into lv_last_time .

     ” If process chain is event triggered get the event ID and other details
     if <l_f_scheduled>eventid is not initial and <l_f_scheduled>sdlstrtdt = ‘ ‘ and <l_f_scheduled>sdlstrttm = ‘ ‘ .
       lv_next_date = ‘Event’ .
       lv_next_time = ‘Event’ .
       clear lv_event .
       select variante from rspcvariant into lv_event where fnam = ‘EVENT’ and low = <l_f_scheduled>eventid .
       endselect .
       select chain_id from rspcchain into <l_f_scheduled>parent_chain where type = ‘ZEVENT’ and objvers = ‘A’ and variante = lv_event .
       endselect.

       ” else get print the date and time stamp
     else .
       move <l_f_scheduled>sdlstrtdt to date .
       concatenate date+6(2) ‘.’ date+4(2) ‘.’ date+0(4) into lv_next_date .
       move <l_f_scheduled>sdlstrttm to time .
       concatenate time+0(2) ‘:’ time+2(2)‘:’ time+4(2) into lv_next_time .
     endif .

     concatenate <l_f_scheduled>sdlstrtdt <l_f_scheduled>sdlstrttm into lv_datetime_dummy .
     move lv_datetime_dummy to lv_datetime_remark .

     write :‘|’ , <l_f_scheduled>chain, ‘|’, lv_last_date, ‘|’ lv_last_time ,
      ‘|’ , lv_next_date, ‘|’ lv_next_time , ‘  |’ <l_f_scheduled>parent_chain , ‘|’ , <l_f_scheduled>eventid , ‘|’  , frequency , ‘ |’ .

   endif.
   uline (163).

endloop.
new-line .

Text Symbols:

4.JPG


Result:


1.JPG

User input:

/wp-content/uploads/2016/05/2_963199.png/wp-content/uploads/2016/05/3_963200.png



To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply