ABAP顾问
分类:
2009-04-01 15:01:46
REPORT z_barry_change_srcsystem.
TYPE-POOLS: slis.
DATA: gd_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: sla TYPE slis_layout_alv ,
ivariant LIKE disvariant,
i_repid LIKE sy-repid .
DATA: BEGIN OF itab OCCURS 0 ,
pgmid LIKE tadir-pgmid ,
object LIKE tadir-object ,
obj_name LIKE tadir-obj_name ,
srcsystem LIKE tadir-srcsystem ,
END OF itab.
SELECT-OPTIONS: s_pgmid FOR itab-pgmid ,
s_object FOR itab-object ,
s_objnam FOR itab-obj_name OBLIGATORY .
START-OF-SELECTION.
PERFORM getdata.
PERFORM display.
*&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
FORM getdata.
SELECT pgmid object obj_name srcsystem
FROM tadir INTO CORRESPONDING FIELDS OF TABLE itab
WHERE pgmid IN s_pgmid AND
object IN s_object AND
obj_name IN s_objnam .
ENDFORM. "getdata
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
FORM display.
sla-colwidth_optimize = 'X'.
sla-zebra = 'X'.
i_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'ITAB'
i_inclname = i_repid
CHANGING
ct_fieldcat = gd_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LOOP AT gd_fieldcat .
IF gd_fieldcat-fieldname = 'SRCSYSTEM'.
gd_fieldcat-edit = 'X'.
ENDIF.
MODIFY gd_fieldcat.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
it_fieldcat = gd_fieldcat[]
i_save = 'A'
is_variant = ivariant
is_layout = sla
i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
READ TABLE itab INDEX rs_selfield-tabindex.
CASE r_ucomm.
WHEN '&DATA_SAVE'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
rs_selfield-row_stable = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-refresh = 'X'.
LOOP AT itab.
UPDATE tadir SET srcsystem = itab-srcsystem
WHERE pgmid = itab-pgmid AND
object = itab-object AND
obj_name = itab-obj_name .
ENDLOOP.
ENDCASE.
ENDFORM. "user_command
或者Tcode:SE03,"修改对象目录条目"