*&---------------------------------------------------------------------*
*& Report ZPC_CHECK_PREV_RUN_CHAIN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPC_CHECK_PREV_RUN_CHAIN.
DATA: L_STATUS TYPE RSPC_STATE.
PARAMETERS L_CHAIN TYPE RSPC_CHAIN.
BREAK-POINT.
DO 3600 TIMES.
SELECT SINGLE ANALYZED_STATUS
FROM RSPCLOGCHAIN BYPASSING BUFFER
INTO L_STATUS
WHERE CHAIN_ID = L_CHAIN
AND DATUM = SY-DATUM
AND ANALYZED_STATUS EQ 'A'.
IF SY-SUBRC NE 0.
EXIT.
ELSEIF SY-INDEX = 3600.
MESSAGE 'ОШИБКА! ДЕЛАЕМ ЦЕПОЧКУ КРАСНОЙ' TYPE 'E'. STOP.
ENDIF.
WAIT UP TO 1 SECONDS.
ENDDO.
Однако, есть и другая версия:
*&---------------------------------------------------------------------*
*& Report ZPC_CHECK_PREV_RUN_CHAIN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YPC_CHECK_PREV_RUN_CHAIN.
include LBTCHDEF.
*data d type c.
*d = 'X'.
*while d = 'X'.
* d = 'X'.
*ENDWHILE.
data: lf_chain type rspc_chain,
lf_max_time type i,
lf_my_log type RSPC_LOGID. "log id текущией цепочки
data: lt_running_chains type table of RSPCLOGCHAIN. "список активных цепочек
SELECT-OPTIONS p_chains for lf_chain. "список проверяемых цепочек
PARAMETER p_maxsec type i DEFAULT 3600. "максимальное время ожидания в sec
*определяем log текущией цепочки, чтобы его не учитывать.
perform get_my_log_id.
lf_max_time = p_maxsec.
BREAK-POINT.
check p_chains[] is not INITIAL.
DO lf_max_time TIMES.
SELECT *
FROM RSPCLOGCHAIN BYPASSING BUFFER
INTO table lt_running_chains
WHERE CHAIN_ID in p_chains
and log_id <> lf_my_log
* AND DATUM = SY-DATUM
AND ANALYZED_STATUS EQ 'A'.
if sy-subrc ne 0. "нет активных цепочке - выход
exit.
else.
if SY-INDEX = 3600.
MESSAGE 'ОШИБКА! ДЕЛАЕМ ЦЕПОЧКУ КРАСНОЙ' TYPE 'E'. STOP.
endif.
endif.
WAIT UP TO 1 SECONDS.
ENDDO.
form get_my_log_id.
clear lf_my_log.
data: jobcount like TBTCM-JOBCOUNT,
jobname like TBTCM-JOBNAME.
* stepcount like TBTCM-STEPCOUNT.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
* EVENTID =
* EVENTPARM =
* EXTERNAL_PROGRAM_ACTIVE =
JOBCOUNT = jobcount
JOBNAME = jobname
* STEPCOUNT = stepcount
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
data: jobhead type TBTCJOB.
* JOBLOG_ATTRIBUTES type BAPIXMJOBLOG,
* EPP_ATTRIBUTES TYPE BTCJOBEPP.
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
JOB_READ_JOBCOUNT = jobcount
JOB_READ_JOBNAME = jobname
JOB_READ_OPCODE = btc_xbp_jobhead_only
* JOB_STEP_NUMBER = stepcount
IMPORTING
JOB_READ_JOBHEAD = jobhead
* JOBLOG_ATTRIBUTES = JOBLOG_ATTRIBUTES
* EPP_ATTRIBUTES = EPP_ATTRIBUTES
* TABLES
* JOB_READ_STEPLIST =
* SPOOL_ATTRIBUTES =
* CHANGING
* RET =
EXCEPTIONS
INVALID_OPCODE = 1
JOB_DOESNT_EXIST = 2
JOB_DOESNT_HAVE_STEPS = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
select single log_id
into lf_my_log
from RSPCPROCESSLOG
where type = 'ABAP'
and event_start = jobhead-EVENTID
and eventp_start = jobhead-EVENTPARM
and JOB_COUNT = jobcount.
endform.
*& Report ZPC_CHECK_PREV_RUN_CHAIN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPC_CHECK_PREV_RUN_CHAIN.
DATA: L_STATUS TYPE RSPC_STATE.
PARAMETERS L_CHAIN TYPE RSPC_CHAIN.
BREAK-POINT.
DO 3600 TIMES.
SELECT SINGLE ANALYZED_STATUS
FROM RSPCLOGCHAIN BYPASSING BUFFER
INTO L_STATUS
WHERE CHAIN_ID = L_CHAIN
AND DATUM = SY-DATUM
AND ANALYZED_STATUS EQ 'A'.
IF SY-SUBRC NE 0.
EXIT.
ELSEIF SY-INDEX = 3600.
MESSAGE 'ОШИБКА! ДЕЛАЕМ ЦЕПОЧКУ КРАСНОЙ' TYPE 'E'. STOP.
ENDIF.
WAIT UP TO 1 SECONDS.
ENDDO.
Однако, есть и другая версия:
*&---------------------------------------------------------------------*
*& Report ZPC_CHECK_PREV_RUN_CHAIN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YPC_CHECK_PREV_RUN_CHAIN.
include LBTCHDEF.
*data d type c.
*d = 'X'.
*while d = 'X'.
* d = 'X'.
*ENDWHILE.
data: lf_chain type rspc_chain,
lf_max_time type i,
lf_my_log type RSPC_LOGID. "log id текущией цепочки
data: lt_running_chains type table of RSPCLOGCHAIN. "список активных цепочек
SELECT-OPTIONS p_chains for lf_chain. "список проверяемых цепочек
PARAMETER p_maxsec type i DEFAULT 3600. "максимальное время ожидания в sec
*определяем log текущией цепочки, чтобы его не учитывать.
perform get_my_log_id.
lf_max_time = p_maxsec.
BREAK-POINT.
check p_chains[] is not INITIAL.
DO lf_max_time TIMES.
SELECT *
FROM RSPCLOGCHAIN BYPASSING BUFFER
INTO table lt_running_chains
WHERE CHAIN_ID in p_chains
and log_id <> lf_my_log
* AND DATUM = SY-DATUM
AND ANALYZED_STATUS EQ 'A'.
if sy-subrc ne 0. "нет активных цепочке - выход
exit.
else.
if SY-INDEX = 3600.
MESSAGE 'ОШИБКА! ДЕЛАЕМ ЦЕПОЧКУ КРАСНОЙ' TYPE 'E'. STOP.
endif.
endif.
WAIT UP TO 1 SECONDS.
ENDDO.
form get_my_log_id.
clear lf_my_log.
data: jobcount like TBTCM-JOBCOUNT,
jobname like TBTCM-JOBNAME.
* stepcount like TBTCM-STEPCOUNT.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
* EVENTID =
* EVENTPARM =
* EXTERNAL_PROGRAM_ACTIVE =
JOBCOUNT = jobcount
JOBNAME = jobname
* STEPCOUNT = stepcount
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
data: jobhead type TBTCJOB.
* JOBLOG_ATTRIBUTES type BAPIXMJOBLOG,
* EPP_ATTRIBUTES TYPE BTCJOBEPP.
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
JOB_READ_JOBCOUNT = jobcount
JOB_READ_JOBNAME = jobname
JOB_READ_OPCODE = btc_xbp_jobhead_only
* JOB_STEP_NUMBER = stepcount
IMPORTING
JOB_READ_JOBHEAD = jobhead
* JOBLOG_ATTRIBUTES = JOBLOG_ATTRIBUTES
* EPP_ATTRIBUTES = EPP_ATTRIBUTES
* TABLES
* JOB_READ_STEPLIST =
* SPOOL_ATTRIBUTES =
* CHANGING
* RET =
EXCEPTIONS
INVALID_OPCODE = 1
JOB_DOESNT_EXIST = 2
JOB_DOESNT_HAVE_STEPS = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
select single log_id
into lf_my_log
from RSPCPROCESSLOG
where type = 'ABAP'
and event_start = jobhead-EVENTID
and eventp_start = jobhead-EVENTPARM
and JOB_COUNT = jobcount.
endform.
Комментариев нет:
Отправить комментарий