alv 修改/ oo对象/ 双击事件/更改事件

**---------------------------------------------------------------------*
*  PROGRAM ID          : ZPS048
*  APPLICATION NAME    : ZPS048
*  AUTHOR              : Chen Fei
*  PROGRAM TYPE        : REPORT
*  DESCRIPTION         : 退役设备选用和解冻
*  CREATED TIME        : 2009-02-20
**---------------------------------------------------------------------*
REPORT ZPS048.

INCLUDE ZPS048TOP.
INCLUDE ZPS048O01.
INCLUDE ZPS048I01.
INCLUDE ZPS048F01.

START-OF-SELECTION.

  PERFORM GET_DATA.
  PERFORM DISPLAY_ALV.
  CALL SCREEN '9000'.


**---------------------------------------------------------------------*
*  PROGRAM ID          : ZPS048
*  APPLICATION NAME    : ZPS048TOP
*  AUTHOR              : Chen Fei
*  PROGRAM TYPE        : REPORT
*  DESCRIPTION         : 可利用退役设备查询台帐
*  CREATED TIME        : 2009-02-20
**---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.  "for event handling

TABLES: MCHB,            " 批量库存
        ZTY_MASTER_DATA, " 设备退役在利用主数据表
        ZTY_LOG_DATA,    " 设备退役在利用日志表
        ZTY_EQUIP_TYPE,  " PMS设备类型
        T001W,
        MARA,
        ANLC.            "资产值字段

DATA: IT_FIELDCAT     TYPE  LVC_T_FCAT WITH HEADER LINE,
       IT_LAYOUT      TYPE  LVC_S_LAYO.

DATA: CONTAINER TYPE SCRFNAME VALUE 'SCR01',     "在屏幕中创建的容器名称
      CONTAINER1 TYPE SCRFNAME VALUE 'SCR02',    "在屏幕中创建的容器名称1
      ALV_GRID  TYPE REF TO CL_GUI_ALV_GRID,
      CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER, "实例化一个容器
      CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"实例化一个容器1
      G_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER,
      G_FCPOS TYPE I VALUE 0.

TYPES: BEGIN OF ST01,
          MATNR       LIKE MCHB-MATNR,                   " 物料编码
          MAKTX       LIKE MAKT-MAKTX,                      " 物料描述
          EQUI_STATUS LIKE ZTY_MASTER_DATA-EQUI_STATUS,     " 状态
          STATXT(20)  TYPE C,                               " 状态描述
          NAME1       LIKE T001W-NAME1,                   " 所属单位
          LGORT       LIKE MCHB-LGORT,                      " 库存地点
          EQUNR       LIKE ZTY_MASTER_DATA-EQUNR,       " 设备编号
          NAME2       LIKE ZTY_EQUIP_TYPE-NAME1,            " 设备类型描述
          SUBTYPE     LIKE ZTY_MASTER_DATA-SUBTYPE,         " 设备类型ID
          ANLN1       LIKE ZTY_MASTER_DATA-ANLN1,       " 资产编号
          ANLN2       LIKE ZTY_MASTER_DATA-ANLN2,       " 资产次级编号
          NTVAL       LIKE ZTY_MASTER_DATA-NTVAL,       " 资产净值
          DUE_DATE    LIKE ZTY_MASTER_DATA-DUE_DATE,       " 评估寿命到期日
          REQU_ID     LIKE ZTY_MASTER_DATA-REQU_ID,
         SEL_DISABLE  TYPE LVC_T_STYL,
         LAST_MODIFIER LIKE ZTY_MASTER_DATA-LAST_MODIFIER,  " 最后的修改人
       END OF ST01.

DATA: IT_TAB TYPE TABLE OF ST01 WITH HEADER LINE,
      ST_TAB TYPE          ST01.

TYPES: BEGIN OF ST02,
         SEL TYPE C,
         CSTXT(12) TYPE C,
         CSVAL(6)  TYPE C,
         CSDW(6)   TYPE C,
      END   OF ST02.

DATA: IT_TABLE TYPE TABLE OF ST02 WITH HEADER LINE,
      ST_TABLE TYPE          ST02.

DATA: P_TXT01(35) TYPE  C,
      P_TXT02(35) TYPE  C,
      P_TXT03(35) TYPE  C,
      P_INDEX LIKE SY-TABIX.

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS  P_TYPE   FOR ZTY_EQUIP_TYPE-SUBTYPE.   " 设备类型
SELECT-OPTIONS  P_WERK   FOR T001W-WERKS.              " 所属单位
SELECT-OPTIONS  P_MATNR  FOR MARA-MATNR.               " 物料编号
SELECT-OPTIONS  P_EQUNR  FOR ZTY_MASTER_DATA-EQUNR.    " 设备编号
PARAMETERS:     P_YEARS(2) TYPE C,
                P_STATUS(2) TYPE C,
                P_CHECK1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BLK1.

