自动传输副本请求
用途
有时请求需要传输到测试环境才有数据测试,每次传输完请求再修改会产生多个请求,所以采用副本传输。此程序可自动创建副本请求,包含所选请求中的对象,然后释放副本请求并导入到目标系统。
支持一次包多个请求,一次传多个系统。
操作
选择屏幕筛选要传输的请求
选中要传输的请求,点击创建并传输副本请求
填写请求描述和传输目标
查看返回消息,如果返回成功即完成请求传输
安装
用ZLAN_ACC安装
ZLAN_ACC V1.5 使用说明_小懒 1510491230@qq.com的博客-CSDN博客
找YLAN_COPY_REQUEST 副本请求传输
注:
- 如果漏了数据字典或函数之类的属于ZLAN_ACC bug,可联系我
- 函数
ZCM_REQUEST_IMPORTS 传输请求到不同client,在DEV系统,表ZTCM_DESTINATION配置了client和destination的对应关系
ZCM_REQUEST_IMPORT 传输请求到当前client,在QAS系统
3.函数开头的是接口日志,如不需要可以注释掉
代码
主程序代码供参考,引用的其他功能参考ZLAN_ACC部分
*&---------------------------------------------------------------------*
*& Report YLAN_COPY_REQUEST
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report ylan_copy_request.
tables:e070.
*选择屏幕定义
selection-screen begin of block b1 with frame title text-001.
select-options:
s_trkorr for e070-trkorr,
s_trfunc for e070-trfunction,
s_trstat for e070-trstatus default 'D',
s_korrd for e070-korrdev,
s_as4u for e070-as4user default sy-uname,
s_as4d for e070-as4date,
s_as4t for e070-as4time.
selection-screen end of block b1.
*selection-screen begin of block b2 with frame title text-002.
*parameters:
*p_tarsys like ko013-tarsystem default '/QAS/' obligatory.
*selection-screen end of block b2.
*本地类
class lcl_sel definition final.
public section.
class-methods sel_check.
class-methods pbo.
protected section.
private section.
endclass.
class lcl_sel implementation.
method sel_check.
endmethod.
method pbo.
endmethod.
endclass.
class lcl_data definition final inheriting from zcl_data_super1.
public section.
types:begin of ty_output,
sel type flag,
trkorr type e070-trkorr,
trfunction type e070-trfunction,
trstatus type e070-trstatus,
korrdev type e070-korrdev,
as4user type e070-as4user,
as4date type e070-as4date,
as4time type e070-as4time,
as4text type e07t-as4text,
trkorr_copy type e070-trkorr,
mtype type bapi_mtype,
msg type bapi_msg,
end of ty_output.
class-methods class_constructor.
methods output .
class-methods process.
methods:
alv_b_fieldcat redefinition,
alv_e_status_set redefinition,
alv_e_user_command redefinition.
protected section.
private section.
class-data :
t_output type table of ty_output.
data s_new_request type trwbo_request_header.
data t_e071 type standard table of e071.
methods command_transport.
methods request_create.
methods request_include_object.
methods request_transport.
methods find_object.
methods include_object.
methods request_release.
endclass.
class lcl_main definition final.
public section.
class-data: o_msg type ref to zcl_msg,
o_data type ref to lcl_data.
class-methods :class_constructor,
process,
output,
start,
initialization.
protected section.
private section.
endclass.
class lcl_main implementation.
method process.
new lcl_data( )->process( ).
endmethod.
method class_constructor.
o_msg = new zcl_msg( iv_level = '0' ).
o_data = new lcl_data( ).
endmethod.
method output.
new lcl_data( )->output( ).
endmethod.
method start.
process( ).
output( ).
endmethod.
method initialization.
zcl_common=>calc_date(
exporting
im_date = sy-datum
im_days = 0
im_months = '1'
im_signum = '-'
im_years = 0
receiving
re_date = s_as4d-low
).
s_as4d-high = sy-datum.
append s_as4d to s_as4d.
endmethod.
endclass.
class lcl_data implementation .
method output.
create object o_alv_util "有事件才调用,如果只是输出这句全部注释
exporting
iv_repid = sy-repid
iv_callback_pf_status_set = 'FRM_ALV_STATUS_SET'
iv_caller_exit = 'FRM_ALV_CALLER_EXIT'
iv_callback_user_command = 'FRM_ALV_USER_COMMAND'.
alv_b_fieldcat( ).
o_alv_util->layout_build(
iv_box_fname = 'SEL'
).
o_alv_util->call(
changing
it_outtab = t_output ).
endmethod.
method alv_b_fieldcat.
o_alv_util->t_fieldcat = value #(
( fieldname = 'TRKORR' coltext = '请求/任务' ref_table = 'E070' ref_field = 'TRKORR' )
( fieldname = 'TRFUNCTION' coltext = '类型' ref_table = 'E070' ref_field = 'TRFUNCTION')
( fieldname = 'TRSTATUS' coltext = '状态' ref_table = 'E070' ref_field = 'TRSTATUS')
( fieldname = 'KORRDEV' coltext = '类别' ref_table = 'E070' ref_field = 'KORRDEV')
( fieldname = 'AS4USER' coltext = '所有者' ref_table = 'E070' ref_field = 'AS4USER')
( fieldname = 'AS4DATE' coltext = '日期' ref_table = 'E070' ref_field = 'AS4DATE')
( fieldname = 'AS4TIME' coltext = '时间' ref_table = 'E070' ref_field = 'AS4TIME')
( fieldname = 'AS4TEXT' coltext = '描述' ref_table = 'E07T' ref_field = 'AS4TEXT')
( fieldname = 'TRKORR_COPY' coltext = '副本请求' )
( fieldname = 'MTYPE' coltext = '消息描述' )
( fieldname = 'MSG' coltext = '消息文本' )
).
endmethod.
method class_constructor.
o_msg = lcl_main=>o_msg.
endmethod.
method process.
select *
from e070
inner join e07t on e070~trkorr = e07t~trkorr and e07t~langu = @sy-langu
where e070~trkorr in @s_trkorr and e070~trfunction in @s_trfunc
and e070~trstatus in @s_trstat and e070~korrdev in @s_korrd
and e070~as4user in @s_as4u and e070~as4date in @s_as4d
and e070~as4time in @s_as4t
into corresponding fields of table @t_output
.
endmethod.
method alv_e_status_set.
set pf-status '9001'.
endmethod.
method alv_e_user_command.
case iv_ucomm.
when 'TRANSPORT'.
command_transport( ).
endcase.
o_alv_util->refresh( ).
endmethod.
method command_transport.
read table t_output into data(ls_output) with key sel = 'X'.
if sy-subrc ne 0.
message e001(00) with '至少选择一行'.
endif.
*创建副本请求
request_create( ).
*包含对象
request_include_object( ).
*释放请求
request_release( ).
*传输
request_transport( ).
*消息处理
o_msg->raise(
exporting
iv_error_avaliable = ''
importing
ev_type = ls_output-mtype
ev_msg = ls_output-msg
).
modify t_output from ls_output transporting mtype msg where sel = 'X'.
endmethod.
method request_create.
data: lt_users type trwbo_users.
o_msg->s_msg-operation = '创建副本请求'.
call function 'TR_REQUEST_MODIFY'
exporting
iv_action = 'CREA'
iv_new_request_type = 'T'
it_users = lt_users
importing
es_new_request = s_new_request
exceptions
others = 1.
if sy-subrc <> 0.
o_msg->convert_sys_msg( ).
endif.
loop at t_output into data(ls_output) where sel = 'X'.
ls_output-trkorr_copy = s_new_request-trkorr.
o_msg->raise(
importing
ev_type = ls_output-mtype
ev_msg = ls_output-msg
).
modify t_output from ls_output.
endloop.
endmethod.
method request_include_object.
find_object( ).
include_object( ).
endmethod.
method find_object.
clear:t_e071.
*找到任务
with +data as ( select trkorr from @t_output as t_output where sel = 'X' ) ##ITAB_KEY_IN_SELECT
select e070~trkorr,e070~strkorr
from +data as t_output
inner join e070 on t_output~trkorr = e070~strkorr
into table @data(lt_e070).
*请求和任务下面的对象
with +data as ( select trkorr from @t_output as t_output where sel = 'X' ) ##ITAB_KEY_IN_SELECT
select e071~*
from +data as t_output
inner join e071 on t_output~trkorr = e071~trkorr
into table @data(lt_e071).
select e071~*
from @lt_e070 as lt_e070
inner join e071 on lt_e070~trkorr = e071~trkorr
appending corresponding fields of table @lt_e071.
t_e071 = lt_e071.
endmethod.
method request_transport.
data: lt_requests type zty_t_requests,
ls_requests type zscm_request,
ls_client type zcm_s_client,
lt_client type zty_t_zcm_s_client,
lv_type type bapi_mtype,
lv_msg type bapi_msg,
lt_msg type ztt_zcm_s_msg.
ls_requests-trkorr = s_new_request-trkorr.
append ls_requests to lt_requests.
ls_client-client = '400'.
append ls_client to lt_client.
ls_client-client = '4300'.
append ls_client to lt_client.
call function 'ZCM_REQUEST_IMPORTS'
exporting
it_requests = lt_requests
it_client = lt_client
importing
ev_type = lv_type
ev_msg = lv_msg
et_msg = lt_msg.
o_msg->s_msg-operation = '导入请求'.
o_msg->s_msg-type = lv_type.
o_msg->s_msg-msg = lv_msg.
o_msg->collect( ).
endmethod.
method include_object.
o_msg->s_msg-operation = '包请求对象'.
loop at t_e071 into data(ls_e071).
call function 'TR_COPY_COMM'
exporting
wi_dialog = ''
wi_trkorr_from = ls_e071-trkorr
wi_trkorr_to = s_new_request-trkorr
wi_without_documentation = 'X'
exceptions
db_access_error = 1
trkorr_from_not_exist = 2
trkorr_to_is_repair = 3
trkorr_to_locked = 4
trkorr_to_not_exist = 5
trkorr_to_released = 6
user_not_owner = 7
no_authorization = 8
wrong_client = 9
wrong_category = 10
object_not_patchable = 11.
if sy-subrc <> 0.
o_msg->convert_sys_msg( ).
endif.
endloop.
endmethod.
method request_release.
data: ls_request type trwbo_request,
lt_deleted_tasks type trwbo_t_e070.
o_msg->s_msg-operation = '释放请求'.
call function 'TR_RELEASE_REQUEST'
exporting
iv_trkorr = s_new_request-trkorr
iv_dialog = ''
iv_as_background_job = ' '
iv_success_message = 'X'
iv_display_export_log = 'X'
iv_simulation = ' '
iv_without_locking = 'X'
importing
es_request = ls_request
et_deleted_tasks = lt_deleted_tasks
exceptions
cts_initialization_failure = 1
enqueue_failed = 2
no_authorization = 3
invalid_request = 4
request_already_released = 5
repeat_too_early = 6
error_in_export_methods = 7
object_check_error = 8
docu_missing = 9
db_access_error = 10
action_aborted_by_user = 11
export_failed = 12.
if sy-subrc <> 0.
o_msg->convert_sys_msg( ).
endif.
*等待释放完成
do.
select single * from e070
where trkorr = @s_new_request-trkorr
into @data(ls_e070).
if ls_e070-trstatus ne 'R'.
wait up to 1 seconds.
else.
exit.
endif.
enddo.
endmethod.
endclass.
*可执行程序事件
initialization.
lcl_main=>initialization( ).
at selection-screen output.
lcl_sel=>pbo( ).
at selection-screen.
lcl_sel=>sel_check( ).
start-of-selection.
lcl_main=>start( ).
form frm_alv_caller_exit using e_grid type slis_data_caller_exit.
call method lcl_main=>o_data->alv_b_events.
endform.
form frm_alv_status_set using rt_extab type slis_t_extab.
call method lcl_main=>o_data->alv_e_status_set.
endform. "PF_STATUS_SET
form frm_alv_user_command using l_ucomm like sy-ucomm
ls_selfield type slis_selfield.
call method lcl_main=>o_data->alv_e_user_command
exporting
iv_ucomm = l_ucomm
is_selfield = ls_selfield.
endform.
文章来自于网络,如果侵犯了您的权益,请联系站长删除!