Chinaunix首页 | 论坛 | 博客
  • 博客访问: 699496
  • 博文数量: 255
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 2811
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-09 13:29
个人简介

IT业行者,行者无疆

文章分类

全部博文(255)

文章存档

2011年(121)

2010年(134)

我的朋友

分类:

2011-06-20 17:23:27

*&---------------------------------------------------------------------*
*& Report  YGYTEST068
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  YGYTEST068.
DATA:OK_CODE TYPE SY-UCOMM,
     SAVE_OK LIKE OK_CODE.
TABLES SPFLI.
DATA LS_SPFLI TYPE SPFLI.
DATA WA_SPFLI TYPE TABLE OF SPFLI.
DATA WADEL_SPFLI TYPE TABLE OF SPFLI.
SELECT * INTO TABLE WA_SPFLI FROM SPFLI.
DATA:WA_CONTAINER TYPE SCRFNAME VALUE 'ALVDATA',
     ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
     WA_CUSTOM_CONTAINER TYPE REF TO  CL_GUI_CUSTOM_CONTAINER.
DATA WA_LAYOUT TYPE LVC_S_LAYO.
WA_LAYOUT-EDIT = 'X'.
CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.
DATA EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.
CLASS LCL_EVENT_RECEIVER DEFINITION.
  PUBLIC SECTION.
    TYPES:DEL_ROWS TYPE STANDARD TABLE OF SPFLI.
    DATA:DDEL_ROWS TYPE STANDARD TABLE OF SPFLI.
  METHODS:
    HANDLE_DATA_CHANGED
      FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
        IMPORTING ER_DATA_CHANGED.
  METHODS:
    UPDATE_DELTA_TABLES
      IMPORTING PR_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
  METHODS:
    GET_DELETED_ROWS
      EXPORTING
        DELETED_ROWS TYPE DEL_ROWS.
ENDCLASS.
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
  METHOD HANDLE_DATA_CHANGED.
*    CALL METHOD UPDATE_DELTA_TABLES.
    CALL METHOD UPDATE_DELTA_TABLES( ER_DATA_CHANGED ).
  ENDMETHOD.
  METHOD UPDATE_DELTA_TABLES.
    DATA:L_DEL_ROW TYPE LVC_S_MOCE.
    LOOP AT PR_DATA_CHANGED->MT_DELETED_ROWS INTO L_DEL_ROW.
      READ TABLE WA_SPFLI INTO LS_SPFLI INDEX L_DEL_ROW-ROW_ID.
      IF SY-SUBRC NE 0.
        MESSAGE E208(00) WITH '处理错误'.
      ELSE.
        APPEND LS_SPFLI TO DDEL_ROWS.
      ENDIF.
    ENDLOOP.
  ENDMETHOD.
  METHOD GET_DELETED_ROWS.
    DELETED_ROWS = ME->DDEL_ROWS.
  ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
  CALL SCREEN 100.
  WRITE / '删除的内表记录:'.
  WRITE / '--------'.
  CALL METHOD EVENT_RECEIVER->GET_DELETED_ROWS
    IMPORTING DELETED_ROWS = WADEL_SPFLI.
  LOOP AT WADEL_SPFLI INTO SPFLI.
    WRITE: / SPFLI-CARRID,SPFLI-CONNID,SPFLI-CITYFROM.
  ENDLOOP.
  WRITE : / '更新后的内表记录:'.
  WRITE: / '-------'.
  LOOP AT WADEL_SPFLI INTO SPFLI.
    WRITE: / SPFLI-CARRID,SPFLI-CONNID,SPFLI-CITYFROM.
  ENDLOOP.
MODULE USER_COMMAND_0100 INPUT.
  SAVE_OK = OK_CODE.
  CLEAR OK_CODE.
  CASE SAVE_OK.
    WHEN 'EXIT'.
      DATA L_RET VALUE 'X'.
      CALL METHOD ALV_GRID->CHECK_CHANGED_DATA
        IMPORTING E_VALID = L_RET.
      LEAVE TO SCREEN 0.
    WHEN 'SAVE'.
      MODIFY SPFLI FROM TABLE WA_SPFLI.
      IF SY-SUBRC NE 0 .
         MESSAGE I005(YMESS) WITH '更新数据错误!'.
         EXIT.
      ELSE.
        MESSAGE I005(YMESS) WITH '更新数据OK!'.
      ENDIF.
      DELETE SPFLI FROM TABLE WADEL_SPFLI.
      IF SY-SUBRC NE 0 .
         MESSAGE I005(YMESS) WITH '更新数据错误!'.
         EXIT.
      ELSE.
        MESSAGE I005(YMESS) WITH '更新数据OK!'.
      ENDIF.
  ENDCASE.
ENDMODULE.
MODULE STATUS_0100 OUTPUT.
*  SET PF-STATUS 'STATUS1'.
  IF WA_CUSTOM_CONTAINER IS INITIAL.
    CREATE OBJECT WA_CUSTOM_CONTAINER
      EXPORTING CONTAINER_NAME = WA_CONTAINER.
    CREATE OBJECT ALV_GRID
      EXPORTING I_PARENT = WA_CUSTOM_CONTAINER.
    CREATE OBJECT EVENT_RECEIVER.
    SET HANDLER EVENT_RECEIVER->HANDLE_DATA_CHANGED FOR ALV_GRID.
    CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING I_STRUCTURE_NAME = 'SPFLI'
        IS_LAYOUT = WA_LAYOUT
      CHANGING IT_OUTTAB = WA_SPFLI.
  ENDIF.
ENDMODULE.
阅读(2929) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~