**---------------------------------------------------------------------*
*  PROGRAM ID          : ZPS048
*  APPLICATION NAME    : ZPS048O01
*  AUTHOR              : Chen Fei
*  PROGRAM TYPE        : REPORT
*  DESCRIPTION         : 可利用退役设备查询台帐
*  CREATED TIME        : 2009-02-20
**---------------------------------------------------------------------*
*&      Module  STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9001 OUTPUT.
  SET PF-STATUS 'ST01'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_9002  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9002 OUTPUT.
  SET PF-STATUS 'ST01'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_9002  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
  SET PF-STATUS 'ALVSTATUS'.
  SET TITLEBAR 'T01'.

ENDMODULE.                 " STATUS_9000  OUTPUT
*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION.

  PUBLIC SECTION.
    METHODS: CATCH_DOUBLECLICK
             FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
         IMPORTING
            E_COLUMN
            ES_ROW_NO
            SENDER.

ENDCLASS.                    "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

  METHOD CATCH_DOUBLECLICK.

    READ TABLE IT_TAB INTO ST_TAB INDEX ES_ROW_NO-ROW_ID.   "读取当前行

    CALL SCREEN '9003'
       STARTING AT 10 10
         ENDING AT 60 20.

  ENDMETHOD.                    "catch_doubleclick

ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
*&---------------------------------------------------------------------*
*&      Module  INIT_SCREEN  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INIT_SCREEN OUTPUT.

  IF CUSTOM_CONTAINER  IS INITIAL.
    CREATE OBJECT CUSTOM_CONTAINER
      EXPORTING
        CONTAINER_NAME = CONTAINER.

    IF ALV_GRID IS INITIAL.
      CREATE OBJECT ALV_GRID
        EXPORTING
          I_PARENT = CUSTOM_CONTAINER.

      CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IS_LAYOUT       = IT_LAYOUT
        CHANGING
          IT_OUTTAB       = IT_TAB[]
          IT_FIELDCATALOG = IT_FIELDCAT[].

      CREATE OBJECT G_EVENT_RECEIVER.
      SET HANDLER G_EVENT_RECEIVER->CATCH_DOUBLECLICK FOR ALV_GRID.

    ENDIF.

  ENDIF.

ENDMODULE.                 " INIT_SCREEN  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  STATUS_9003  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9003 OUTPUT.
  SET PF-STATUS 'ST03'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_9003  OUTPUT


**---------------------------------------------------------------------*
*  PROGRAM ID          : ZPS048
*  APPLICATION NAME    : ZPS048I01
*  AUTHOR              : Chen Fei
*  PROGRAM TYPE        : REPORT
*  DESCRIPTION         : 可利用退役设备查询台帐
*  CREATED TIME        : 2009-02-20
**---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.

  CASE SY-UCOMM.
    WHEN 'EXE'.
      PERFORM INPUT_DATA1.
      LEAVE TO SCREEN 0.
    WHEN 'EXIT' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9002 INPUT.

  CASE SY-UCOMM.
    WHEN 'EXE'.
      PERFORM INPUT_DATA2.
      LEAVE TO SCREEN 0.
    WHEN 'EXIT' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.

  DATA: ET_INDEX_ROWS TYPE LVC_T_ROW,
        ST_INDEX_ROWS TYPE LINE OF LVC_T_ROW.

  CASE SY-UCOMM.

    WHEN 'LOCK'.
      CALL METHOD ALV_GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = ET_INDEX_ROWS.

      IF NOT ET_INDEX_ROWS IS INITIAL.
        LOOP AT ET_INDEX_ROWS INTO ST_INDEX_ROWS.
          READ TABLE IT_TAB INTO ST_TAB INDEX ST_INDEX_ROWS-INDEX.   "读取当前行
          MOVE ST_INDEX_ROWS-INDEX TO P_INDEX.
        ENDLOOP.

        IF ST_TAB-EQUI_STATUS <> '2'.
          CALL SCREEN '9001' STARTING AT 10 10 ENDING AT 60 10.
        ELSE.
          MESSAGE S398(00) WITH '所选设备已是冻结状态,请重新选择!'.
        ENDIF.

      ELSE.
        MESSAGE S398(00) WITH '请选择一条数据!'.
      ENDIF.

      CLEAR: ST_TAB, ST_INDEX_ROWS, P_INDEX.

    WHEN 'UNLOCK'.
      CALL METHOD ALV_GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = ET_INDEX_ROWS.

      IF NOT ET_INDEX_ROWS IS INITIAL.
        LOOP AT ET_INDEX_ROWS INTO ST_INDEX_ROWS.
          READ TABLE IT_TAB INTO ST_TAB INDEX ST_INDEX_ROWS-INDEX.   "读取当前行
          MOVE ST_INDEX_ROWS-INDEX TO P_INDEX.
        ENDLOOP.

        IF ST_TAB-EQUI_STATUS <> '1'.
          CALL SCREEN '9002' STARTING AT 10 10 ENDING AT 60 10.
        ELSE.
          MESSAGE S398(00) WITH '所选设备已是入库状态,请重新选择!'.
        ENDIF.

      ELSE.
        MESSAGE S398(00) WITH '请选择一条数据!'.
      ENDIF.

      CLEAR: ST_TAB, ST_INDEX_ROWS, P_INDEX.

    WHEN 'BACK'.
      LEAVE TO SCREEN 0.

    WHEN 'CANCEL' OR 'EXIT'.
      LEAVE PROGRAM.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9003  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9003 INPUT.

  CASE SY-UCOMM.

    WHEN 'CLICK' OR 'CANCEL'.
      LEAVE TO SCREEN 0.

  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9003  INPUT

