自建表维护工具
用途
这是个简单的小工具,用于维护自建表。传统建完自建表,可能建一个SM30用于维护,SM30每张自建表都需要创建一次,如果字段有改变每次还需要调整,SM30的筛选排序这些没有alv方便,一次只能粘贴一页数据。
自开发个alv维护,有需要维护的自建表,配置把tcode和表名关联一下就好了,复制数据可以批量粘贴,也就不需要做批导功能了。
目前只有增删改查和传输的功能,如果有复杂需求,可以改一下,建个配置表关联事件,在新的事件程序里写处理代码就好了。
安装
zlan_acc
点进去选一下程序、表和class,tcode不要选了
创建对象即可。
也可以自己复制代码粘贴进去,那要自己建表和status。
或者代码copy一下按自己需求改改也很快
使用
新建两个TCODE,一个用于维护TCODE和自建表的对应关系,一个用于维护自建表
然后进tcode,维护TCODE 和表对应的关系就好了
代码
*&---------------------------------------------------------------------*
*& REPORT ZFIR028
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zfir028.
tables:sscrfields.
*&---------------------------------------------------------------------*
* TYPES
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* CONSTANTS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* GLOBAL DATA
*&---------------------------------------------------------------------*
* ALV变量
class lcl_event_receiver definition deferred.
data:
gv_container type ref to cl_gui_docking_container, "容器类
go_event_receiver type ref to lcl_event_receiver,
go_alvgrid type ref to cl_gui_alv_grid.
class lcl_event_receiver definition. "定义类 捕捉各种事件
public section.
methods data_changed_finished
for event data_changed_finished of cl_gui_alv_grid
importing e_modified
et_good_cells
sender.
endclass. "LCL_EVENT_RECEIVER DEFINITION
class lcl_event_receiver implementation. "实现类 处理事件
method data_changed_finished.
perform frm_alv_data_changed_finished using e_modified et_good_cells sender.
endmethod.
endclass. "LCL_EVENT_RECEIVER IMPLEMENTATION
data:
gt_fieldcat type lvc_t_fcat,
gt_excluding type ui_functions,
gs_layout type lvc_s_layo,
gs_styl type lvc_s_styl,
gt_styl type lvc_t_styl,
gt_events type slis_t_event with header line,
gt_event_exit type slis_t_event_exit with header line,
gs_grid_settings type lvc_s_glay.
data:
ct_fieldcat type lvc_t_fcat, "内表结构
go_alv_ref type ref to data,
gv_no_config, "没有配置tcode和表对应关系
gv_direct. "直接调用
field-symbols <gt_alv> type standard table.
data:
gt_ztfi025i like table of ztfi025i with header line.
*&---------------------------------------------------------------------*
* GLOBAL MACROS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* SELECTION-SCREEN
*&---------------------------------------------------------------------*
selection-screen function key 1.
selection-screen begin of block b1 with frame title gv_tit01.
parameters:
p_tab type dd02l-tabname.
selection-screen end of block b1.
class lcl_data definition final.
public section.
class-data t_where_clauses type rsds_twhere.
class-methods sel_pai.
protected section.
private section.
class-methods db_sel_call.
endclass.
class lcl_data implementation.
method sel_pai.
case sy-ucomm.
when 'FC01'.
db_sel_call( ).
endcase.
endmethod.
method db_sel_call.
data: lv_selection_id type rsdynsel-selid,
lt_tables_tab type standard table of rsdstabs,
ls_tables_tab type rsdstabs.
data: lt_fields_tab type standard table of rsdsfields.
ls_tables_tab-prim_tab = p_tab. "数据库表名
append ls_tables_tab to lt_tables_tab.
call function 'FREE_SELECTIONS_INIT'
exporting
kind = 'T'
importing
selection_id = lv_selection_id
tables
tables_tab = lt_tables_tab
exceptions
fields_incomplete = 1
fields_no_join = 2
field_not_found = 3
no_tables = 4
table_not_found = 5
expression_not_supported = 6
incorrect_expression = 7
illegal_kind = 8
area_not_found = 9
inconsistent_area = 10
kind_f_no_fields_left = 11
kind_f_no_fields = 12
too_many_fields = 13
dup_field = 14
field_no_type = 15
field_ill_type = 16
dup_event_field = 17
node_not_in_ldb = 18
area_no_field = 19
others = 20.
if sy-subrc eq 0.
call function 'FREE_SELECTIONS_DIALOG'
exporting
selection_id = lv_selection_id
title = '选择'(134)
frame_text = '查询条件'(135)
as_window = 'X' "不显示成窗口
importing
where_clauses = t_where_clauses "返回选择条件
tables
fields_tab = lt_fields_tab "选择画面中选中字段
exceptions
internal_error = 1
no_action = 2
selid_not_found = 3
illegal_status = 4
others = 5.
if sy-subrc eq 0.
endif.
endif.
endmethod.
endclass.
*&---------------------------------------------------------------------*
* EVENTS BEFORE MAIN PROGRAM
*&---------------------------------------------------------------------*
initialization.
perform frm_initialization.
at selection-screen output.
perform frm_sel_pbo.
at selection-screen on value-request for p_tab.
perform frm_sel_f4.
at selection-screen on p_tab.
perform frm_sel_field_p_tab.
at selection-screen.
lcl_data=>sel_pai( ).
*&---------------------------------------------------------------------*
* MAIN PROGRAM *
*----------------------------------------------------------------------*
start-of-selection.
perform frm_data_fetch.
perform frm_data_output.
*&---------------------------------------------------------------------*
*& FORM FRM_INITIALIZATION
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_initialization .
gv_tit01 = '选择'(117).
sscrfields-functxt_01 = '筛选数据'(133).
* GV_TIT02 = '操作'(118).
case sy-tcode.
when 'ZFI036CX'.
p_tab = 'ZTFI025I'.
gt_ztfi025i-tabname = 'ZTFI025I'.
gt_ztfi025i-as4text = '自建表维护配置'(061).
append gt_ztfi025i.
**只有一张表直接显示-考虑数据量可能很大需要选择条件,去掉了直接显示
* perform frm_data_fetch.
* perform frm_data_output.
when others.
select
ztfi025i~tcode ztfi025i~tabname dd02t~ddtext as as4text ztfi025i~del ztfi025i~erdat
ztfi025i~erzet ztfi025i~ernam ztfi025i~aedat ztfi025i~aezet ztfi025i~aenam
into corresponding fields of table gt_ztfi025i
from ztfi025i
left join dd02t on ztfi025i~tabname = dd02t~tabname and dd02t~as4local = 'A' and dd02t~ddlanguage = sy-langu
where tcode = sy-tcode.
if sy-dbcnt = 1.
read table gt_ztfi025i index 1.
p_tab = gt_ztfi025i-tabname.
**只有一张表直接显示-考虑数据量可能很大需要选择条件,去掉了直接显示
* perform frm_data_fetch.
* perform frm_data_output.
elseif sy-dbcnt = 0. "没有配置表
gv_no_config = 'X'.
endif.
endcase.
select single ttext
into sy-title
from tstct
where tcode = sy-tcode and sprsl = sy-langu.
endform.
*&---------------------------------------------------------------------*
*& FORM FRM_DATA_OUTPUT
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_data_output .
perform frm_alv_events.
perform frm_alv_layout.
perform frm_alv_fieldcat.
perform frm_alv_style.
perform frm_alv_call.
endform.
form frm_alv_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-sel_mode = 'A'.
gs_layout-zebra = 'X'.
gs_layout-box_fname = 'SEL'.
gs_layout-stylefname = 'TSTYL'.
* GS_LAYOUT-EXCP_FNAME = 'LED'.
endform. "FRM_ALV_LAYOUT
form frm_alv_call .
data lv_title(70).
gs_grid_settings-edt_cll_cb = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_grid_title = lv_title
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_ALV_STATUS_SET'
i_callback_user_command = 'FRM_ALV_USER_COMMAND'
i_grid_settings = gs_grid_settings
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat[]
i_save = 'A'
it_events = gt_events[]
it_event_exit = gt_event_exit[]
tables
t_outtab = <gt_alv>.
endform.
form frm_alv_fieldcat .
loop at gt_fieldcat into data(ls_fieldcat).
if ls_fieldcat-fieldname ne 'DEL'
and ls_fieldcat-fieldname ne 'ERDAT'
and ls_fieldcat-fieldname ne 'ERZET'
and ls_fieldcat-fieldname ne 'ERNAM'
and ls_fieldcat-fieldname ne 'AEDAT'
and ls_fieldcat-fieldname ne 'AEZET'
and ls_fieldcat-fieldname ne 'AENAM'.
ls_fieldcat-edit = 'X'.
endif.
modify gt_fieldcat from ls_fieldcat.
endloop.
endform.
form frm_build_fieldcat tables lt_fieldcat structure lvc_s_fcat
using fieldname coltext ref_tab ref_field convexit drop_down_handle f4availabl checktable edit.
clear lt_fieldcat.
lt_fieldcat-fieldname = fieldname.
lt_fieldcat-coltext = coltext.
lt_fieldcat-ref_table = ref_tab.
lt_fieldcat-ref_field = ref_field.
lt_fieldcat-convexit = convexit.
lt_fieldcat-drdn_field = drop_down_handle.
lt_fieldcat-f4availabl = f4availabl.
lt_fieldcat-checktable = checktable.
lt_fieldcat-edit = edit.
append lt_fieldcat.
endform. "BUILD_FIELDCAT
form frm_alv_status_set using rt_extab type slis_t_extab.
data: begin of lt_excltab occurs 0,
fcode like sy-ucomm,
end of lt_excltab.
* read table gt_fieldcat transporting no fields with key fieldname = 'DEL'.
* if sy-subrc ne 0.
* lt_excltab-fcode = 'DEL'.
* append lt_excltab.
* endif.
set pf-status 'STATUS_ALV' excluding lt_excltab.
endform. "PF_STATUS_SET
form frm_alv_user_command using l_ucomm like sy-ucomm
ls_selfield type slis_selfield.
case l_ucomm.
when 'APPEND'.
perform frm_data_append.
when 'DELETE'.
perform frm_data_delete.
when 'DEL'.
perform frm_data_del.
when 'SAVE' or '&DATA_SAVE'.
perform frm_data_save.
when 'TRANSPORT'.
perform frm_data_transport.
endcase.
perform frm_alv_refresh.
endform.
*&---------------------------------------------------------------------*
*& FORM FRM_ALV_REFRESH
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_alv_refresh.
data l_grid type ref to cl_gui_alv_grid.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = go_alvgrid.
data:
ls_stable type lvc_s_stbl,
ls_layout type lvc_s_layo,
lt_columns type lvc_t_col,
lt_index_rows type lvc_t_row,
lt_row_no type lvc_t_roid.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
clear: lt_columns,ls_layout.
call method go_alvgrid->get_frontend_layout
importing
es_layout = ls_layout.
ls_layout-cwidth_opt = 'X'.
call method go_alvgrid->set_frontend_layout
exporting
is_layout = ls_layout.
call method go_alvgrid->get_selected_columns "获取选择列
importing
et_index_columns = lt_columns.
call method go_alvgrid->get_selected_rows "获取选择行
importing
et_index_rows = lt_index_rows
et_row_no = lt_row_no.
call method go_alvgrid->refresh_table_display
exporting
is_stable = ls_stable
i_soft_refresh = 'X'
exceptions
finished = 1
others = 2.
*
call method go_alvgrid->set_selected_columns "设置回刷新前的列
exporting
it_col_table = lt_columns.
call method go_alvgrid->set_selected_rows "设置回刷新前的行
exporting
it_index_rows = lt_index_rows
it_row_no = lt_row_no.
endform. " FRM_ALV_REFRESH
*&---------------------------------------------------------------------*
*& FORM FRM_DATA_FETCH
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_data_fetch .
select single ddtext
into sy-title
from dd02t
where tabname = p_tab and ddlanguage = sy-langu.
*创建动态内表
data:
lv_structure_name type dd02l-tabname.
clear:gt_fieldcat[],ct_fieldcat[].
lv_structure_name = p_tab.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
* I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
i_structure_name = lv_structure_name
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
* I_INTERNAL_TABNAME = I_INTERNAL_TABNAME
changing
ct_fieldcat = ct_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2.
move-corresponding ct_fieldcat[] to gt_fieldcat[].
perform frm_build_fieldcat tables ct_fieldcat using 'SEL' 'SEL' space space space space space space space.
perform frm_build_fieldcat tables ct_fieldcat using 'CHANGED' 'CHANGED' space space space space space space space.
perform frm_build_fieldcat tables ct_fieldcat using 'TSTYL' 'TSTYL' '/INCMD/EXT_PHASB_COMP_DATA_ALV' 'CELLTAB' space space space space space.
call method cl_alv_table_create=>create_dynamic_table
exporting
* I_STYLE_TABLE = 'X' "会多出一列DEEP STRUCTURE
it_fieldcatalog = ct_fieldcat[]
importing
ep_table = go_alv_ref.
* CREATE DATA GO_ALV_REF TYPE STANDARD TABLE OF (GV_ORI_TABNAME).
assign go_alv_ref->* to <gt_alv>.
*在选择屏幕自己筛选的选择条件
data lv_where type string.
read table lcl_data=>t_where_clauses into data(ls_where_clauses) index 1.
if sy-subrc = 0.
loop at ls_where_clauses-where_tab into data(ls_where_tab).
lv_where = lv_where && ls_where_tab-line.
endloop.
select *
into corresponding fields of table <gt_alv>
from (p_tab)
where (lv_where).
else.
select *
into corresponding fields of table <gt_alv>
from (p_tab).
endif.
*数据筛选
import zcl_pass=>t_rsparams from memory id 'ZCL_PASS=>T_RSPARAMS'.
loop at <gt_alv> assigning field-symbol(<ls_alv>).
*从调用程序传过来选择条件
loop at zcl_pass=>t_rsparams into data(ls_rsparams).
assign component ls_rsparams-selname of structure <ls_alv> to field-symbol(<lv_field>).
if sy-subrc = 0.
if ls_rsparams-kind = 'P'.
if <lv_field> ne ls_rsparams-low.
delete <gt_alv>.
endif.
elseif ls_rsparams-kind = 'S'.
if ls_rsparams-sign = 'I'. "只处理了I和BT
if ls_rsparams-option = 'BT'.
if <lv_field> not between ls_rsparams-low and ls_rsparams-high.
delete <gt_alv>.
endif.
endif.
else.
endif.
endif.
endif.
endloop.
endloop.
endform.
*&---------------------------------------------------------------------*
*& FORM FRM_DATA_APPEND
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_data_append .
append initial line to <gt_alv>.
read table <gt_alv> assigning field-symbol(<ls_alv>) index sy-tabix.
assign component 'SPRAS' of structure <ls_alv> to field-symbol(<lv_spras>).
if sy-subrc = 0.
<lv_spras> = sy-langu.
endif.
assign component 'ERDAT' of structure <ls_alv> to field-symbol(<lv_erdat>).
if sy-subrc = 0.
<lv_erdat> = sy-datum.
endif.
assign component 'ERZET' of structure <ls_alv> to field-symbol(<lv_erzet>).
if sy-subrc = 0.
<lv_erzet> = sy-uzeit.
endif.
assign component 'ERNAM' of structure <ls_alv> to field-symbol(<lv_ernam>).
if sy-subrc = 0.
<lv_ernam> = sy-uname.
endif.
assign component 'CHANGED' of structure <ls_alv> to field-symbol(<lv_changed>).
if sy-subrc = 0.
<lv_changed> = 'X'.
endif.
endform.
*&---------------------------------------------------------------------*
*& FORM FRM_DATA_DEL
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_data_del .
data:
lo_dtab_ref type ref to data,
lo_dtab_s_ref type ref to data.
field-symbols <lt_dtab> type standard table.
field-symbols <ls_dtab> type any.
call method cl_alv_table_create=>create_dynamic_table
exporting
* I_STYLE_TABLE = 'X' "会多出一列DEEP STRUCTURE
it_fieldcatalog = gt_fieldcat[]
importing
ep_table = lo_dtab_ref.
assign lo_dtab_ref->* to <lt_dtab>.
create data lo_dtab_s_ref like line of <lt_dtab>.
assign lo_dtab_s_ref->* to <ls_dtab>.
loop at <gt_alv> assigning field-symbol(<ls_alv>).
assign component 'SEL' of structure <ls_alv> to field-symbol(<lv_sel>).
if sy-subrc = 0.
if <lv_sel> = 'X'.
assign component 'CHANGED' of structure <ls_alv> to field-symbol(<lv_changed>).
if sy-subrc = 0.
<lv_changed> = 'X'.
endif.
assign component 'AEDAT' of structure <ls_alv> to field-symbol(<lv_aedat>).
if sy-subrc = 0.
<lv_aedat> = sy-datum.
endif.
assign component 'AEZET' of structure <ls_alv> to field-symbol(<lv_aezet>).
if sy-subrc = 0.
<lv_aezet> = sy-uzeit.
endif.
assign component 'AENAM' of structure <ls_alv> to field-symbol(<lv_aenam>).
if sy-subrc = 0.
<lv_aenam> = sy-uname.
endif.
data(lv_sel) = 'X'.
assign component 'DEL' of structure <ls_alv> to field-symbol(<lv_del>).
if sy-subrc = 0.
if <lv_del> = 'X'.
<lv_del> = ''.
else.
<lv_del> = 'X'.
endif.
else.
data(lv_delete_db) = 'X'.
move-corresponding <ls_alv> to <ls_dtab>.
append <ls_dtab> to <lt_dtab>.
endif.
endif.
endif.
endloop.
if lv_sel is initial.
message s001(00) with '至少选择一行'(119) display like 'E'.
endif.
if lv_delete_db = 'X'.
data(lv_ques) = '表'(120) && p_tab && '没有删除标识,将会直接删除表数据,是否继续?'(121).
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = '删除表数据'(122)
text_question = lv_ques
text_button_1 = '是'(123)
icon_button_1 = ' '
text_button_2 = '否'(124)
icon_button_2 = ' '
exceptions
text_not_found = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if sy-ucomm = 'OPT1'. " If you click 'YES' button it will execute
delete (p_tab) from table <lt_dtab>.
message s001(00) with '删除成功'(125).
loop at <gt_alv> assigning <ls_alv>.
assign component 'SEL' of structure <ls_alv> to <lv_sel>.
if sy-subrc = 0.
if <lv_sel> = 'X'.
delete <gt_alv>.
endif.
endif.
endloop.
elseif sy-ucomm = 'OPT2'. " If you click 'NO' button it will execute
else. " If you click 'CANCEL' button it will execute
endif.
else.
message s001(00) with '已更新删除标记,请点击保存按钮'.
endif.
endform.
form frm_data_delete .
loop at <gt_alv> assigning field-symbol(<ls_alv>).
assign component 'SEL' of structure <ls_alv> to field-symbol(<lv_sel>).
if sy-subrc = 0.
if <lv_sel> = 'X'.
data(lv_sel) = 'X'.
delete <gt_alv>.
endif.
endif.
endloop.
if lv_sel is initial.
message s001(00) with '至少选择一行'(119) display like 'E'.
else.
message s001(00) with '此操作不会删除数据库表数据,如果要删除表数据请点击删除数据'(126).
endif.
endform.
*&---------------------------------------------------------------------*
*& FORM FRM_DATA_SAVE
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& --> P1 TEXT
*& <-- P2 TEXT
*&---------------------------------------------------------------------*
form frm_data_save .
data:
lo_dtab_ref type ref to data,
lo_dtab_s_ref type ref to data.
field-symbols <lt_dtab> type standard table.
field-symbols <ls_dtab> type any.
call method cl_alv_table_create=>create_dynamic_table
exporting
* I_STYLE_TABLE = 'X' "会多出一列DEEP STRUCTURE
it_fieldcatalog = gt_fieldcat[]
importing
ep_table = lo_dtab_ref.
assign lo_dtab_ref->* to <lt_dtab>.
create data lo_dtab_s_ref like line of <lt_dtab>.
assign lo_dtab_s_ref->* to <ls_dtab>.
*先检查主键重复
loop at <gt_alv> assigning field-symbol(<ls_alv>).
assign component 'SEL' of structure <ls_alv> to field-symbol(<lv_sel>).
if sy-subrc = 0.
assign component 'CHANGED' of structure <ls_alv> to field-symbol(<lv_changed>).
if sy-subrc = 0.
if <lv_changed> = 'I'.
move-corresponding <ls_alv> to <ls_dtab>.
append <ls_dtab> to <lt_dtab>.
endif.
endif.
endif.
endloop.
if <lt_dtab> is not initial.
data lo_ref type ref to cx_root. "异常处理
data lv_text type string.
try.
insert (p_tab) from table <lt_dtab>.
catch cx_root into lo_ref.
lv_text = lo_ref->get_text( ).
rollback work.
message e001(00) with '主键重复'(127).
endtry.
rollback work.
clear <lt_dtab>.
endif.
*正式保存
loop at <gt_alv> assigning <ls_alv>.
assign component 'SEL' of structure <ls_alv> to <lv_sel>.
if sy-subrc = 0.
assign component 'CHANGED' of structure <ls_alv> to <lv_changed>.
if sy-subrc = 0.
if <lv_changed> = 'X' or <lv_changed> = 'I'.
move-corresponding <ls_alv> to <ls_dtab>.
append <ls_dtab> to <lt_dtab>.
endif.
endif.
endif.
endloop.
if <lt_dtab> is initial .
message s001(00) with '没有变更'(128).
else.
if p_tab = 'ZTFI025I'.
loop at <lt_dtab> assigning <ls_dtab>.
assign component 'TABNAME' of structure <ls_dtab> to field-symbol(<lv_tabname>).
if sy-subrc = 0.
if <lv_tabname>(1) ne 'Z'.
message e001(00) with '仅允许维护自建表'(129).
endif.
endif.
endloop.
endif.
modify (p_tab) from table <lt_dtab>.
commit work and wait .
message s001(00) with '已保存变更数据'(130).
endif.
endform.
form frm_alv_events .
gt_events-name = 'CALLER_EXIT'.
gt_events-form = 'FRM_ALV_CALLER_EXIT'.
append gt_events to gt_events.
endform.
form frm_alv_caller_exit using e_grid type slis_data_caller_exit.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = go_alvgrid.
call method go_alvgrid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
create object go_event_receiver.
set handler go_event_receiver->data_changed_finished for go_alvgrid.
endform. "FRM_ALV_CALLER_EXIT
form frm_alv_data_changed_finished using e_modified
et_good_cells type lvc_t_modi
sender type ref to cl_gui_alv_grid.
loop at et_good_cells into data(ls_cell).
read table <gt_alv> assigning field-symbol(<ls_alv>) index ls_cell-row_id.
assign component 'CHANGED' of structure <ls_alv> to field-symbol(<lv_changed>).
if sy-subrc = 0.
read table ct_fieldcat into data(ls_fieldcat) with key fieldname = ls_cell-fieldname.
if ls_fieldcat-key = 'X'.
<lv_changed> = 'I'. "insert
elseif <lv_changed> is initial.
<lv_changed> = 'X'.
endif.
endif.
assign component 'AEDAT' of structure <ls_alv> to field-symbol(<lv_aedat>).
if sy-subrc = 0.
<lv_aedat> = sy-datum.
endif.
assign component 'AEZET' of structure <ls_alv> to field-symbol(<lv_aezet>).
if sy-subrc = 0.
<lv_aezet> = sy-uzeit.
endif.
assign component 'AENAM' of structure <ls_alv> to field-symbol(<lv_aenam>).
if sy-subrc = 0.
<lv_aenam> = sy-uname.
endif.
* IF <GT_ALV>-FLAG IS INITIAL.
* <GT_ALV>-FLAG = 'U'.
* MODIFY <GT_ALV> INDEX SY-TABIX TRANSPORTING FLAG .
* ENDIF.
* IF LS_CELL-FIELDNAME = 'WMENG'.
* <GT_ALV>-WMENG_CHANGE = 'X'.
* MODIFY <GT_ALV> INDEX SY-TABIX TRANSPORTING WMENG_CHANGE .
* ENDIF.
endloop.
* PERFORM FRM_ALV_REFRESH.
endform. " DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
*& Form FRM_SEL_PBO
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
form frm_sel_pbo .
*第一次进来判断是否是直接调用
if gv_direct is initial.
if gv_no_config = 'X' and p_tab is not initial.
gv_direct = 'T'.
else.
gv_direct = 'F'.
endif.
endif.
if gv_direct = 'T'.
select single ddtext
from dd02t
where tabname = @p_tab and ddlanguage = @sy-langu
into @sy-title.
endif.
* loop at screen.
* if screen-name = 'P_TAB'.
* screen-input = 0.
* modify screen.
* endif.
* endloop.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_SEL_PAI
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
form frm_sel_field_p_tab .
if gv_direct = 'T'. "单表维护
else. "从配置表进来
read table gt_ztfi025i with key tabname = p_tab.
if sy-subrc ne 0.
message e001(00) with '请从搜索帮助选择正确的表名'(131).
endif.
endif.
if p_tab(1) ne 'Z'.
message e001(00) with '仅可维护自建表'(132).
endif.
endform.
*&---------------------------------------------------------------------*
*& Form FRM_SEL_F4
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
form frm_sel_f4 .
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'TABNAME'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_TAB'
value_org = 'S'
* multiple_choice = ''
tables
value_tab = gt_ztfi025i
* FIELD_TAB =
* return_tab = it_return
.
endform.
form frm_alv_style.
loop at <gt_alv> assigning field-symbol(<ls_alv>).
clear:gs_styl,gt_styl[].
loop at ct_fieldcat into data(ls_fieldcat) where key = 'X'.
perform frm_build_style using ls_fieldcat-fieldname cl_gui_alv_grid=>mc_style_disabled.
endloop.
assign component 'TSTYL' of structure <ls_alv> to field-symbol(<lv_tstyl>).
<lv_tstyl> = gt_styl.
endloop.
endform.
form frm_build_style using fname style.
clear gs_styl.
gs_styl-fieldname = fname.
gs_styl-style = style.
insert gs_styl into table gt_styl.
endform.
form frm_data_transport.
data: lv_order type e070-trkorr,
lv_task type e070-trkorr,
lt_ko200 type standard table of ko200,
lt_e071k type standard table of e071k,
lv_key type trobj_name,
lv_objects_appendable type trpari-s_checked.
loop at <gt_alv> assigning field-symbol(<ls_alv>).
assign component 'SEL' of structure <ls_alv> to field-symbol(<lv_sel>).
if sy-subrc = 0.
if <lv_sel> = 'X'.
data(lv_sel) = 'X'.
loop at gt_fieldcat into data(ls_fieldcat) where key = 'X'.
assign component ls_fieldcat-fieldname of structure <ls_alv> to field-symbol(<lv_field>).
if ls_fieldcat-fieldname = 'MANDT' and <lv_field> is initial.
<lv_field> = sy-mandt.
endif.
lv_key = lv_key && <lv_field>.
endloop.
lt_e071k = value #( ( pgmid = 'R3TR' object = 'TABU'
objname = p_tab mastertype = 'TABU' mastername = p_tab
tabkey = lv_key
sortflag = '2' ) ).
clear lv_key.
endif.
endif.
endloop.
if lv_sel is initial.
message s001(00) with '至少选择一行'(119) display like 'E'.
else.
lt_ko200 = value #( ( pgmid = 'R3TR' object = 'TABU' obj_name = p_tab objfunc = 'K' ) ).
call function 'VIM_TR_OBJECTS_CHECK'
importing
we_order = lv_order
we_task = lv_task
we_objects_appendable = lv_objects_appendable
tables
wt_ko200 = lt_ko200
* wt_e071k = lt_e071k
* tt_tadir = lt_tadir
exceptions
cancel_edit_other_error = 1
show_only_other_error = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
call function 'VIM_TR_OBJECTS_INSERT'
importing
we_order = lv_order
we_task = lv_task
tables
wt_ko200 = lt_ko200
wt_e071k = lt_e071k
exceptions
cancel_edit_other_error = 1
show_only_other_error = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
message s001(00) with '已写入传输请求'.
endif.
endif.
endform.
post SAP-Garson
原文链接:https://blog.csdn.net/cylcylcylcylwo/article/details/124475708文章来自于网络,如果侵犯了您的权益,请联系站长删除!