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:
- Easily gets the list of direct scheduled chains in a click which should be De-scheduled within the downtime window.
- 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.
- 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 text–001.
selection-screen comment 1(55) text–007 .
selection-screen begin of line .
selection-screen comment 1(12) text–002 .
parameters: str_date type sy–datum default sy–datum .
selection-screen comment 30(12) text–003 .
parameters: end_date type sy–datum default sy–datum .
selection-screen end of line .
selection-screen begin of line .
selection-screen comment 1(12) text–004 .
parameters: str_time type sy–uzeit default ‘000000’ .
selection-screen comment 30(12) text–005 .
parameters: end_time type sy–uzeit default ‘235959’ .
selection-screen end of line .
selection-screen skip.
selection-screen begin of line .
selection-screen comment 1(39) text–006 .
selection-screen position 50.
parameters: cb_dir as checkbox .
selection-screen end of line .
selection-screen begin of line .
selection-screen comment 1(38) text–008 .
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 tbtco–jobname,
jobcount type tbtco–jobcount,
sdlstrtdt type tbtco–sdlstrtdt,
sdlstrttm type tbtco–sdlstrttm,
eventid type tbtco–eventid ,
hourly type tbtco–prdhours ,
daily type tbtco–prddays ,
weekly type tbtco–prdweeks ,
monthly type tbtco–prdmonths ,
progname type tbtcp–progname,
variant type tbtcp–variant,
chain type rspc_chain,
parent_chain(30) type c ,
datetime_str(14) type c ,
datetime_end(14) type 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 rspclogchain–datum ,
lv_time type rspclogchain–zeit ,
lv_datetime_str(14) type c,
lv_datetime_end(14) type c,
lv_dst type abap_bool,
lv_timestamp type rspcprocesslog–endtimestamp ,
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 rspcprocesslog–endtimestamp ,
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_scheduled–sdlstrtdt wa_scheduled–sdlstrttm into wa_scheduled–datetime_str .
concatenate wa_scheduled–sdlstrtdt wa_scheduled–sdlstrttm into wa_scheduled–datetime_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 sy–subrc = 0.
read table l_t_valtab into l_w_valtab
with key selname = ‘CHAIN’.
if sy–subrc = 0.
<l_f_scheduled>–chain = l_w_valtab–low.
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 sy–zonlo
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:
Result:
User input:
No comments:
Post a Comment