**---------------------------------------------------------------------*
*  PROGRAM ID          : ZPS048
*  APPLICATION NAME    : ZPS048F01
*  AUTHOR              : Chen Fei
*  PROGRAM TYPE        : REPORT
*  DESCRIPTION         : 可利用退役设备查询台帐
*  CREATED TIME        : 2009-02-20
**---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
FORM GET_DATA .

  DATA: L_LGORT TYPE MCHB-LGORT,
        IT_TYPE TYPE TABLE OF ZTY_EQUIP_TYPE WITH HEADER LINE.

  REFRESH IT_TYPE[].

  SELECT *
    INTO TABLE IT_TYPE
    FROM ZTY_EQUIP_TYPE.

  IF P_CHECK1 <> 'X'.

    SELECT T1~MATNR T3~MAKTX T1~EQUI_STATUS T4~NAME1
           T1~EQUNR T1~ANLN1 T1~ANLN2       T1~NTVAL
           T1~DUE_DATE T1~REQU_ID T2~LGORT  T1~SUBTYPE
           T1~LAST_MODIFIER
           INTO CORRESPONDING FIELDS OF TABLE IT_TAB
      FROM ZTY_MASTER_DATA AS T1
     INNER JOIN MAKT  AS T3 ON T1~MATNR   = T3~MATNR
     INNER JOIN T001W AS T4 ON T1~SWERK  = T4~WERKS
     INNER JOIN MCHB  AS T2 ON T1~MATNR = T2~MATNR
                     AND T1~REQU_ID = T2~CHARG
     WHERE T1~SUBTYPE IN P_TYPE
       AND T1~SWERK IN P_WERK
       AND T1~MATNR IN P_MATNR
       AND T1~EQUNR IN P_EQUNR
       AND T1~EQUI_STATUS EQ '1'
       AND T1~EQUI_USE EQ '2'.

  ELSE.

    SELECT T1~MATNR T3~MAKTX T1~EQUI_STATUS T4~NAME1
           T1~EQUNR T1~ANLN1 T1~ANLN2
           T1~DUE_DATE T1~REQU_ID T2~LGORT  T1~SUBTYPE
           T1~LAST_MODIFIER
      INTO CORRESPONDING FIELDS OF TABLE IT_TAB
      FROM ZTY_MASTER_DATA AS T1
     INNER JOIN MAKT  AS T3 ON T1~MATNR   = T3~MATNR
     INNER JOIN T001W AS T4 ON T1~SWERK  = T4~WERKS
     INNER JOIN MCHB  AS T2 ON T1~MATNR = T2~MATNR
                           AND T1~REQU_ID = T2~CHARG
     WHERE T1~SUBTYPE IN P_TYPE
       AND T1~SWERK IN P_WERK
       AND T1~MATNR IN P_MATNR
       AND T1~EQUNR IN P_EQUNR
       AND T1~EQUI_STATUS IN ('1', '2')
       AND T1~EQUI_USE = 2.

  ENDIF.


  DATA: ANSWL LIKE ANLC-ANSWL,   " 该年度影响资产值的业务
        KANSW LIKE ANLC-KANSW,   " 累积购置和生产费用
        KNAFA LIKE ANLC-KNAFA.   " 累计正常折旧

  LOOP AT IT_TAB.
    READ TABLE IT_TYPE WITH KEY SUBTYPE = IT_TAB-SUBTYPE
                                MANDT   = SY-MANDT.
    MOVE IT_TYPE-NAME1 TO IT_TAB-NAME2.

    CASE IT_TAB-EQUI_STATUS.
      WHEN '1'.
        MOVE '入库可用' TO IT_TAB-STATXT.
      WHEN '2'.
        MOVE '冻结'     TO IT_TAB-STATXT.
    ENDCASE.

    SELECT SINGLE ANSWL KANSW KNAFA
      INTO (ANSWL, KANSW, KNAFA)
      FROM ANLC
     WHERE ANLC~ANLN1 = IT_TAB-ANLN1
       AND ANLC~ANLN2 = IT_TAB-ANLN2
       AND ANLC~GJAHR = SY-DATUM.

    IT_TAB-NTVAL = ANSWL + KANSW + ( KNAFA ).

    MODIFY IT_TAB.

    CLEAR: ANSWL, KANSW, KNAFA, IT_TAB-NTVAL.

  ENDLOOP.

ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV .

  PERFORM FRM_LAYOUT.
  PERFORM FRM_FILL_FIELDCAT.

