Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

ABAP to get SAP BW Direct & Event scheduled process chains list

$
0
0

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:


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' . "sy-uzeit' .
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 .

TYPES: BEGIN OF l_s_scheduled,
jobname   
TYPE tbtco-jobname,
jobcount  
TYPE tbtco-jobcount,
sdlstrtdt 
TYPE tbtco-sdlstrtdt,
sdlstrttm 
TYPE tbtco-sdlstrttm,
event(17type c ,
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,
lastrun
(19) TYPE c ,
remarks
(19) TYPE c ,
datetime_remark
(31) type c ,
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,
l_w_valtab   
TYPE rsparams,
lv_date
type rspclogchain-datum ,
lv_time
type rspclogchain-zeit ,
lv_date_remark
type rspclogchain-datum ,
lv_time_remark
type rspclogchain-zeit ,
lv_datetime_dummy
(14) type c ,
lv_datetime_remark
type TIMESTAMP ,
lv_datetime_str
(14) type c,
lv_datetime_end
(14) type c,
lv_dst
TYPE abap_bool,
lv_timestamp
type RSPCPROCESSLOG-ENDTIMESTAMP ,
dummy
(14) type c ,
seconds_dummy
type i ,
lv_check_end_dummy
(14) type c ,
lv_check_end
type RSPCPROCESSLOG-ENDTIMESTAMP ,
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_gmw_date
(10) type c ,
lv_gmw_time
(10) type c .

FIELD-SYMBOLS    <l_f_scheduled> TYPE l_s_scheduled.

concatenate end_date end_time into lv_check_end_dummy .
move lv_check_end_dummy to lv_check_end .


* Get data based on user selections *


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    wa_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 .
*AND     a~sdlstrttm >= str_time and a~sdlstrttm <= end_time .
append wa_scheduled to l_t_scheduled .
endselect .

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 .

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 wa_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
append wa_scheduled to l_t_scheduled .
endselect .

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 wa_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
append wa_scheduled to l_t_scheduled .
endselect.

delete l_t_scheduled where event <> ' ' .

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 wa_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
append wa_scheduled to l_t_scheduled .
endselect .

delete l_t_scheduled where sdlstrtdt <> ' ' .

endif.

SORT l_t_scheduled BY sdlstrtdt sdlstrttm ASCENDING.

ULINE (179).

WRITE :/ '|' , '                         ', '|' ,'      Last Run         ', '|' , '      Next Run         ' , '|' , '|' , '                                                                ' , '|' .

ULINE (179).

WRITE :/ '|' , 'Chain Name               ', '|' ,'Start Date', '|', 'Start Time' , '|' , 'Start Date', '|', 'Start Time'
, '|' , 'Parent Chain                  ' , '|' , 'Event ID         ' , '|'  , 'Frequency  ' , '|'  .

new-line .

ULINE (179).

data: date(19) type c ,
time(17) type c ,
frequency
(10) type c .


* Pass the parameter to get Process chain name *

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 details

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 <l_f_scheduled>-event 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>-event .
endselect .
select chain_id from rspcchain into <l_f_scheduled>-parent_chain where type = 'ZEVENT' and objvers = 'A' and variante = lv_event .
endselect.

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>-event , '|'  , frequency , ' |' .


ENDIF.
ULINE (179).

ENDLOOP.
new-line
.


Text Symbols:

4.JPG


Result:


1.JPG

User input:

2.png3.png




Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>