Небольшая заготовка для транзакции запуска цепочки и передачей в неё фильтров.
Есть возможность просмотра лога цепочки, проверка и просмотр фильтров перед запуском. Навигация в стандартном стиле SAP.
Когда продуктив закрыт, а загрузиться что-то очень хочется :)
Только сразу не кидайте камни, часть функционала переделал, а часть пришлось оставить как есть...
Внешний вид:
Код основной программы слишком длинный, пришлось завернуть в файл.
Структура таблиц:
/bic/anoekran00:
Есть возможность просмотра лога цепочки, проверка и просмотр фильтров перед запуском. Навигация в стандартном стиле SAP.
Когда продуктив закрыт, а загрузиться что-то очень хочется :)
Только сразу не кидайте камни, часть функционала переделал, а часть пришлось оставить как есть...
В фильтры можно добавлять столько же значений, сколько добавляем в фильтры dtp.
Внешний вид:
Код основной программы слишком длинный, пришлось завернуть в файл.
Структура таблиц:
/bic/anoekran00:
/bic/pnefilter:
/bic/pncfilt:
ZNMENU:
ZNF_SET_EKRAN_PARAM:
function znf_set_ekran_param.*"----------------------------------------------------------------------*"*"Локальный интерфейс:*" IMPORTING*" REFERENCE(EKRAN) TYPE I*" REFERENCE(NUM_FILT) TYPE C*" REFERENCE(VALPAR) TYPE C*" REFERENCE(TXT) TYPE STRING OPTIONAL*" EXPORTING*" REFERENCE(RES) TYPE I*"---------------------------------------------------------------------- data: type_filtr type /bic/oincfilt, all_filt like /bic/pnefilter, id_rec type /bic/oinefilter.*----------------------------------------------------------------------- select single /bic/ncfilt
into type_filtr
from /bic/pncfilt
where txtlg = num_filt.
*" Определяем ID записи в таблице select max( /bic/nefilter ) into id_rec
from /bic/pnefilter
where objvers = 'A'.
id_rec = id_rec + 1.
clear all_filt.
*" Запихиваем значения all_filt-/bic/nefilter = id_rec. all_filt-/bic/ncnumekr = ekran. all_filt-/bic/ncfilt = type_filtr. all_filt-/bic/ncvalpar = valpar. all_filt-objvers = 'A'. all_filt-txtlg = txt.
insert into /bic/pnefilter values all_filt.
*" Проверка записи в таблицу select count( * ) into res
from /bic/pnefilter
where objvers = 'A' and /bic/nefilter = id_rec.
if res > 0. res = 0. else. res = 1. endif.*"----------------------------------------------------------------------endfunction.
ZNF_SETPLANING:
function znf_setplaning.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" IMPORTING
*" REFERENCE(JOBNAME) TYPE C
*" REFERENCE(JOBDATE) TYPE DATS
*" REFERENCE(JOBTIME) TYPE TIMS
*" EXPORTING
*" REFERENCE(JOBCOUNT) TYPE C
*"----------------------------------------------------------------------
data:
jobnumber like tbtcjob-jobcount,
jobnames like tbtcjob-jobname,
startdate like tbtcjob-sdlstrtdt,
starttime like tbtcjob-sdlstrttm,
laststartdate like tbtcjob-laststrtdt,
laststarttime like tbtcjob-laststrttm,
job_released like btch0000-char1,
user_print_params like pri_params,
user_arc_params like arc_params,
g_report like rsvar-report value 'ZN_JOB_AGENT',
g_variant like rsvar-variant,
g_vari_desc like varid,
it_rsparams type standard table of rsparams,
wa_rsparams like line of it_rsparams,
it_vari_text type standard table of varit,
wa_vari_text like line of it_vari_text,
param type tvarv_val.
*"----------------------------------------------------------------------
move jobname to jobnames.
move jobdate to startdate.
move jobtime to starttime.
laststartdate = startdate + 1.
laststarttime = starttime.
*-----------------------------------------------------------------------
*" Создание задания
call function 'JOB_OPEN'
exporting
jobname = jobnames
importing
jobcount = jobnumber
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03
others = 99.
if sy-subrc > 0.
jobcount = '0'.
exit.
endif.
*-----------------------------------------------------------------------
*" Создание варианта к заданию
*" Определяем имя варианта
concatenate 'V' jobnumber into g_variant.
move jobnumber to param.
*" Удаляем ранее созданный вариант для этого джоба
call function 'RSAQ_DELETE_ONE_VARIANT'
exporting
report = g_report
variant = g_variant
exceptions
not_authorized = 1
not_executed = 2
no_report = 3
report_not_existent = 4
report_not_supplied = 5
variant_locked = 6
others = 7.
commit work.
*" Текст к варианту
wa_vari_text-langu = sy-langu.
wa_vari_text-report = g_report.
wa_vari_text-variant = g_variant.
wa_vari_text-vtext = 'NeoAgent'.
append wa_vari_text to it_vari_text.
clear wa_vari_text.
*" Связь с программой и задание имя варианта
g_vari_desc-report = g_report.
g_vari_desc-variant = g_variant.
g_vari_desc-environmnt = 'A'.
g_vari_desc-aedat = sy-datum.
g_vari_desc-aetime = sy-uzeit.
*" Параметры варианта
wa_rsparams-selname = 'PVARIANT'.
wa_rsparams-kind = 'P'.
wa_rsparams-sign = 'I'.
wa_rsparams-option = 'EQ'.
wa_rsparams-low = param .
append wa_rsparams to it_rsparams.
clear wa_rsparams.
call function 'RS_CREATE_VARIANT'
exporting
curr_report = g_report
curr_variant = g_variant
vari_desc = g_vari_desc
tables
vari_contents = it_rsparams
vari_text = it_vari_text.
commit work.
*-----------------------------------------------------------------------
*" Связываем задание с вариантом
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = jobnumber
jobname = jobnames
report = g_report
variant = g_variant
priparams = user_print_params
arcparams = user_arc_params
exceptions
bad_priparams = 01
invalid_jobdata = 02
jobname_missing = 03
job_notex = 04
job_submit_failed = 05
lock_failed = 06
program_missing = 07
prog_abap_and_extpg_set = 08
others = 99.
if sy-subrc > 0.
*" Удалили созданный вариант
call function 'RSAQ_DELETE_ONE_VARIANT'
exporting
report = g_report
variant = g_variant
exceptions
not_authorized = 1
not_executed = 2
no_report = 3
report_not_existent = 4
report_not_supplied = 5
variant_locked = 6
others = 7.
commit work.
jobcount = '0'.
exit.
endif.
*-----------------------------------------------------------------------
*" Завершение планирования, связь с временем и типом запуска
call function 'JOB_CLOSE'
exporting
jobcount = jobnumber
jobname = jobnames
sdlstrtdt = startdate
sdlstrttm = starttime
laststrtdt = laststartdate
laststrttm = laststarttime
prdmonths = '1'
prdweeks = '1'
prddays = '1'
prdhours = '1'
prdmins = '1'
importing
job_was_released = job_released
exceptions
invalid_startdate = 01
jobname_missing = 02
job_close_failed = 03
job_nosteps = 04
job_notex = 05
lock_failed = 06
others = 99.
if sy-subrc > 0.
*" Удалили созданный вариант
call function 'RSAQ_DELETE_ONE_VARIANT'
exporting
report = g_report
variant = g_variant
exceptions
not_authorized = 1
not_executed = 2
no_report = 3
report_not_existent = 4
report_not_supplied = 5
variant_locked = 6
others = 7.
jobcount = '0'.
exit.
endif.
jobcount = jobnumber.
*-----------------------------------------------------------------------
endfunction.
ZNF_SET_MESSPLANING:
function znf_set_messplaning.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" IMPORTING
*" REFERENCE(JOBNUM) TYPE C
*" REFERENCE(JOBNAME) TYPE C
*" REFERENCE(JOBDATE) TYPE DATS
*" REFERENCE(JOBTIME) TYPE TIMS
*" REFERENCE(EKRAN) TYPE I
*" REFERENCE(NUM_FILT) TYPE C
*" REFERENCE(VALPAR) TYPE C
*" REFERENCE(TXT) TYPE STRING OPTIONAL
*" EXPORTING
*" REFERENCE(RES) TYPE I
*"----------------------------------------------------------------------
data:
all_filt like /bic/pnejobs,
type_filtr type /bic/oincfilt,
id_rec type /bic/oinejobs.
*-----------------------------------------------------------------------
select single /bic/ncfilt
into type_filtr
from /bic/pncfilt
where txtlg = num_filt.
*" Определяем ID записи в таблице
select max( /bic/nejobs )
into id_rec
from /bic/pnejobs
where objvers = 'A'.
id_rec = id_rec + 1.
clear all_filt.
*" Запихиваем значения
all_filt-/bic/nejobs = id_rec.
all_filt-/bic/ncjobnum = jobnum.
all_filt-/bic/ncjobname = jobname.
all_filt-/bic/ncdate = jobdate.
all_filt-/bic/nctime = jobtime.
all_filt-/bic/ncnumekr = ekran.
all_filt-/bic/ncfilt = type_filtr.
all_filt-/bic/ncvalpar = valpar.
all_filt-objvers = 'A'.
all_filt-txtlg = txt.
insert into /bic/pnejobs values all_filt.
*" Проверка записи в таблицу
select count( * )
into res
from /bic/pnejobs
where objvers = 'A'
and /bic/nejobs = id_rec.
if res > 0.
res = 0.
else.
res = 1.
endif.
endfunction.
В цепочке ставим\снимаем флаги через абапину ZN_EKRAN_FLAG:
*&---------------------------------------------------------------------*
*& Report ZN_EKRAN_FLAG
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*"----------------------------------------------------------------------
report zn_ekran_flag.
parameters:
num_ekr type i default 0,
set_flag type i default 0.
*-----------------------------------------------------------------------
if set_flag <> 0.
set_flag = 1.
endif.
update /bic/pncflstate
set /bic/ekrstate = set_flag
/bic/ncdt = sy-datum
/bic/nctime = sy-uzeit
where /bic/ncnumekr = num_ekr
and objvers = 'A'.
*"----------------------------------------------------------------------
Фильтры читаем так (у нас загрузка из инфо-набора):
* -------------------------------------------------------------------
* Fieldname = F1
* data type = CHAR
* length = 000030
* -------------------------------------------------------------------
form c_f1
tables l_t_range structure rssdlrange
using i_r_request type ref to if_rsbk_request_admintab_view
i_fieldnm type rsfieldnm
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
*-----------------------------------------------------------------------
types:
begin of param_all,
ncvalpar type /bic/oincvalpar,
end of param_all.
data:
l_idx like sy-tabix,
counts type i,
t_table type table of param_all,
wa like line of t_table,
bufers type /bic/oincvalpar.
*-----------------------------------------------------------------------
*" Загрузка фильтров по Бухгалтерской проводке вo времeнную таблицу
select /bic/ncvalpar
into table t_table
from /bic/pnefilter
where objvers = 'A'
and /bic/ncnumekr = 11041000
and /bic/ncfilt
in ( select /bic/ncfilt
from /bic/pncfilt
where objvers = 'A'
and txtlg = '13' ).
*" Определение количества установленных фильтров
counts = 0.
loop at t_table into wa.
counts = counts + 1.
exit.
endloop.
if counts > 0.
*" Есть фильтры, перетаскиваем их
loop at t_table into wa.
l_t_range-iobjnm = 'F1'.
l_t_range-fieldname = 'F1'.
move wa-ncvalpar to l_t_range-low.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
append l_t_range.
endloop.
else.
*" нет фильтров, должны быть любыми
l_t_range-iobjnm = 'F1'.
l_t_range-fieldname = 'F1'.
l_t_range-low = 'XXX'.
l_t_range-sign = 'I'.
l_t_range-option = 'NE'.
append l_t_range.
endif.
p_subrc = 0.
*-----------------------------------------------------------------------
CP, если нужно в фильтре указать маску *
* -------------------------------------------------------------------
* Fieldname = F5
* data type = DATS
* length = 000008
* -------------------------------------------------------------------
form c_f5
tables l_t_range structure rssdlrange
using i_r_request type ref to if_rsbk_request_admintab_view
i_fieldnm type rsfieldnm
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
*-----------------------------------------------------------------------
data:
l_idx like sy-tabix,
bufers type /bic/oincvalpar,
d1 type d,
d2 type d.
*-----------------------------------------------------------------------
select single /bic/ncvalpar
into bufers
from /bic/pnefilter
where objvers = 'A'
and /bic/ncnumekr = 11041000
and /bic/ncfilt
in ( select /bic/ncfilt
from /bic/pncfilt
where objvers = 'A'
and txtlg = '0' ).
move bufers to d1.
clear bufers.
select single /bic/ncvalpar
into bufers
from /bic/pnefilter
where objvers = 'A'
and /bic/ncnumekr = 11041000
and /bic/ncfilt
in ( select /bic/ncfilt
from /bic/pncfilt
where objvers = 'A'
and txtlg = '1' ).
move bufers to d2.
if d1 is initial or d2 is initial.
*" нет фильтров, сводим на пусто
l_t_range-iobjnm = 'F5'.
l_t_range-fieldname = 'F5'.
l_t_range-low = '10000101'.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
append l_t_range.
else.
l_t_range-iobjnm = 'F5'.
l_t_range-fieldname = 'F5'.
move d1 to l_t_range-low.
move d2 to l_t_range-high.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
append l_t_range.
endif.
p_subrc = 0.
*-----------------------------------------------------------------------
Комментариев нет:
Отправить комментарий