ENDFORM.                    " DISPLAY_ALV
*&---------------------------------------------------------------------*
*&      Form  FRM_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_LAYOUT .

  IT_LAYOUT-SEL_MODE = 'B'.
  IT_LAYOUT-CWIDTH_OPT = 'X'.


ENDFORM.                    " FRM_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  FRM_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*s
FORM FRM_FIELDCAT USING TABLENAME FIELDNAME OUTPUTLEN SELTEXT FIX_COLUMN.

  DATA: TEXTLEN TYPE I.
  CLEAR IT_FIELDCAT.

  G_FCPOS = G_FCPOS + 1.

  IT_FIELDCAT-COL_POS = G_FCPOS.
  IT_FIELDCAT-FIELDNAME = FIELDNAME.
  IT_FIELDCAT-TABNAME = TABLENAME.
  IT_FIELDCAT-OUTPUTLEN = OUTPUTLEN.

  IF FIX_COLUMN = 'X'.
    IT_FIELDCAT-NO_ZERO  = 'X'.
  ENDIF.

  TEXTLEN = STRLEN( SELTEXT ).
  IF TEXTLEN <= 10.
    IT_FIELDCAT-SCRTEXT_S = SELTEXT.
  ELSEIF TEXTLEN <= 20.
    IT_FIELDCAT-SCRTEXT_M = SELTEXT.
  ELSE.
    IT_FIELDCAT-SCRTEXT_L = SELTEXT.
  ENDIF.

  IF FIELDNAME = 'MARK'.
    IT_FIELDCAT-MARK = 'X'.
  ENDIF.
*  IF FIELDNAME = 'SEL'.
*    IT_FIELDCAT-CHECKBOX = 'X'.
*    IT_FIELDCAT-EDIT = 'X'.
*  ENDIF.

  APPEND IT_FIELDCAT.

ENDFORM .                    "FRM_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  FRM_FILL_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*s
FORM FRM_FILL_FIELDCAT .

  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'REQU_ID' '2' '入库申请单号' ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'MATNR' '2' '物料编码' 'X'.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'MAKTX' '2' '物料描述'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'STATXT' '2' '状态' 'R' .
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'NAME1' '2' '所属单位'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'LGORT' '2' '库存地点'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'EQUNR' '2' '设备编号'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'NAME2' '2' '设备类型'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'ANLN1' '2' '资产编号'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'ANLN2' '2' '资产次级编号'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'NTVAL'  '2' '资产净值'  ''.
  PERFORM FRM_FIELDCAT USING 'IT_TAB' 'DUE_DATE' '2' '评估寿命到期日' ''.

ENDFORM.                    " FRM_FILL_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  INPUT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM INPUT_DATA1.

  DATA: IT_TEMP TYPE TABLE OF ZTY_LOG_DATA WITH HEADER LINE,
        ST_TEMP TYPE          ZTY_LOG_DATA,
        L_NO(10)    TYPE C.

