Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185176
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

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,"修改对象目录条目"

阅读(3107) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~