*** 判断修改人是否是当前用户
  IF ST_TAB-LAST_MODIFIER = SY-UNAME.

    SELECT MAX( LOG_NO )
      INTO L_NO
      FROM ZTY_LOG_DATA
      WHERE ZTY_LOG_DATA~REQU_ID = ST_TAB-REQU_ID.
    L_NO = L_NO + 1.

    MOVE SY-MANDT     TO ST_TEMP-MANDT.
    MOVE ST_TAB-REQU_ID TO ST_TEMP-REQU_ID.
    MOVE L_NO         TO ST_TEMP-LOG_NO.
    MOVE '05'         TO ST_TEMP-ZBTYPE.
    MOVE SY-DATUM     TO ST_TEMP-OP_DATE.
    MOVE SY-UNAME     TO ST_TEMP-USNAM.
    MOVE P_TXT01      TO ST_TEMP-ZREMARK.
    APPEND ST_TEMP TO IT_TEMP.

    INSERT ZTY_LOG_DATA FROM TABLE IT_TEMP ACCEPTING DUPLICATE KEYS.

    UPDATE ZTY_MASTER_DATA
       SET: EQUI_STATUS = '2'
            FREEZE_DATE = SY-DATUM
            FREEZE_USER = SY-UNAME
            LAST_MODIFY_DATE = SY-DATUM
            LAST_MODIFIER = SY-UNAME
            PSPID =  P_TXT02
     WHERE REQU_ID = ST_TAB-REQU_ID.

    IF SY-SUBRC = 0.
      MOVE '2'      TO ST_TAB-EQUI_STATUS.
      MOVE '冻结'   TO ST_TAB-STATXT.
      MOVE SY-UNAME TO ST_TAB-LAST_MODIFIER.
      MESSAGE S398(00) WITH '设备冻结操作成功!'.
    ELSE.
      MESSAGE S398(00) WITH '设备冻结操作失败!'.
    ENDIF.

    MODIFY IT_TAB INDEX P_INDEX FROM ST_TAB.
    CLEAR ST_TEMP.

* 不是当前用户时
  ELSE.
    MESSAGE S398(00) WITH '你无权解冻当前设备!'.
  ENDIF.

*** 同步内表和界面的数据
  CALL METHOD ALV_GRID->REFRESH_TABLE_DISPLAY.


ENDFORM.                    " INPUT_DATA1
*&---------------------------------------------------------------------*
*&      Form  INPUT_DATA2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM INPUT_DATA2 .

  DATA: IT_TEMP TYPE TABLE OF ZTY_LOG_DATA WITH HEADER LINE,
        ST_TEMP TYPE          ZTY_LOG_DATA,
        L_NO    TYPE N.

*** 判断修改人是否是当前用户
  IF ST_TAB-LAST_MODIFIER = SY-UNAME.

    SELECT MAX( LOG_NO )
      INTO L_NO
      FROM ZTY_LOG_DATA.
    L_NO = L_NO + 1.

    MOVE SY-MANDT     TO ST_TEMP-MANDT.
    MOVE IT_TAB-REQU_ID TO ST_TEMP-REQU_ID.
    MOVE L_NO         TO ST_TEMP-LOG_NO.
    MOVE '06'         TO ST_TEMP-ZBTYPE.
    MOVE SY-DATUM     TO ST_TEMP-OP_DATE.
    MOVE SY-UNAME     TO ST_TEMP-USNAM.
    MOVE P_TXT03      TO ST_TEMP-ZREMARK.
    APPEND ST_TEMP TO IT_TEMP.

    INSERT ZTY_LOG_DATA FROM TABLE IT_TEMP ACCEPTING DUPLICATE KEYS.

    UPDATE ZTY_MASTER_DATA
      SET: EQUI_STATUS = '1'
           LAST_MODIFY_DATE = SY-DATUM
           LAST_MODIFIER = SY-UNAME
           PSPID =  ''
     WHERE REQU_ID = ST_TAB-REQU_ID.

    IF SY-SUBRC = 0.
      MOVE '1'        TO ST_TAB-EQUI_STATUS.
      MOVE '入库可用' TO ST_TAB-STATXT.
      MOVE SY-UNAME   TO ST_TAB-LAST_MODIFIER.
      MESSAGE S398(00) WITH '设备解冻操作成功!'.
    ELSE.
      MESSAGE S398(00) WITH '设备解冻操作失败!'.
    ENDIF.

    MODIFY IT_TAB INDEX P_INDEX FROM ST_TAB.
    CLEAR ST_TEMP.
** 不是当前用户时
  ELSE.
    MESSAGE S398(00) WITH '你无权解冻当前设备!'.
  ENDIF.

*   *** 同步内表和界面的数据
  CALL METHOD ALV_GRID->REFRESH_TABLE_DISPLAY.


ENDFORM.                    " INPUT_DATA2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值