精华内容
下载资源
问答
  • C# 分类存档文件 源码

    2018-10-30 08:55:46
    机关单位用来分类存档各种word文档,pdf文档的源码,可以自定义存放规则,一共有三种规则,等于 以...开头 公文标准分割 包含文件名
  • 存档属性取消的操作步骤:1、选择一个文件夹,点击鼠标右键;2、在弹出的菜单中选属性;3、新窗口中点击高级按钮,第一个选项不勾选就取消存档属性。计算机(computer)俗称电脑,是现代一种用于高速计算的电子计算...

    大家好,我是时间财富网智能客服时间君,上述问题将由我为大家进行解答。

    存档属性取消的操作步骤:

    1、选择一个文件夹,点击鼠标右键;

    2、在弹出的菜单中选属性;

    3、新窗口中点击高级按钮,第一个选项不勾选就取消存档属性。

    计算机(computer)俗称电脑,是现代一种用于高速计算的电子计算机器,可以进行数值计算,又可以进行逻辑计算,还具有存储记忆功能。是能够按照程序运行,自动、高速处理海量数据的现代化智能电子设备。由硬件系统和软件系统所组成,没有安装任何软件的计算机称为裸机。可分为超级计算机、工业控制计算机、网络计算机、个人计算机、嵌入式计算机五类,较先进的计算机有生物计算机、光子计算机、量子计算机等。

    计算机发明者约翰・冯・诺依曼。计算机是20世纪最先进的科学技术发明之一,对人类的生产活动和社会活动产生了极其重要的影响,并以强大的生命力飞速发展。它的应用领域从最初的军事科研应用扩展到社会的各个领域,已形成了规模巨大的计算机产业,带动了全球范围的技术进步,由此引发了深刻的社会变革,计算机已遍及一般学校、企事业单位,进入寻常百姓家,成为信息社会中必不可少的工具。

    展开全文
  • 代码存档

    千次阅读 2016-11-29 14:20:08
     MEINS TYPE AUFM-MEINS , "基本计量单位  DMBTR TYPE AUFM-DMBTR , "按本位币计的金额  WAERS TYPE AUFM-WAERS , "货币码  MJAHR TYPE AUFM-MJAHR , "物料凭证年度  MBLNR TYPE AUFM-MBLNR , "物料...

    REPORT  ZCHECK NO STANDARD PAGE HEADING.


    *----------------------------------------------------------------------*
    * TABLE DECLARATION
    *----------------------------------------------------------------------*
    TYPE-POOLS:SLIS.
    TYPE-POOLS VRM.
    INCLUDE <ICON>.
    TABLES :
      MKPF,
      MARA,
      ZSCKQH,
      AUFM,
      ZSCRAP,
      SSCRFIELDS.


    *&---------------------------------------------------------------------*
    * STRUCTURE DECLARATION
    *&---------------------------------------------------------------------*
    *输出结构
    TYPES : BEGIN OF T_STUC,
              BTBHA TYPE ZTBBH,   "台班班号
              CPDDH TYPE AUFNR,   "产品订单号
              YLFT TYPE ZYLFT,    "投入原材料
              HGPZL TYPE ZHGPZL,  "合格品
              DJYPZL TYPE ZDJPZL, "待检品
              BHGPZL TYPE ZBHGPZL,"不合格品
              FGHGP TYPE ZFGP,    "返工合格品
              FGDJP TYPE ZFGP,    "返工待检品
              FGBHGP TYPE ZFGP,   "返工不合格品
              BXFX TYPE ZBXFX,    "波纤
              YUL TYPE ZBXFX,    "余料
              YLCCHJ TYPE ZYLCCHJ,"原料产品产出
              DBCCL TYPE ZCCL,    "成材率
              DBHSL TYPE ZHSL,     "回收率
              DBSHL TYPE ZSHL,     "当班损耗率  "New
              RATE(16) TYPE P DECIMALS 3,"投入产出比
              ICON   TYPE CHAR10,  "错误标示【0.95,1】
              CELLCOLORS TYPE LVC_T_SCOL,"投入产出比单元格错误颜色
              ROWCOLOR TYPE CHAR04, "合计行颜色
              MATNR TYPE MATNR,    "订单产品代码
              MAKTX TYPE MAKTX,    "订单产品名称
              HOURS TYPE RU_ISMNG, "班组出勤总工时
              TIMES TYPE RU_ISMNG, "设备运行时间
              UNITS TYPE CO_ISMNGEH,"时间单位
              AS TYPE ZYLCCHJ,      "小时产量
              PRDHA TYPE PRODH_D,   "产品层次
              VTEXT TYPE BEZEI40,   "层次描述
            END OF T_STUC.


    *产品层次物料代码统计
    TYPES : BEGIN OF T_PRDHA,
              PRDHA TYPE PRODH_D,  "产品层次
              MATNR TYPE MATNR,    "订单产品代码
              VTEXT TYPE BEZEI40,  "层次描述
              MAKTX TYPE MAKTX,    "订单产品名称
              BTBHA TYPE ZTBBH,   "台班班号
              CPDDH TYPE AUFNR,   "产品订单号
              YLFT TYPE ZYLFT,    "投入原材料
              HGPZL TYPE ZHGPZL,  "合格品
              DJYPZL TYPE ZDJPZL, "待检品
              BHGPZL TYPE ZBHGPZL,"不合格品
              FGHGP TYPE ZFGP,    "返工合格品
              FGDJP TYPE ZFGP,    "返工待检品
              FGBHGP TYPE ZFGP,   "返工不合格品
              BXFX TYPE ZBXFX,    "波纤
              YUL TYPE ZBXFX,    "余料
              YLCCHJ TYPE ZYLCCHJ,"原料产品产出
              DBCCL TYPE ZCCL,    "成材率
              DBHSL TYPE ZHSL,     "回收率
              DBSHL TYPE ZSHL,     "当班损耗率  "New
              RATE(16) TYPE P DECIMALS 3,"投入产出比
              ICON   TYPE CHAR10,  "错误标示【0.95,1】
              ROWCOLOR TYPE CHAR04, "合计行颜色
              HOURS TYPE RU_ISMNG, "班组出勤总工时
              TIMES TYPE RU_ISMNG, "设备运行时间
              UNITS TYPE CO_ISMNGEH,"时间单位
              AS TYPE ZYLCCHJ,      "小时产量
    END OF T_PRDHA.


    *台班订单统计
    TYPES : BEGIN OF T_BTBHA,
              BTBHA TYPE ZTBBH,   "台班班号
              CPDDH TYPE AUFNR,   "产品订单号
              YLFT TYPE ZYLFT,    "投入原材料
              HGPZL TYPE ZHGPZL,  "合格品
              DJYPZL TYPE ZDJPZL, "待检品
              BHGPZL TYPE ZBHGPZL,"不合格品
              FGHGP TYPE ZFGP,    "返工合格品
              FGDJP TYPE ZFGP,    "返工待检品
              FGBHGP TYPE ZFGP,   "返工不合格品
              BXFX TYPE ZBXFX,    "波纤
              YUL TYPE ZBXFX,    "余料
              YLCCHJ TYPE ZYLCCHJ,"原料产品产出
              DBCCL TYPE ZCCL,    "成材率
              DBHSL TYPE ZHSL,     "回收率
              DBSHL TYPE ZSHL,     "当班损耗率  "New
              RATE(16) TYPE P DECIMALS 3,"投入产出比
              ICON   TYPE CHAR10,  "错误标示【0.95,1】
              ROWCOLOR TYPE CHAR04, "合计行颜色
              MATNR TYPE MATNR,    "订单产品代码
              MAKTX TYPE MAKTX,    "订单产品名称
              HOURS TYPE RU_ISMNG, "班组出勤总工时
              TIMES TYPE RU_ISMNG, "设备运行时间
              UNITS TYPE CO_ISMNGEH,"时间单位
              AS TYPE ZYLCCHJ,      "小时产量
      END OF T_BTBHA.


    *订单台班统计
    TYPES : BEGIN OF T_AUFNR,
              CPDDH TYPE AUFNR,   "产品订单号
              BTBHA TYPE ZTBBH,   "台班班号
              YLFT TYPE ZYLFT,    "投入原材料
              HGPZL TYPE ZHGPZL,  "合格品
              DJYPZL TYPE ZDJPZL, "待检品
              BHGPZL TYPE ZBHGPZL,"不合格品
              FGHGP TYPE ZFGP,    "返工合格品
              FGDJP TYPE ZFGP,    "返工待检品
              FGBHGP TYPE ZFGP,   "返工不合格品
              BXFX TYPE ZBXFX,    "波纤
              YUL TYPE ZBXFX,    "余料
              YLCCHJ TYPE ZYLCCHJ,"原料产品产出
              DBCCL TYPE ZCCL,    "成材率
              DBHSL TYPE ZHSL,     "回收率
              DBSHL TYPE ZSHL,     "当班损耗率  "New
              RATE(16) TYPE P DECIMALS 3,"投入产出比
              ICON   TYPE CHAR10,  "错误标示【0.95,1】
              ROWCOLOR TYPE CHAR04, "合计行颜色
              MATNR TYPE MATNR,    "订单产品代码
              MAKTX TYPE MAKTX,    "订单产品名称
              HOURS TYPE RU_ISMNG, "班组出勤总工时
              TIMES TYPE RU_ISMNG, "设备运行时间
              UNITS TYPE CO_ISMNGEH,"时间单位
              AS TYPE ZYLCCHJ,      "小时产量
    END OF T_AUFNR.


    *取数结构
    TYPES : BEGIN OF T_TAB,
              BKTXT TYPE MKPF-BKTXT , "凭证抬头文本-台班班号
              AUFNR TYPE AUFM-AUFNR , "订单号
              MATNR TYPE AUFM-MATNR , "物料号
              CHARG TYPE AUFM-CHARG , "批号
              BWART TYPE AUFM-BWART , "移动类型(库存管理)
              SHKZG TYPE AUFM-SHKZG , "借方/贷方标识
              MENGE TYPE AUFM-MENGE , "数量
              MEINS TYPE AUFM-MEINS , "基本计量单位
              DMBTR TYPE AUFM-DMBTR , "按本位币计的金额
              WAERS TYPE AUFM-WAERS , "货币码
              MJAHR TYPE AUFM-MJAHR , "物料凭证年度
              MBLNR TYPE AUFM-MBLNR , "物料凭证编号
              ZEILE TYPE AUFM-ZEILE , "物料凭证中的项目
              BUDAT TYPE AUFM-BUDAT , "凭证中的过帐日期
              WERKS TYPE AUFM-WERKS , "工厂
              LGORT TYPE AUFM-LGORT , "库存地点
              SOBKZ TYPE AUFM-SOBKZ , "特殊库存标识
              KDAUF TYPE AUFM-KDAUF , "销售订单数
              KDPOS TYPE AUFM-KDPOS , "销售订单中的项目编号
              RSNUM TYPE AUFM-RSNUM , "预留/相关需求的编号
              RSPOS TYPE AUFM-RSPOS , "预留/相关需求的项目编号
              SAKTO TYPE AUFM-SAKTO , "总帐科目编号
              MAKTX TYPE MAKT-MAKTX , "物料描述(短文本)
              USNAM TYPE MKPF-USNAM , "用户名
              SPRAS TYPE MAKT-SPRAS , "语言代码
              MARK  TYPE CHAR01,      "标志
              REMARK TYPE CHAR10,     "合格标志
              GROUP TYPE CHAR10,      "班组
            END OF T_TAB.


    *----------------
    *投入原材料     A
    *合格品        B
    *待检品        C
    *不合格品      D
    *返工合格品    E
    *返工待检品    F
    *返工不合格品  G
    *波纤         H
    *余料         I
    *----------------


    *物料代码+名称
    TYPES : BEGIN OF T_MATERIAL,
              AUFNR TYPE AUFNR,
              MATNR TYPE MATNR,
              MAKTX TYPE MAKTX,
              PRDHA TYPE PRODH_D,
              VTEXT TYPE BEZEI40,
            END OF T_MATERIAL.


    *订单确认
    TYPES:   BEGIN OF T_AFRU,
               AUFNR TYPE AFRU-AUFNR, "生产订单号
               LTXA1 TYPE AFRU-LTXA1, "台班班号
               BUDAT TYPE AFRU-BUDAT, "记账日期
               LOGRP TYPE AFRU-LOGRP, "班组
               ISM01 TYPE AFRU-ISM01, "机器分摊
               ISM02 TYPE AFRU-ISM02, "人工分摊 -- 即班组出勤工时
               ISM03 TYPE AFRU-ISM03, "用电分摊
             END OF T_AFRU.


    *&---------------------------------------------------------------------*
    * INTERNAL TABLE DECLARATION
    *&---------------------------------------------------------------------*
    DATA :
    *ALV 字段
          ITAB_CATA_TK  TYPE LVC_T_FCAT,
          I_FCAT TYPE LVC_T_FCAT,
    *输出
          I_BTBHA TYPE STANDARD TABLE OF T_STUC,
    *查找+处理
          I_DATA TYPE STANDARD TABLE OF T_TAB,
    *订单产品规格
          I_SPEC TYPE STANDARD TABLE OF T_MATERIAL,
    *订单明细
          I_DETAIL TYPE STANDARD TABLE OF  T_TAB,
    *订单确认-- 设备运行时间
          I_CONFIRM TYPE STANDARD TABLE OF T_AFRU.


    *&---------------------------------------------------------------------*
    * WORK AREA DECLARATION
    *&---------------------------------------------------------------------*
    DATA :
    *输出
          WA_BTBHA TYPE T_STUC,
    *单元格颜色设置
          WA_CELLCOLOR TYPE LVC_S_SCOL,
    *取数处理
          WA_DATA TYPE T_TAB,
    *订单产品规格
          WA_SPEC TYPE T_MATERIAL,
    *订单确认
          WA_CONFIRM TYPE T_AFRU.


    *&---------------------------------------------------------------------*
    * VARIANT DECLARATION
    *&---------------------------------------------------------------------*
    DATA :
    *功能代码
          OK_CODE TYPE SY-UCOMM,
          OK_CODE1 TYPE SY-UCOMM,
    * 容器名称
          GV_CNAME TYPE SCRFNAME VALUE 'CONTAINER',
          GV_CNAME1 TYPE SCRFNAME VALUE 'CONTAINER1',
    * 容器对象
          GV_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          GV_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    * ALV对象
          GV_ALV TYPE REF TO CL_GUI_ALV_GRID,
          GV_DETAIL TYPE REF TO CL_GUI_ALV_GRID,
    * ALV布局
          GV_LAYOUT TYPE LVC_S_LAYO,
          GV_LAYOUT1 TYPE LVC_S_LAYO,
    *投入原材料
          GV_YLFT TYPE ZYLFT,
    *合格品
          GV_HGPZL TYPE ZHGPZL,
    *待检品
          GV_DJYPZL TYPE ZDJPZL,
    *不合格品
          GV_BHGPZL TYPE ZBHGPZL,
    *返工合格品
          GV_FGHGP TYPE ZFGP,
    *返工待检品
          GV_FGDJP TYPE ZFGP,
    *返工不合格品
          GV_FGBHGP TYPE ZFGP,
    *波纤
          GV_BXFX TYPE ZBXFX,
    *余料
          GV_YUL TYPE ZBXFX,
    *开始日期
          GV_START TYPE D,
    *结束日期
          GV_FINISH TYPE D.


    *&---------------------------------------------------------------------*
    * Constant DECLARATION
    *&---------------------------------------------------------------------*
    CONSTANTS :
              C_RATE(16) TYPE P DECIMALS 3 VALUE '0.95',
              C_SIGN TYPE CHAR02 VALUE '%',
              C_SUS TYPE CHAR03 VALUE 'SUS',
              C_YUL TYPE CHAR04 VALUE '余料',
              C_WEIL TYPE CHAR04 VALUE '尾料',
              C_LASI TYPE CHAR04 VALUE 'φ6.5'.


    *----------------------------------------------------------------------*
    *       CLASS lcl_event_handler DEFINITION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    *双击事件
          HANDLE_DOUBLE_CLICK
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
          IMPORTING E_ROW E_COLUMN.


    *热点事件
        METHODS:
          HANDLE_HOTSPOT_CLICK
          FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
          IMPORTING ES_ROW_NO E_COLUMN_ID .
    ENDCLASS.                    "lcl_event_handler DEFINITION


    *----------------------------------------------------------------------*
    *       CLASS lcl_event_handler IMPLEMENTATION
    *----------------------------------------------------------------------*
    *
    *----------------------------------------------------------------------*
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
    *  Handle Double Click
      METHOD HANDLE_DOUBLE_CLICK .
        PERFORM HANDLE_DOUBLE_CLICK USING E_ROW E_COLUMN.
      ENDMETHOD .                    "handle_double_click


    * Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK.
        PERFORM HANDLE_HOTSPOT_CLICK USING  ES_ROW_NO E_COLUMN_ID.
      ENDMETHOD.                    "HANDLE_HOTSPOT_CLICK
    ENDCLASS .                    "lcl_event_handler IMPLEMENTATION
    DATA : GR_EVENT_HANDLER TYPE REF TO LCL_EVENT_HANDLER.


    *&---------------------------------------------------------------------*
    * SELECTION SCREEN DECLARATION
    *&---------------------------------------------------------------------*
    *选择屏幕的定义
    SELECTION-SCREEN FUNCTION KEY 1.
    SELECTION-SCREEN FUNCTION KEY 2.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS :
                 P_R1 RADIOBUTTON GROUP G1 USER-COMMAND UC,
                 P_R2 RADIOBUTTON GROUP G1,
                 P_R3 RADIOBUTTON GROUP G1 DEFAULT 'X' ,
                 P_R4 RADIOBUTTON GROUP G1,
                 P_R5 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B1.


    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS:
                    S_WERKS FOR AUFM-WERKS DEFAULT '1201',
                    S_MONTH FOR AUFM-BUDAT+0(6) NO-EXTENSION,
    *                S_MJAHR FOR AUFM-MJAHR,
                    S_BUDAT FOR AUFM-BUDAT.
    SELECTION-SCREEN SKIP 1.


    SELECT-OPTIONS: S_BTBHA FOR ZSCRAP-REMARK"MKPF-BKTXT
                    MATCHCODE OBJECT ZBTBHA MODIF ID M1,
                    S_AUFNR FOR AUFM-AUFNR MODIF ID M2.


    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS: S_PRDHA FOR MARA-PRDHA MODIF ID M3,
                    S_MATNR FOR MARA-MATNR MODIF ID M3.
    SELECTION-SCREEN END OF BLOCK B2.


    *查询注释
    SELECTION-SCREEN COMMENT 1(82) TEXT-003.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 3(82) TEXT-004.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 5(82) TEXT-007.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 3(82) TEXT-005.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 3(82) TEXT-006.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 3(82) TEXT-008.


    *&---------------------------------------------------------------------*
    * INITIALIZATION
    *&---------------------------------------------------------------------*
    INITIALIZATION.


      DATA :
            LV_LASTDAY TYPE VTBBEWE-DVALUT.
    *初始化
      SSCRFIELDS-FUNCTXT_01 = TEXT-009.
      SSCRFIELDS-FUNCTXT_02 = TEXT-010.


    *求上月的最后一天
      CALL FUNCTION 'FIMA_DATE_CREATE'
        EXPORTING
          I_DATE                        = SY-DATUM
    *     I_FLG_END_OF_MONTH            = ' '
    *     I_YEARS                       = 0
         I_MONTHS                      = '-1'
    *     I_DAYS                        = 0
    *     I_CALENDAR_DAYS               = 0
         I_SET_LAST_DAY_OF_MONTH       = 'X'
       IMPORTING
         E_DATE                        = LV_LASTDAY
    *     E_FLG_END_OF_MONTH            =
    *     E_DAYS_OF_I_DATE              =
                .


    *设置年月的初始值为当年的上个月
      S_MONTH-SIGN = 'I'.
      S_MONTH-OPTION = 'EQ'.
      S_MONTH-LOW = LV_LASTDAY+0(6).
      APPEND S_MONTH.




      CLEAR :       GV_YLFT ,     "投入原材料
                    GV_HGPZL ,    "合格品
                    GV_DJYPZL ,   "待检品
                    GV_BHGPZL ,   "不合格品
                    GV_FGHGP ,    "返工合格品
                    GV_FGDJP ,    "返工待检品
                    GV_FGBHGP ,   "返工不合格品
                    GV_BXFX ,     "波纤
                    GV_YUL .      "余料


    *&---------------------------------------------------------------------*
    * AT SELECTION-SCREEN OUTPUT
    *&---------------------------------------------------------------------*
    AT SELECTION-SCREEN OUTPUT.
    *设置产品类别下拉框
      PERFORM FRM_SET_PRODUCT.


    *设置是否可输
      PERFORM FRM_SET_INPUT.


    *&---------------------------------------------------------------------*
    * AT SELECTION-SCREEN
    *&---------------------------------------------------------------------*
    AT SELECTION-SCREEN.
    *警告信息
    *  IF P_R1 = 'X' OR P_R2 = 'X'.
    *    IF S_MONTH IS INITIAL AND S_BUDAT IS INITIAL
    *      AND S_BTBHA IS INITIAL AND S_AUFNR IS INITIAL.
    *      MESSAGE '此操作将查询所有记录,若要继续,请按回车键!' TYPE 'W'.
    *    ENDIF.
    *  ENDIF.


    *设置必输条件
    *  IF P_R3 = 'X'.
    *    IF S_BTBHA IS INITIAL.
    *      SET CURSOR FIELD 'S_BTBHA-LOW'.
    *      MESSAGE '请输出需要查询的台班班号!' TYPE 'S' DISPLAY LIKE 'E'.
    *      STOP.
    *    ENDIF.
    *  ELSEIF P_R4 = 'X'.
    *    IF S_AUFNR IS INITIAL.
    *      SET CURSOR FIELD 'S_AUFNR-LOW'.
    *      MESSAGE '请输入需要查询的生产订单号!' TYPE 'S' DISPLAY LIKE 'E'.
    *      STOP.
    *    ENDIF.
    *  ENDIF.


      IF SSCRFIELDS-UCOMM = 'FC01'.
        SUBMIT ZPACKAGE_COL AND RETURN VIA SELECTION-SCREEN.
      ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
        CALL TRANSACTION 'ZPP110' ."AND SKIP FIRST SCREEN.
      ENDIF.


      IF S_MONTH IS INITIAL AND S_BUDAT IS INITIAL.
        SET CURSOR FIELD 'S_MONTH-LOW'.
        MESSAGE '请输入查询条件:年月或者过账日期!' TYPE 'E'.
      ENDIF.


    *&---------------------------------------------------------------------*
    * 建立年月的搜索帮助
    *&---------------------------------------------------------------------*
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-LOW.
    *年月的搜索帮助
      DATA:L_DATE TYPE SY-DATUM.


      CALL FUNCTION 'F4_DATE'
        EXPORTING
          DATE_FOR_FIRST_MONTH         = SY-DATUM
        IMPORTING
          SELECT_DATE                  = L_DATE
        EXCEPTIONS
          CALENDAR_BUFFER_NOT_LOADABLE = 1
          DATE_AFTER_RANGE             = 2
          DATE_BEFORE_RANGE            = 3
          DATE_INVALID                 = 4
          FACTORY_CALENDAR_NOT_FOUND   = 5
          HOLIDAY_CALENDAR_NOT_FOUND   = 6
          PARAMETER_CONFLICT           = 7
          OTHERS                       = 8.


      IF SY-SUBRC = 0.
        S_MONTH-LOW = L_DATE+0(6).
      ENDIF.


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-HIGH.
    *年月的搜索帮助
      DATA:L_DATE TYPE SY-DATUM.


      CALL FUNCTION 'F4_DATE'
        EXPORTING
          DATE_FOR_FIRST_MONTH         = SY-DATUM
        IMPORTING
          SELECT_DATE                  = L_DATE
        EXCEPTIONS
          CALENDAR_BUFFER_NOT_LOADABLE = 1
          DATE_AFTER_RANGE             = 2
          DATE_BEFORE_RANGE            = 3
          DATE_INVALID                 = 4
          FACTORY_CALENDAR_NOT_FOUND   = 5
          HOLIDAY_CALENDAR_NOT_FOUND   = 6
          PARAMETER_CONFLICT           = 7
          OTHERS                       = 8.


      IF SY-SUBRC = 0.
        S_MONTH-HIGH = L_DATE+0(6).
      ENDIF.


    *&---------------------------------------------------------------------*
    * START-OF-SELECTION
    *&---------------------------------------------------------------------*
    START-OF-SELECTION.


    * - show the current activity and the progress
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          TEXT = '正在处理,请稍等......'.
      CALL FUNCTION 'ZF_AUTHORITY_WERKS'
        TABLES
          S_WERKS = S_WERKS.


    *取数
      PERFORM FRM_GET_DATA.


    *处理
      PERFORM FRM_PROCESS_DATA.


    *显示
      IF I_BTBHA IS NOT INITIAL.
        CALL SCREEN 9000.
      ELSE.
        MESSAGE '抱歉,没有找到任何符合条件的记录!' TYPE 'S' DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.


    *&---------------------------------------------------------------------*
    * END-OF-SELECTION
    *&---------------------------------------------------------------------*
    END-OF-SELECTION.


    *&---------------------------------------------------------------------*
    *&      Form  FRM_SET_PRODUCT
    *&---------------------------------------------------------------------*
    *       产品类别下拉框
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_SET_PRODUCT .
      DATA:
            I_LIST   TYPE VRM_VALUES,
            WA_LIST  LIKE LINE OF I_LIST,
            LV_I_DOMTAB      TYPE STANDARD TABLE OF DD07V,
            LV_WA_DOMTAB     TYPE DD07V.


      CALL FUNCTION 'DD_DOMVALUES_GET'
        EXPORTING
          DOMNAME        = 'ZPRODUCT'
          TEXT           = 'X'
          LANGU          = SY-LANGU
        TABLES
          DD07V_TAB      = LV_I_DOMTAB
        EXCEPTIONS                                              "#EC FB_RC
          WRONG_TEXTFLAG = 1
          OTHERS         = 2.


      LOOP AT LV_I_DOMTAB INTO LV_WA_DOMTAB.
        READ TABLE LV_I_DOMTAB INTO LV_WA_DOMTAB INDEX SY-TABIX.
        IF SY-SUBRC = 0.
          CLEAR : WA_LIST.
          WA_LIST-KEY = LV_WA_DOMTAB-DOMVALUE_L.
          WA_LIST-TEXT = LV_WA_DOMTAB-DDTEXT.
          APPEND WA_LIST TO I_LIST.
        ENDIF.
      ENDLOOP.


      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          ID              = 'P_PRO'
          VALUES          = I_LIST
        EXCEPTIONS
          ID_ILLEGAL_NAME = 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.
    ENDFORM.                    " FRM_SET_PRODUCT
    *&---------------------------------------------------------------------*
    *&      Form  FRM_SET_INPUT
    *&---------------------------------------------------------------------*
    *       设置当某个单选按钮按下时不可输入
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_SET_INPUT .
    *控制屏幕的输入
      LOOP AT SCREEN.
        IF P_R1 = 'X' OR P_R2 = 'X'.
          CLEAR : S_MATNR.
          REFRESH : S_MATNR.
          CLEAR : S_PRDHA.
          REFRESH : S_PRDHA.
          IF SCREEN-GROUP1 = 'M3'.
            SCREEN-INPUT = '0'.
          ELSE.
            SCREEN-INPUT = '1'.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF P_R3 = 'X'.
          CLEAR : S_AUFNR.
          REFRESH : S_AUFNR.
          CLEAR : S_MATNR.
          REFRESH : S_MATNR.
          CLEAR : S_PRDHA.
          REFRESH : S_PRDHA.
          IF SCREEN-GROUP1 = 'M2' OR SCREEN-GROUP1 = 'M3'.
            SCREEN-INPUT = '0'.
          ELSE.
            SCREEN-INPUT = '1'.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF P_R4 = 'X'.
          CLEAR : S_BTBHA.
          REFRESH : S_BTBHA.
          CLEAR : S_MATNR.
          REFRESH : S_MATNR.
          CLEAR : S_PRDHA.
          REFRESH : S_PRDHA.
          IF SCREEN-GROUP1 = 'M1' OR SCREEN-GROUP1 = 'M3'.
            SCREEN-INPUT = '0'.
          ELSE.
            SCREEN-INPUT = '1'.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF P_R5 = 'X'.
          CLEAR : S_BTBHA.
          REFRESH : S_BTBHA.
          CLEAR : S_AUFNR.
          REFRESH : S_AUFNR.
          IF SCREEN-GROUP1 = 'M1' OR SCREEN-GROUP1 = 'M2'.
            SCREEN-INPUT = '0'.
          ELSE.
            SCREEN-INPUT = '1'.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " FRM_SET_INPUT


    *&---------------------------------------------------------------------*
    *&      Module  INITIAL_CONTAINER  OUTPUT
    *&---------------------------------------------------------------------*
    *       初始化容器对象
    *----------------------------------------------------------------------*
    MODULE INITIAL_CONTAINER OUTPUT.
      IF GV_CONTAINER IS INITIAL.
        PERFORM CREATE_ALV_CONTAINER.
      ENDIF.
      PERFORM FRM_SET_ALV.
    ENDMODULE.                 " INITIAL_CONTAINER  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Form  CREATE_ALV_CONTAINER
    *&---------------------------------------------------------------------*
    *       创建容器
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM CREATE_ALV_CONTAINER .
      IF NOT GV_CONTAINER IS INITIAL.
        CALL METHOD GV_CONTAINER->FREE
          EXCEPTIONS
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
    *    IF SY-SUBRC <> 0.
    *    ENDIF.
        CLEAR GV_CONTAINER.
        CLEAR GV_ALV.
      ENDIF.
      CREATE OBJECT GV_CONTAINER
        EXPORTING
          CONTAINER_NAME              = GV_CNAME
        EXCEPTIONS
          CNTL_ERROR                  = 1
          CNTL_SYSTEM_ERROR           = 2
          CREATE_ERROR                = 3
          LIFETIME_ERROR              = 4
          LIFETIME_DYNPRO_DYNPRO_LINK = 5.
    ENDFORM.                    " CREATE_ALV_CONTAINER
    *&---------------------------------------------------------------------*
    *&      Form  FRM_SET_ALV
    *&---------------------------------------------------------------------*
    *       ALV显示
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_SET_ALV .
      IF GV_ALV IS INITIAL.
    *创建ALV容器
        CREATE OBJECT GV_ALV
          EXPORTING
            I_PARENT          = GV_CONTAINER
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4.


    *ALV的设置
        PERFORM FRM_ALV_LIST.


    *add by maojian at 20121026
        DELETE I_BTBHA WHERE YLFT = 0 AND
                            HGPZL = 0 AND
                            DJYPZL = 0 AND
                            BHGPZL = 0 AND
                            FGHGP = 0 AND
                            FGDJP = 0 AND
                            FGBHGP = 0 AND
                            BXFX = 0 AND
                            YUL = 0.


    *AVL的显示
        CALL METHOD GV_ALV->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
            IS_LAYOUT                     = GV_LAYOUT
            I_SAVE                        = 'A'
          CHANGING
            IT_OUTTAB                     = I_BTBHA
            IT_FIELDCATALOG               = ITAB_CATA_TK
          EXCEPTIONS
            INVALID_PARAMETER_COMBINATION = 1
            PROGRAM_ERROR                 = 2
            TOO_MANY_LINES                = 3
            OTHERS                        = 4.
    *    --Creating an instance for the event handler
        CREATE OBJECT GR_EVENT_HANDLER .
    *    --Registering handler methods to handle ALV Grid events
        SET HANDLER GR_EVENT_HANDLER->HANDLE_DOUBLE_CLICK FOR GV_ALV.
        SET HANDLER GR_EVENT_HANDLER->HANDLE_HOTSPOT_CLICK FOR GV_ALV .
      ENDIF.
    ENDFORM.                    " FRM_SET_ALV
    *&---------------------------------------------------------------------*
    *&      Form  FRM_ALV_LIST
    *&---------------------------------------------------------------------*
    *       ALV设置
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_ALV_LIST .
    * set fieldcatalog
      PERFORM FRM_SET_FIELDCAT.
    * set layout
      PERFORM FRM_SET_LAYOUT.
    ENDFORM.                    " FRM_ALV_LIST
    *&---------------------------------------------------------------------*
    *&      Form  FRM_SET_FIELDCAT
    *&---------------------------------------------------------------------*
    *       设置ALV字段
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_SET_FIELDCAT .
      DATA:
            LV_WA_FCAT TYPE LVC_S_FCAT.


      IF P_R2 = 'X'.
        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'CPDDH'.
        LV_WA_FCAT-COLTEXT = '产品订单号'.
        LV_WA_FCAT-OUTPUTLEN = '12'.
        LV_WA_FCAT-FIX_COLUMN = 'X'.
        LV_WA_FCAT-KEY = 'X'.
        LV_WA_FCAT-HOTSPOT = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.


        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'BTBHA'.
        LV_WA_FCAT-COLTEXT = '台班编号'.
        LV_WA_FCAT-OUTPUTLEN = '10'.
        LV_WA_FCAT-FIX_COLUMN = 'X'.
        LV_WA_FCAT-KEY = 'X'.
        LV_WA_FCAT-HOTSPOT = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.
      ELSEIF P_R5 = 'X'.
        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'VTEXT'.
        LV_WA_FCAT-COLTEXT = '产品层次'.
        LV_WA_FCAT-OUTPUTLEN = '18'.
        LV_WA_FCAT-KEY = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.


        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'MAKTX'.
        LV_WA_FCAT-COLTEXT = '订单产品名称'.
        LV_WA_FCAT-OUTPUTLEN = '25'.
        LV_WA_FCAT-KEY = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.


        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'MATNR'.
        LV_WA_FCAT-COLTEXT = '订单产品代码'.
        LV_WA_FCAT-OUTPUTLEN = '10'.
        LV_WA_FCAT-HOTSPOT = 'X'.
        LV_WA_FCAT-KEY = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.
      ELSE.
        IF P_R4 <> 'X'.
          CLEAR LV_WA_FCAT.
          LV_WA_FCAT-FIELDNAME = 'BTBHA'.
          LV_WA_FCAT-COLTEXT = '台班编号'.
          LV_WA_FCAT-OUTPUTLEN = '10'.
          LV_WA_FCAT-FIX_COLUMN = 'X'.
          LV_WA_FCAT-KEY = 'X'.
          LV_WA_FCAT-HOTSPOT = 'X'.
          APPEND LV_WA_FCAT TO ITAB_CATA_TK.
        ENDIF.


        IF P_R3 <> 'X'.
          CLEAR LV_WA_FCAT.
          LV_WA_FCAT-FIELDNAME = 'CPDDH'.
          LV_WA_FCAT-COLTEXT = '产品订单号'.
          LV_WA_FCAT-OUTPUTLEN = '12'.
          LV_WA_FCAT-FIX_COLUMN = 'X'.
          LV_WA_FCAT-KEY = 'X'.
          LV_WA_FCAT-HOTSPOT = 'X'.
          APPEND LV_WA_FCAT TO ITAB_CATA_TK.
        ENDIF.
      ENDIF.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'YLFT'.
      LV_WA_FCAT-COLTEXT = '投入原材料'.
      LV_WA_FCAT-OUTPUTLEN = '12'.
      LV_WA_FCAT-EMPHASIZE = 'C500'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'HGPZL'.
      LV_WA_FCAT-COLTEXT = '合格品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C710'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'DJYPZL'.
      LV_WA_FCAT-COLTEXT = '待检品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C710'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'BHGPZL'.
      LV_WA_FCAT-COLTEXT = '不合格品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C710'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'FGHGP'.
      LV_WA_FCAT-COLTEXT = '返工合格品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C510'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'FGDJP'.
      LV_WA_FCAT-COLTEXT = '返工待检品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C510'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'FGBHGP'.
      LV_WA_FCAT-COLTEXT = '返工不合格品'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C510'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'BXFX'.
      LV_WA_FCAT-COLTEXT = '波纤'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C600'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'YUL'.
      LV_WA_FCAT-COLTEXT = '余料'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-EMPHASIZE = 'C600'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'YLCCHJ'.
      LV_WA_FCAT-COLTEXT = '原料产品产出'.
      LV_WA_FCAT-OUTPUTLEN = '12'.
    *  LV_WA_FCAT-EMPHASIZE = 'C711'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'DBCCL'.
      LV_WA_FCAT-COLTEXT = '成材率'.
      LV_WA_FCAT-OUTPUTLEN = '8'.
      LV_WA_FCAT-JUST = 'R'.
      LV_WA_FCAT-HOTSPOT = 'X'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'DBHSL'.
      LV_WA_FCAT-COLTEXT = '回收率'.
      LV_WA_FCAT-OUTPUTLEN = '8'.
      LV_WA_FCAT-JUST = 'R'.
      LV_WA_FCAT-HOTSPOT = 'X'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'DBSHL'.
      LV_WA_FCAT-COLTEXT = '损耗率'.
      LV_WA_FCAT-OUTPUTLEN = '8'.
      LV_WA_FCAT-JUST = 'R'.
      LV_WA_FCAT-HOTSPOT = 'X'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'RATE'.
      LV_WA_FCAT-COLTEXT = '投入产出比'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      LV_WA_FCAT-HOTSPOT = 'X'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'ICON'.
      LV_WA_FCAT-COLTEXT = '错误标示'.
      LV_WA_FCAT-ICON = 'X'.
      LV_WA_FCAT-HOTSPOT = 'X'.
      LV_WA_FCAT-OUTPUTLEN = '8'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      IF P_R3 <> 'X' AND P_R5 <> 'X'.
        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'MAKTX'.
        LV_WA_FCAT-COLTEXT = '订单产品名称'.
        LV_WA_FCAT-OUTPUTLEN = '25'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.


        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'MATNR'.
        LV_WA_FCAT-COLTEXT = '订单产品代码'.
        LV_WA_FCAT-OUTPUTLEN = '10'.
        LV_WA_FCAT-HOTSPOT = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.
      ENDIF.


      IF P_R5 = 'X'.
        CLEAR LV_WA_FCAT.
        LV_WA_FCAT-FIELDNAME = 'PRDHA'.
        LV_WA_FCAT-COLTEXT = '层次代码'.
        LV_WA_FCAT-OUTPUTLEN = '6'.
        LV_WA_FCAT-NO_OUT = 'X'.
        APPEND LV_WA_FCAT TO ITAB_CATA_TK.
      ENDIF.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'HOURS'.
      LV_WA_FCAT-COLTEXT = '班组出勤总工时'.
      LV_WA_FCAT-OUTPUTLEN = '14'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'TIMES'.
      LV_WA_FCAT-COLTEXT = '设备运行时间'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'UNITS'.
      LV_WA_FCAT-COLTEXT = '单位'.
      LV_WA_FCAT-OUTPUTLEN = '4'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'AS'.
      LV_WA_FCAT-COLTEXT = '小时产量'.
      LV_WA_FCAT-OUTPUTLEN = '10'.
      APPEND LV_WA_FCAT TO ITAB_CATA_TK.


    ENDFORM.                    " FRM_SET_FIELDCAT
    *&---------------------------------------------------------------------*
    *&      Form  FRM_SET_LAYOUT
    *&---------------------------------------------------------------------*
    *       设置ALV格式
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_SET_LAYOUT .
      GV_LAYOUT-SEL_MODE = 'D'.
    *  GV_LAYOUT-ZEBRA = 'X' .
      GV_LAYOUT-CTAB_FNAME = 'CELLCOLORS'.
      GV_LAYOUT-INFO_FNAME = 'ROWCOLOR'.
      IF P_R1 = 'X'.
        GV_LAYOUT-GRID_TITLE = '生产投入产出平衡检查及指标分析 - 按台班订单   单位 :KG' .
      ELSEIF P_R2 = 'X'.
        GV_LAYOUT-GRID_TITLE = '生产投入产出平衡检查及指标分析 - 按订单台班   单位 :KG' .
      ELSEIF P_R3 = 'X'.
        GV_LAYOUT-GRID_TITLE = '生产投入产出平衡检查及指标分析 - 按台班  单位 :KG' .
      ELSEIF P_R4 = 'X'.
        GV_LAYOUT-GRID_TITLE = '生产投入产出平衡检查及指标分析 - 按订单  单位 :KG' .
      ELSEIF P_R5 = 'X'.
        GV_LAYOUT-GRID_TITLE = '生产投入产出平衡检查及指标分析 - 按产品层次跟物料代码  单位 :KG' .
      ENDIF.
      GV_LAYOUT-SMALLTITLE = 'X' .
    ENDFORM.                    " FRM_SET_LAYOUT
    *&---------------------------------------------------------------------*
    *&      Form  FRM_GET_DATA
    *&---------------------------------------------------------------------*
    *       取数规则
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_GET_DATA .
    *  DATA :
    **开始年月
    *        LV_START TYPE D,
    **结束年月
    *        LV_FINISH TYPE D.


    *取’年月‘选择条件
      PERFORM FRM_GET_DATE CHANGING GV_START GV_FINISH.
    *取数
      SELECT  AUFM~WERKS
              AUFM~AUFNR
              AUFM~MATNR
              AUFM~SHKZG
              AUFM~BWART
              AUFM~MEINS
              AUFM~WAERS
              AUFM~MJAHR
              AUFM~MBLNR
              AUFM~ZEILE
              AUFM~BUDAT
              AUFM~LGORT
              AUFM~CHARG
              AUFM~SOBKZ
              AUFM~KDAUF
              AUFM~KDPOS
              AUFM~RSNUM
              AUFM~RSPOS
              AUFM~SAKTO
              AUFM~MENGE
              AUFM~DMBTR
              MKPF~BKTXT
              MKPF~USNAM
              MAKT~MAKTX
              MAKT~SPRAS
    *          MARA~PRDHA
        INTO CORRESPONDING FIELDS OF TABLE I_DATA
        FROM AUFM
             INNER JOIN MKPF
                   ON MKPF~MBLNR = AUFM~MBLNR
                  AND MKPF~MJAHR = AUFM~MJAHR
             INNER JOIN MAKT
                  ON MAKT~MATNR = AUFM~MATNR
             INNER JOIN AFPO
                  ON AFPO~AUFNR = AUFM~AUFNR
             INNER JOIN ZZTPP_ZSTZ_HEAD
                  ON ZZTPP_ZSTZ_HEAD~BTBHA = MKPF~BKTXT
    *         INNER JOIN MARA
    *              ON MARA~MATNR = AUFM~MATNR
             WHERE AUFM~AUFNR IN S_AUFNR
    *           AND AUFM~MJAHR IN S_MJAHR
    *           AND AUFM~BUDAT BETWEEN GV_START AND GV_FINISH  "凭证中的过帐日期
               AND AFPO~LTRMI BETWEEN GV_START AND GV_FINISH "实际交货日期/结束日期
               AND AFPO~POSNR = '1'
               AND AUFM~BUDAT IN S_BUDAT
               AND MKPF~BKTXT IN S_BTBHA
               AND MKPF~BKTXT <> ''
               AND MAKT~SPRAS = '1'
               AND ZZTPP_ZSTZ_HEAD~GZ = 'Y'
    *           AND ZZTPP_ZSTZ_HEAD~BUDAT IN S_BTBHA
    *           AND ZZTPP_ZSTZ_HEAD~BUDAT BETWEEN GV_START AND GV_FINISH
               AND AUFM~WERKS IN S_WERKS.
      IF I_DATA IS INITIAL.
        EXIT.
      ENDIF.


      IF P_R1 = 'X'.
    *台班订单产出
        PERFORM FRM_TB_ORDER.
      ELSEIF P_R2 = 'X'.
    *订单台班产出
        PERFORM FRM_ORDER_TB.
      ELSEIF P_R3 = 'X'.
    *按台班
        PERFORM FRM_BY_TB.
      ELSEIF P_R4 = 'X'.
    *按订单
        PERFORM FRM_BY_ORDER.
    *产品层次跟物料代码
      ELSEIF P_R5 = 'X'.
        PERFORM FRM_BY_PRODUCT_LEVEL.
      ENDIF.


    ENDFORM.                    " FRM_GET_DATA
    *&---------------------------------------------------------------------*
    *&      Form  FRM_GET_DATE
    *&---------------------------------------------------------------------*
    *       选择屏幕上的年月条件
    *----------------------------------------------------------------------*
    *      <--P_LV_START  text
    *      <--P_LV_FINISH  text
    *----------------------------------------------------------------------*
    FORM FRM_GET_DATE  CHANGING P_START TYPE D
                                P_FINISH TYPE D.


      IF S_MONTH-LOW IS NOT INITIAL AND S_MONTH-HIGH IS INITIAL.
        CONCATENATE S_MONTH-LOW '01' INTO P_START.
        CALL FUNCTION 'FIMA_DATE_CREATE'
          EXPORTING
            I_DATE                        = P_START
    *   I_FLG_END_OF_MONTH            = ' '
    *   I_YEARS                       = 0
           I_MONTHS                      = 0
    *   I_DAYS                        = 0
    *   I_CALENDAR_DAYS               = 0
           I_SET_LAST_DAY_OF_MONTH       = 'X'
         IMPORTING
       E_DATE                        = P_FINISH
    *   E_FLG_END_OF_MONTH            =
    *   E_DAYS_OF_I_DATE              =
                  .
      ELSEIF S_MONTH-LOW IS NOT INITIAL AND S_MONTH-HIGH IS NOT INITIAL.
        CONCATENATE S_MONTH-LOW '01' INTO P_START.
        CONCATENATE S_MONTH-HIGH '01' INTO P_FINISH.
        CALL FUNCTION 'FIMA_DATE_CREATE'
              EXPORTING
                I_DATE                        = P_FINISH
    *   I_FLG_END_OF_MONTH            = ' '
    *   I_YEARS                       = 0
               I_MONTHS                      = 0
    *   I_DAYS                        = 0
    *   I_CALENDAR_DAYS               = 0
               I_SET_LAST_DAY_OF_MONTH       = 'X'
             IMPORTING
           E_DATE                        = P_FINISH
    *   E_FLG_END_OF_MONTH            =
    *   E_DAYS_OF_I_DATE              =
                      .
      ELSEIF S_MONTH IS INITIAL.
        P_START = '19000101'.
        P_FINISH = '99991231'.
      ENDIF.
    ENDFORM.                    " FRM_GET_DATE
    *&---------------------------------------------------------------------*
    *&      Form  FRM_TB_ORDER
    *&---------------------------------------------------------------------*
    *       台班订单产出
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_TB_ORDER .
      DATA :
    * 存放比较的台班编号
            LV_BKTXT TYPE BKTXT,
    * 存放比较的生产订单号
            LV_AUFNR TYPE AUFNR,
    * 临时I_BTBHA内表
            LV_I_BTBHA TYPE STANDARD TABLE OF T_BTBHA,
            LV_WA_BTBHA TYPE T_BTBHA,
            LV_I_TEMP TYPE STANDARD TABLE OF T_BTBHA,
            LV_WA_TEMP TYPE T_BTBHA,
    *过账日期
            LV_DAT TYPE D,
    *产品类别
            LV_BTBHA TYPE BKTXT.


    *按台班-订单排序
      SORT I_DATA BY BKTXT AUFNR.


    *取订单产品规格信息
      PERFORM FRM_GET_ORDERSPEC.


    *处理查询结果到输出内表:I_BTBHA
      READ TABLE I_DATA INTO WA_DATA INDEX 1.
      LV_BKTXT = WA_DATA-BKTXT.
      LV_AUFNR = WA_DATA-AUFNR.
      CLEAR : WA_DATA.
      REFRESH : I_BTBHA.


      LOOP AT I_DATA INTO WA_DATA.
        IF LV_BKTXT = WA_DATA-BKTXT AND LV_AUFNR = WA_DATA-AUFNR.
    *同一台班下的同一订单 - 累加
          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ELSEIF LV_BKTXT = WA_DATA-BKTXT AND LV_AUFNR <> WA_DATA-AUFNR.
    *同一台班下的不同订单 - 添加
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = LV_BKTXT.       "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          APPEND WA_BTBHA TO I_BTBHA.


          LV_AUFNR = WA_DATA-AUFNR.
          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ELSEIF LV_BKTXT <> WA_DATA-BKTXT .
    *不同台班
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = LV_BKTXT.       "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          APPEND WA_BTBHA TO I_BTBHA.


          LV_BKTXT = WA_DATA-BKTXT.
          LV_AUFNR = WA_DATA-AUFNR.
          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ENDIF.


        MODIFY I_DATA FROM WA_DATA.


        AT LAST.
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = LV_BKTXT.       "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          APPEND WA_BTBHA TO I_BTBHA.


          CLEAR : LV_AUFNR,
                  LV_BKTXT,
                  GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料
        ENDAT.
      ENDLOOP.


    *台班合计行
      REFRESH LV_I_BTBHA.
      LOOP AT I_BTBHA INTO WA_BTBHA.
        MOVE-CORRESPONDING WA_BTBHA TO LV_WA_BTBHA.


    *   台班-订单  设备运行时间
        CLEAR : LV_DAT , LV_BTBHA.
        IF STRLEN( LV_WA_BTBHA-BTBHA ) = 8.
          CONCATENATE '20' LV_WA_BTBHA-BTBHA+2(6) INTO LV_DAT.
          LV_BTBHA = LV_WA_BTBHA-BTBHA+0(2).
        ELSEIF STRLEN( LV_WA_BTBHA-BTBHA ) = 10.
          CONCATENATE '20' LV_WA_BTBHA-BTBHA+4(6) INTO LV_DAT.
          LV_BTBHA = LV_WA_BTBHA-BTBHA+0(4).
        ENDIF.


        REFRESH I_CONFIRM.
        SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_BTBHA-CPDDH
             AND LTXA1 = LV_WA_BTBHA-BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
        IF SY-SUBRC = 0.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             APPENDING CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_BTBHA-CPDDH
             AND BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.


          LOOP AT I_CONFIRM INTO WA_CONFIRM.
            LV_WA_BTBHA-TIMES = LV_WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
            LV_WA_BTBHA-HOURS = LV_WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
          ENDLOOP.


        ELSE.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_BTBHA-CPDDH
             AND BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
          IF SY-SUBRC = 0.
            LOOP AT I_CONFIRM INTO WA_CONFIRM.
              LV_WA_BTBHA-TIMES = LV_WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
              LV_WA_BTBHA-HOURS = LV_WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
            ENDLOOP.
          ENDIF.
        ENDIF.
        LV_WA_BTBHA-UNITS = 'H'.
        APPEND LV_WA_BTBHA TO LV_I_BTBHA.
      ENDLOOP.


      REFRESH : LV_I_TEMP.
      LOOP AT LV_I_BTBHA INTO LV_WA_BTBHA.
        APPEND LV_WA_BTBHA TO LV_I_TEMP.
        MOVE-CORRESPONDING LV_WA_BTBHA TO LV_WA_TEMP .
        AT END OF BTBHA.
          SUM.
          LV_WA_BTBHA-BTBHA = LV_WA_TEMP-BTBHA.
          LV_WA_BTBHA-CPDDH = '合计'.
          LV_WA_BTBHA-DBCCL = ''.
          LV_WA_BTBHA-DBHSL = ''.
          LV_WA_BTBHA-ICON = ''.
          LV_WA_BTBHA-MATNR = ''.
          LV_WA_BTBHA-MAKTX = ''.
          LV_WA_BTBHA-UNITS = 'H'.
          LV_WA_BTBHA-ROWCOLOR = 'C100'.
          APPEND LV_WA_BTBHA TO LV_I_TEMP.
        ENDAT.
      ENDLOOP.


      REFRESH : I_BTBHA , LV_I_BTBHA.
      LOOP AT LV_I_TEMP INTO LV_WA_BTBHA.
        MOVE-CORRESPONDING LV_WA_BTBHA TO WA_BTBHA.
        APPEND WA_BTBHA TO I_BTBHA.
      ENDLOOP.
      REFRESH LV_I_TEMP.


    ENDFORM.                    " FRM_TB_ORDER
    *&---------------------------------------------------------------------*
    *&      Form  FRM_ORDER_TB
    *&---------------------------------------------------------------------*
    *       订单台班产出
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_ORDER_TB .
      DATA :
    * 存放比较的台班编号
              LV_BKTXT TYPE BKTXT,
    * 存放比较的生产订单号
              LV_AUFNR TYPE AUFNR,
    * 临时存放的内表信息
              LV_I_AUFNR TYPE STANDARD TABLE OF T_AUFNR,
              LV_WA_AUFNR TYPE T_AUFNR,
              LV_I_TEMP TYPE STANDARD TABLE OF T_AUFNR,
              LV_WA_TEMP TYPE T_AUFNR,
    *过账日期
              LV_DAT TYPE D,
    *产品类别
              LV_BTBHA TYPE BKTXT.


    *按订单-台班排序
      SORT I_DATA BY AUFNR BKTXT.


    *取订单产品规格信息
      PERFORM FRM_GET_ORDERSPEC.


    *处理查询结果到输出内表:I_BTBHA
      READ TABLE I_DATA INTO WA_DATA INDEX 1.
      LV_AUFNR = WA_DATA-AUFNR.
      LV_BKTXT = WA_DATA-BKTXT.
      CLEAR : WA_DATA.
      REFRESH : I_BTBHA.


      LOOP AT I_DATA INTO WA_DATA.
        IF  LV_AUFNR = WA_DATA-AUFNR AND  LV_BKTXT = WA_DATA-BKTXT.
    *同一生产订单同一台班 - 累加
          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ELSEIF LV_AUFNR = WA_DATA-AUFNR AND  LV_BKTXT <> WA_DATA-BKTXT.
    *同一生产订单不同台班 - 添加
          CLEAR : LV_WA_AUFNR.
          LV_WA_AUFNR-CPDDH = LV_AUFNR.       "产品订单号
          LV_WA_AUFNR-BTBHA = LV_BKTXT.       "台班班号
          LV_WA_AUFNR-YLFT = GV_YLFT.         "投入原材料
          LV_WA_AUFNR-HGPZL = GV_HGPZL.       "合格品
          LV_WA_AUFNR-DJYPZL = GV_DJYPZL.     "待检品
          LV_WA_AUFNR-BHGPZL = GV_BHGPZL.     "不合格品
          LV_WA_AUFNR-FGHGP = GV_FGHGP.       "返工合格品
          LV_WA_AUFNR-FGDJP = GV_FGDJP.       "返工待检品
          LV_WA_AUFNR-FGBHGP = GV_FGBHGP.     "返工不合格品
          LV_WA_AUFNR-BXFX  = GV_BXFX.        "波纤
          LV_WA_AUFNR-YUL = GV_YUL.           "余料
          APPEND LV_WA_AUFNR TO LV_I_AUFNR.


          LV_BKTXT = WA_DATA-BKTXT.


          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ELSEIF LV_AUFNR <> WA_DATA-AUFNR.
    *不同生产订单
          CLEAR : LV_WA_AUFNR.
          LV_WA_AUFNR-CPDDH = LV_AUFNR.       "产品订单号
          LV_WA_AUFNR-BTBHA = LV_BKTXT.       "台班班号
          LV_WA_AUFNR-YLFT = GV_YLFT.         "投入原材料
          LV_WA_AUFNR-HGPZL = GV_HGPZL.       "合格品
          LV_WA_AUFNR-DJYPZL = GV_DJYPZL.     "待检品
          LV_WA_AUFNR-BHGPZL = GV_BHGPZL.     "不合格品
          LV_WA_AUFNR-FGHGP = GV_FGHGP.       "返工合格品
          LV_WA_AUFNR-FGDJP = GV_FGDJP.       "返工待检品
          LV_WA_AUFNR-FGBHGP = GV_FGBHGP.     "返工不合格品
          LV_WA_AUFNR-BXFX  = GV_BXFX.        "波纤
          LV_WA_AUFNR-YUL = GV_YUL.           "余料
          APPEND LV_WA_AUFNR TO LV_I_AUFNR.


          LV_AUFNR = WA_DATA-AUFNR.
          LV_BKTXT = WA_DATA-BKTXT.


          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ENDIF.


        MODIFY I_DATA FROM WA_DATA.


        AT LAST.
          CLEAR : LV_WA_AUFNR.
          LV_WA_AUFNR-CPDDH = LV_AUFNR.       "产品订单号
          LV_WA_AUFNR-BTBHA = LV_BKTXT.       "台班班号
          LV_WA_AUFNR-YLFT = GV_YLFT.         "投入原材料
          LV_WA_AUFNR-HGPZL = GV_HGPZL.       "合格品
          LV_WA_AUFNR-DJYPZL = GV_DJYPZL.     "待检品
          LV_WA_AUFNR-BHGPZL = GV_BHGPZL.     "不合格品
          LV_WA_AUFNR-FGHGP = GV_FGHGP.       "返工合格品
          LV_WA_AUFNR-FGDJP = GV_FGDJP.       "返工待检品
          LV_WA_AUFNR-FGBHGP = GV_FGBHGP.     "返工不合格品
          LV_WA_AUFNR-BXFX  = GV_BXFX.        "波纤
          LV_WA_AUFNR-YUL = GV_YUL.           "余料
          APPEND LV_WA_AUFNR TO LV_I_AUFNR.


          CLEAR : LV_AUFNR,
                  LV_BKTXT,
                  GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料
        ENDAT.
      ENDLOOP.


      LOOP AT LV_I_AUFNR INTO LV_WA_AUFNR.
    *   订单 - 台班  设备运行时间


        CLEAR : LV_DAT , LV_BTBHA.
        IF STRLEN( LV_WA_AUFNR-BTBHA ) = 8.
          CONCATENATE '20' LV_WA_AUFNR-BTBHA+2(6) INTO LV_DAT.
          LV_BTBHA = LV_WA_AUFNR-BTBHA+0(2).
        ELSEIF STRLEN( LV_WA_AUFNR-BTBHA ) = 10.
          CONCATENATE '20' LV_WA_AUFNR-BTBHA+4(6) INTO LV_DAT.
          LV_BTBHA = LV_WA_AUFNR-BTBHA+0(4).
        ENDIF.


        REFRESH I_CONFIRM.
        SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_AUFNR-CPDDH
             AND LTXA1 = LV_WA_AUFNR-BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
        IF SY-SUBRC = 0.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             APPENDING CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_AUFNR-CPDDH
             AND BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.


          LOOP AT I_CONFIRM INTO WA_CONFIRM.
            LV_WA_AUFNR-TIMES = LV_WA_AUFNR-TIMES + WA_CONFIRM-ISM01.
    *工时
            LV_WA_AUFNR-HOURS = LV_WA_AUFNR-HOURS + WA_CONFIRM-ISM02.
          ENDLOOP.


        ELSE.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = LV_WA_AUFNR-CPDDH
             AND BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
          IF SY-SUBRC = 0.
            LOOP AT I_CONFIRM INTO WA_CONFIRM.
              LV_WA_AUFNR-TIMES = LV_WA_AUFNR-TIMES + WA_CONFIRM-ISM01.
    *工时
              LV_WA_AUFNR-HOURS = LV_WA_AUFNR-HOURS + WA_CONFIRM-ISM02.
            ENDLOOP.
          ENDIF.
        ENDIF.
        LV_WA_AUFNR-UNITS = 'H'.
        MODIFY LV_I_AUFNR FROM LV_WA_AUFNR.
      ENDLOOP.
    *合计行
      REFRESH LV_I_TEMP.
      LOOP AT LV_I_AUFNR INTO LV_WA_AUFNR.
        APPEND LV_WA_AUFNR TO LV_I_TEMP.
        MOVE-CORRESPONDING LV_WA_AUFNR TO LV_WA_TEMP.
        AT END OF CPDDH.
          SUM.
          LV_WA_AUFNR-CPDDH = LV_WA_TEMP-CPDDH.
          LV_WA_AUFNR-BTBHA = '合计'.
          LV_WA_AUFNR-DBCCL = ''.
          LV_WA_AUFNR-DBHSL = ''.
          LV_WA_AUFNR-ICON = ''.
          LV_WA_AUFNR-UNITS = 'H'.
          LV_WA_AUFNR-ROWCOLOR = 'C100'.
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_WA_TEMP-CPDDH.
          LV_WA_AUFNR-MATNR = WA_SPEC-MATNR.
          LV_WA_AUFNR-MAKTX = WA_SPEC-MAKTX.
          APPEND LV_WA_AUFNR TO LV_I_TEMP.
        ENDAT.
      ENDLOOP.


      REFRESH LV_I_AUFNR.
      CLEAR WA_BTBHA.
      LOOP AT LV_I_TEMP INTO LV_WA_AUFNR.
        MOVE-CORRESPONDING LV_WA_AUFNR TO WA_BTBHA.
        APPEND WA_BTBHA TO I_BTBHA.
      ENDLOOP.
      REFRESH LV_I_TEMP.


    ENDFORM.                    " FRM_ORDER_TB
    *&---------------------------------------------------------------------*
    *&      Form  FRM_BY_TB
    *&---------------------------------------------------------------------*
    *       按台班--直接统计某个台班的所有信息,不必区分订单
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_BY_TB .
      DATA :
    * 存放比较的台班编号
            LV_BKTXT TYPE BKTXT,
    *过账日期
            LV_DAT  TYPE D,
    *产品类别
            LV_BTBHA TYPE BKTXT.


    *按台班排序
      SORT I_DATA BY BKTXT MATNR.


    *处理查询结果到输出内表:I_BTBHA
      READ TABLE I_DATA INTO WA_DATA INDEX 1.
      LV_BKTXT = WA_DATA-BKTXT.
      CLEAR : WA_DATA.
      REFRESH : I_BTBHA.


      LOOP AT I_DATA INTO WA_DATA.
        IF LV_BKTXT = WA_DATA-BKTXT.
    *同一台班编号
    *分类合计
          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.
        ELSE.
    *不同的台班编号
    *插入到输出内表中
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = LV_BKTXT.       "台班班号
          WA_BTBHA-CPDDH = WA_DATA-AUFNR.  "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          APPEND WA_BTBHA TO I_BTBHA.


          LV_BKTXT = WA_DATA-BKTXT.
          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ENDIF.


        MODIFY I_DATA FROM WA_DATA.


        AT LAST.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = LV_BKTXT.       "台班班号
          WA_BTBHA-CPDDH = WA_DATA-AUFNR.  "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          APPEND WA_BTBHA TO I_BTBHA.
          CLEAR : LV_BKTXT,
                  GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料
        ENDAT.
      ENDLOOP.


    *小时产量的计算 -- 台班
      LOOP AT I_BTBHA INTO WA_BTBHA.


        CLEAR : LV_DAT , LV_BTBHA.
        IF STRLEN( WA_BTBHA-BTBHA ) = 8.
          CONCATENATE '20' WA_BTBHA-BTBHA+2(6) INTO LV_DAT.
          LV_BTBHA = WA_BTBHA-BTBHA+0(2).
        ELSEIF STRLEN( WA_BTBHA-BTBHA ) = 10.
          CONCATENATE '20' WA_BTBHA-BTBHA+4(6) INTO LV_DAT.
          LV_BTBHA = WA_BTBHA-BTBHA+0(4).
        ENDIF.


        REFRESH I_CONFIRM.
        SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE LTXA1 = WA_BTBHA-BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
        IF SY-SUBRC = 0.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             APPENDING CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.


          LOOP AT I_CONFIRM INTO WA_CONFIRM.
    *机器运行时间
            WA_BTBHA-TIMES = WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
            WA_BTBHA-HOURS = WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
          ENDLOOP.


        ELSE.


          SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE BUDAT = LV_DAT
             AND LTXA1 = ''
             AND LOGRP = LV_BTBHA
             AND STOKZ <> 'X'
             AND STZHL = ''.
          IF SY-SUBRC = 0.
            LOOP AT I_CONFIRM INTO WA_CONFIRM.
    *机器运行时间
              WA_BTBHA-TIMES = WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
              WA_BTBHA-HOURS = WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
            ENDLOOP.
          ENDIF.
        ENDIF.
        WA_BTBHA-UNITS = 'H'.
        MODIFY I_BTBHA FROM WA_BTBHA.
      ENDLOOP.
    ENDFORM.                    " FRM_BY_TB
    *&---------------------------------------------------------------------*
    *&      Form  FRM_BY_ORDER
    *&---------------------------------------------------------------------*
    *       按订单
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_BY_ORDER .
      DATA :
    *存放比较的订单号
           LV_AUFNR TYPE AUFNR.


    *按订单排序
      SORT I_DATA BY AUFNR .


    *取订单产品规格信息
      PERFORM FRM_GET_ORDERSPEC.


    *处理查询结果到输出内表:I_BTBHA
      READ TABLE I_DATA INTO WA_DATA INDEX 1.
      LV_AUFNR = WA_DATA-AUFNR.
      CLEAR : WA_DATA.
      REFRESH : I_BTBHA.


      LOOP AT I_DATA INTO WA_DATA.
        IF LV_AUFNR = WA_DATA-AUFNR.
    *同一个订单
          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.
        ELSE.
    *不同订单
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = WA_DATA-BKTXT.  "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          APPEND WA_BTBHA TO I_BTBHA.


          LV_AUFNR = WA_DATA-AUFNR.
          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.


        ENDIF.


        MODIFY I_DATA FROM WA_DATA.


        AT LAST.
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = WA_DATA-BKTXT.  "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          APPEND WA_BTBHA TO I_BTBHA.


          CLEAR : LV_AUFNR,
                  GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料
        ENDAT.
      ENDLOOP.


    *小时产量的计算 -- 订单
      LOOP AT I_BTBHA INTO WA_BTBHA.
        REFRESH I_CONFIRM.
        SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = WA_BTBHA-CPDDH
             AND BUDAT BETWEEN GV_START AND GV_FINISH
             AND BUDAT IN S_BUDAT
             AND STOKZ <> 'X'
             AND STZHL = ''.
        IF SY-SUBRC = 0.
          LOOP AT I_CONFIRM INTO WA_CONFIRM.
    *机器运行时间
            WA_BTBHA-TIMES = WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
            WA_BTBHA-HOURS = WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
          ENDLOOP.
        ENDIF.
        WA_BTBHA-UNITS = 'H'.
        MODIFY I_BTBHA FROM WA_BTBHA.
      ENDLOOP.
    ENDFORM.                    " FRM_BY_ORDER
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_9000  OUTPUT
    *&---------------------------------------------------------------------*
    *       输出屏幕的PBO
    *----------------------------------------------------------------------*
    MODULE STATUS_9000 OUTPUT.
      SET PF-STATUS '9000'.
      IF P_R1 = 'X'.
        SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 按台班订单'.
      ELSEIF P_R2 = 'X'.
        SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 按订单台班'.
      ELSEIF P_R3 = 'X'.
        SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 按台班'.
      ELSEIF P_R4 = 'X'.
        SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 按订单'.
      ELSEIF P_R5 = 'X'.
        SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 按产品层次跟物料代码'.
      ENDIF.


    ENDMODULE.                 " STATUS_9000  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_9000  INPUT
    *&---------------------------------------------------------------------*
    *       输出屏幕的PAI
    *----------------------------------------------------------------------*
    MODULE USER_COMMAND_9000 INPUT.
      CASE OK_CODE.
        WHEN 'BACK' OR 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
        WHEN OTHERS .
      ENDCASE.
      CLEAR : OK_CODE.
    ENDMODULE.                 " USER_COMMAND_9000  INPUT
    *&---------------------------------------------------------------------*
    *&      Form  FRM_PROCESS_DATA
    *&---------------------------------------------------------------------*
    *       处理输出值
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_PROCESS_DATA .
      DATA :
    *投入原料+余料
           LV_MATERIAL(16) TYPE P DECIMALS 2,
    *成材率
           LV_DBCCL TYPE ZZLMS,
    *回收率
           LV_DBHSL TYPE ZZLMS,
    *损耗率
           LV_DBSHL TYPE ZZLMS.


      LOOP AT I_DATA INTO WA_DATA WHERE MARK <> ''.
        IF WA_DATA-MARK = 'A'.
          WA_DATA-REMARK = '投入原材料'.
        ELSEIF WA_DATA-MARK = 'B'.
          WA_DATA-REMARK = '合格品'.
        ELSEIF WA_DATA-MARK = 'C'.
          WA_DATA-REMARK = '待检品'.
        ELSEIF WA_DATA-MARK = 'D'.
          WA_DATA-REMARK = '不合格品'.
        ELSEIF WA_DATA-MARK = 'E'.
          WA_DATA-REMARK = '返工合格品'.
        ELSEIF WA_DATA-MARK = 'F'.
          WA_DATA-REMARK = '返工待检品'.
        ELSEIF WA_DATA-MARK = 'G'.
          WA_DATA-REMARK = '返工不合格品'.
        ELSEIF WA_DATA-MARK = 'H'.
          WA_DATA-REMARK = '波纤'.
        ELSEIF WA_DATA-MARK = 'I'.
          WA_DATA-REMARK = '余料'.
        ENDIF.


        IF WA_DATA-SHKZG = 'H'.
    *数量 ( + / -)
          WA_DATA-MENGE = 0 - WA_DATA-MENGE.
    *本位币金额  ( + / -)
          WA_DATA-DMBTR = 0 - WA_DATA-DMBTR.
        ENDIF.
    *班组
        WA_DATA-GROUP = WA_DATA-BKTXT+0(2) .


        MODIFY I_DATA FROM WA_DATA.


      ENDLOOP.


      IF I_BTBHA IS NOT INITIAL.
    *处理输出列表
        LOOP AT I_BTBHA INTO WA_BTBHA.
          CLEAR :
                LV_MATERIAL,
                LV_DBCCL,
                LV_DBHSL.


    *原料产品产出
          WA_BTBHA-YLCCHJ = WA_BTBHA-HGPZL + WA_BTBHA-DJYPZL +
            WA_BTBHA-BHGPZL + WA_BTBHA-FGHGP +
            WA_BTBHA-FGDJP + WA_BTBHA-FGBHGP.


    *成材率
          IF WA_BTBHA-YLFT <> 0.
            LV_DBCCL = ( TRUNC( ( WA_BTBHA-YLCCHJ /
              WA_BTBHA-YLFT ) * 10000 ) ) / 100.
          ELSE.
            LV_DBCCL = 0.
          ENDIF.




          WA_BTBHA-DBCCL = ABS( LV_DBCCL ).
          CONDENSE WA_BTBHA-DBCCL NO-GAPS.
          CONCATENATE WA_BTBHA-DBCCL C_SIGN INTO WA_BTBHA-DBCCL.


    *回收率
          IF WA_BTBHA-YLFT <> 0.
            LV_DBHSL = ( TRUNC( ( ( WA_BTBHA-BXFX + WA_BTBHA-YUL )
              / WA_BTBHA-YLFT ) * 10000 ) ) / 100.
          ELSE.
            LV_DBHSL = 0.
          ENDIF.


          WA_BTBHA-DBHSL = ABS( LV_DBHSL ).
          CONDENSE WA_BTBHA-DBHSL NO-GAPS.
          CONCATENATE WA_BTBHA-DBHSL C_SIGN INTO WA_BTBHA-DBHSL.


    *损耗率 = (投入原料-产出成品-余料/联产品)/投入原料
          IF WA_BTBHA-YLFT <> 0.
            LV_DBSHL = ( TRUNC( ( ( WA_BTBHA-YLFT + WA_BTBHA-YLCCHJ
               + WA_BTBHA-BXFX + WA_BTBHA-YUL )
              / WA_BTBHA-YLFT ) * 10000 ) ) / 100.
          ELSE.
            LV_DBSHL = 0.
          ENDIF.


          WA_BTBHA-DBSHL = ABS( LV_DBSHL ).
          CONDENSE WA_BTBHA-DBSHL NO-GAPS.
          CONCATENATE WA_BTBHA-DBSHL C_SIGN INTO WA_BTBHA-DBSHL.


    *投入产出比
          LV_MATERIAL = WA_BTBHA-YLFT + WA_BTBHA-YUL.
          IF LV_MATERIAL  <> 0.
            WA_BTBHA-RATE = ( WA_BTBHA-YLCCHJ + WA_BTBHA-BXFX ) /
              ( WA_BTBHA-YLFT + WA_BTBHA-YUL ).
          ELSE.
            WA_BTBHA-RATE = 0.
          ENDIF.


          WA_BTBHA-RATE = ABS( WA_BTBHA-RATE ).


    *错误标示
          IF WA_BTBHA-RATE > 1 OR WA_BTBHA-RATE < C_RATE.
            WA_BTBHA-ICON = ICON_LED_RED.
            WA_CELLCOLOR-FNAME = 'RATE' .
            WA_CELLCOLOR-COLOR-COL = '6' .
            WA_CELLCOLOR-COLOR-INT = '1' .
            APPEND WA_CELLCOLOR TO WA_BTBHA-CELLCOLORS .
          ELSE.
            WA_BTBHA-ICON = ICON_LED_GREEN.
            WA_CELLCOLOR-FNAME = 'RATE' .
            WA_CELLCOLOR-COLOR-COL = '1' .
            WA_CELLCOLOR-COLOR-INT = '1' .
            APPEND WA_CELLCOLOR TO WA_BTBHA-CELLCOLORS .
          ENDIF.


    *小时产量
          IF WA_BTBHA-TIMES <> 0.
            WA_BTBHA-AS = WA_BTBHA-YLCCHJ / WA_BTBHA-TIMES.
          ENDIF.
    *      IF WA_BTBHA-TIMES = 0 OR WA_BTBHA-TIMES > 20 .
          IF WA_BTBHA-TIMES <= 0 .
            WA_CELLCOLOR-FNAME = 'TIMES' .
            WA_CELLCOLOR-COLOR-COL = '6' .
            WA_CELLCOLOR-COLOR-INT = '1' .
            APPEND WA_CELLCOLOR TO WA_BTBHA-CELLCOLORS .
          ENDIF.


    *订单产品代码
          IF WA_BTBHA-MATNR IS NOT INITIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                INPUT  = WA_BTBHA-MATNR
              IMPORTING
                OUTPUT = WA_BTBHA-MATNR.
          ENDIF.


    *订单号
          IF WA_BTBHA-CPDDH IS NOT INITIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                INPUT  = WA_BTBHA-CPDDH
              IMPORTING
                OUTPUT = WA_BTBHA-CPDDH.
          ENDIF.


          MODIFY I_BTBHA FROM WA_BTBHA.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " FRM_PROCESS_DATA
    *&---------------------------------------------------------------------*
    *&      Form  FRM_SUBTOTAL
    *&---------------------------------------------------------------------*
    *       分类合并处理
    *----------------------------------------------------------------------*
    *      -->P_WA_DATA  text
    *----------------------------------------------------------------------*
    FORM FRM_SUBTOTAL  CHANGING P_WA_DATA TYPE T_TAB.
      DATA :
    *物料描述
            LV_MAKTX TYPE MAKTX.


    *包装物
      IF P_WA_DATA-MATNR+8(1) = '5'.
        EXIT.
      ENDIF.


      IF P_WA_DATA-BWART = '321'."质检库存到非限制库存
        EXIT.
      ENDIF.


      SELECT SINGLE MAKTX
        INTO LV_MAKTX
        FROM MAKT
       WHERE MATNR = P_WA_DATA-MATNR
         AND SPRAS = SY-LANGU.
    *----------------
    *投入原材料     A
    *合格品        B
    *待检品        C
    *不合格品      D
    *返工合格品    E
    *返工待检品    F
    *返工不合格品  G
    *波纤         H
    *余料         I
    *----------------


    *波纤 531 & 101
      SEARCH LV_MAKTX FOR C_SUS.
      IF SY-SUBRC = 0.
        IF P_WA_DATA-SHKZG = 'S'.
          GV_BXFX = GV_BXFX + P_WA_DATA-MENGE.
        ELSEIF P_WA_DATA-SHKZG = 'H'.
          GV_BXFX = GV_BXFX - P_WA_DATA-MENGE.
        ENDIF.
        P_WA_DATA-MARK = 'H'.
        EXIT.
      ENDIF.


    *余料
      SEARCH LV_MAKTX FOR C_YUL.
      IF SY-SUBRC = 0.
        IF P_WA_DATA-SHKZG = 'S'.
          GV_YUL = GV_YUL + P_WA_DATA-MENGE.
        ELSEIF P_WA_DATA-SHKZG = 'H'.
          GV_YUL = GV_YUL - P_WA_DATA-MENGE.
        ENDIF.
        P_WA_DATA-MARK = 'I'.
        EXIT.
      ENDIF.
      SEARCH LV_MAKTX FOR C_WEIL.
      IF SY-SUBRC = 0.
        IF P_WA_DATA-SHKZG = 'S'.
          GV_YUL = GV_YUL + P_WA_DATA-MENGE.
        ELSEIF P_WA_DATA-SHKZG = 'H'.
          GV_YUL = GV_YUL - P_WA_DATA-MENGE.
        ENDIF.
        P_WA_DATA-MARK = 'I'.
        EXIT.
      ENDIF.


    *-------------------------------------L 拉丝
      IF P_WA_DATA-BKTXT+0(1) = 'L'.
        SEARCH LV_MAKTX FOR C_LASI.
        IF SY-SUBRC = 0.
    *原材料
          IF P_WA_DATA-SHKZG = 'S'.
            GV_YLFT = GV_YLFT + P_WA_DATA-MENGE.
          ELSEIF P_WA_DATA-SHKZG = 'H'.
            GV_YLFT = GV_YLFT - P_WA_DATA-MENGE.
          ENDIF.
          P_WA_DATA-MARK = 'A'.
          EXIT.
        ELSE.
    *合格品
          IF P_WA_DATA-SHKZG = 'S'.
            GV_HGPZL = GV_HGPZL + P_WA_DATA-MENGE.
          ELSEIF P_WA_DATA-SHKZG = 'H'.
            GV_HGPZL = GV_HGPZL - P_WA_DATA-MENGE.
          ENDIF.
          P_WA_DATA-MARK = 'B'.
          EXIT.
        ENDIF.


      ELSE.


    *原材料
        IF P_WA_DATA-BKTXT+0(2) <> 'GI'.
          IF P_WA_DATA-MATNR+8(1) = '1'  "钢丝φ3.0 铜丝 青铜棒 紫铜棒
    *------------------------------------T 退火棉
          OR ( P_WA_DATA-MATNR+8(1) = '4' AND P_WA_DATA-BWART = '261' )
          OR ( P_WA_DATA-MATNR+8(1) = '4' AND P_WA_DATA-BWART = '262' ).
            IF P_WA_DATA-SHKZG = 'S'.
              GV_YLFT = GV_YLFT + P_WA_DATA-MENGE.
            ELSEIF P_WA_DATA-SHKZG = 'H'.
              GV_YLFT = GV_YLFT - P_WA_DATA-MENGE.
            ENDIF.
            P_WA_DATA-MARK = 'A'.
            EXIT.
          ENDIF.
        ELSE.
    *-------------------------------------GI 棉块班
          IF P_WA_DATA-MATNR+8(1) = '1' OR         "---------GI 原料应该只是棉卷的
          ( P_WA_DATA-MATNR+8(1) = '3' AND P_WA_DATA-BWART = '261' ) OR
          ( P_WA_DATA-MATNR+8(1) = '3' AND P_WA_DATA-BWART = '262' ).
            IF P_WA_DATA-CHARG+0(1) = '#'.
    *返工待检品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_FGDJP = GV_FGDJP + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_FGDJP = GV_FGDJP - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'F'.
              EXIT.
            ELSEIF P_WA_DATA-CHARG+0(1) = '^'.
    *返工不合格品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_FGBHGP = GV_FGBHGP + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_FGBHGP = GV_FGBHGP - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'G'.
              EXIT.
            ELSE.
    *原材料
              IF P_WA_DATA-SHKZG = 'S'.
                GV_YLFT = GV_YLFT + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_YLFT = GV_YLFT - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'A'.
              EXIT.
            ENDIF.
          ENDIF.
        ENDIF.


    *成品 & 返工品
        IF P_WA_DATA-MATNR+8(1) = '3'
          OR P_WA_DATA-MATNR+8(1) = '4' ."退火棉(半成品)
    *成品
          IF P_WA_DATA-BWART = '101'    "按订单收货
            OR P_WA_DATA-BWART = '102'   "冲销直接收货
            OR P_WA_DATA-BWART = '122'   "向供应商退货
            OR P_WA_DATA-BWART = '123'   "退货供应商冲销
            .
            IF P_WA_DATA-CHARG+0(1) = '#'.
    *待检品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_DJYPZL = GV_DJYPZL + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_DJYPZL = GV_DJYPZL - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'C'.
              EXIT.
            ELSEIF P_WA_DATA-CHARG+0(1) = '^'.
    *不合格品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_BHGPZL = GV_BHGPZL + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_BHGPZL = GV_BHGPZL - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'D'.
              EXIT.
            ELSE.
    *合格品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_HGPZL = GV_HGPZL + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_HGPZL = GV_HGPZL - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'B'.
              EXIT.
            ENDIF.


    *返工品
          ELSEIF P_WA_DATA-BWART = '261'  "工单领料
              OR P_WA_DATA-BWART = '262'  "工单退料
    *          OR P_WA_DATA-BWART = '122'   "向供应商退货
    *          OR P_WA_DATA-BWART = '123'  "退货供应商冲销
            .
            IF P_WA_DATA-CHARG+0(1) = '#'.
    *返工待检品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_FGDJP = GV_FGDJP + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_FGDJP = GV_FGDJP - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'F'.
              EXIT.
            ELSEIF P_WA_DATA-CHARG+0(1) = '^'.
    *返工不合格品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_FGBHGP = GV_FGBHGP + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_FGBHGP = GV_FGBHGP - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'G'.
              EXIT.
            ELSE.
    *返工合格品
              IF P_WA_DATA-SHKZG = 'S'.
                GV_FGHGP = GV_FGHGP + P_WA_DATA-MENGE.
              ELSEIF P_WA_DATA-SHKZG = 'H'.
                GV_FGHGP = GV_FGHGP - P_WA_DATA-MENGE.
              ENDIF.
              P_WA_DATA-MARK = 'E'.
              EXIT.
            ENDIF.
          ENDIF.
        ENDIF.


      ENDIF.
    ENDFORM.                    " FRM_SUBTOTAL
    *&---------------------------------------------------------------------*
    *&      Form  FRM_GET_ORDERSPEC
    *&---------------------------------------------------------------------*
    *        取订单产品代码&描述
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_GET_ORDERSPEC .
      DATA :
            LV_I_DATA TYPE STANDARD TABLE OF T_TAB.


      MOVE I_DATA TO LV_I_DATA.
      DELETE ADJACENT DUPLICATES FROM LV_I_DATA COMPARING AUFNR.
      CLEAR : WA_DATA,WA_SPEC.
      REFRESH I_SPEC.


      LOOP AT LV_I_DATA INTO WA_DATA.


        CLEAR : WA_SPEC.
    *订单号
        WA_SPEC-AUFNR =  WA_DATA-AUFNR.


    *取订单产品代码
        SELECT SINGLE PLNBEZ
          FROM AFKO
          INTO WA_SPEC-MATNR
          WHERE AUFNR = WA_SPEC-AUFNR.


    *取订单产品描述
        SELECT SINGLE MAKTX
          FROM MAKT
          INTO WA_SPEC-MAKTX
          WHERE MATNR = WA_SPEC-MATNR
            AND SPRAS = SY-LANGU.
        IF SY-SUBRC <> 0.
          SELECT SINGLE MAKTX
           FROM MAKT
           INTO WA_SPEC-MAKTX
           WHERE MATNR = WA_SPEC-MATNR
             AND SPRAS = 'EN'.
        ENDIF.


    *取产品层次
        SELECT SINGLE PRDHA
          FROM MARA
          INTO WA_SPEC-PRDHA
          WHERE MATNR = WA_SPEC-MATNR.
        IF WA_SPEC-PRDHA IS NOT INITIAL.
          SELECT SINGLE VTEXT
                 FROM T179T
                 INTO WA_SPEC-VTEXT
                 WHERE PRODH = WA_SPEC-PRDHA
                   AND SPRAS = SY-LANGU.
        ELSE.
          IF WA_SPEC-MATNR+8 = '1011003001'.
            WA_SPEC-VTEXT = WA_SPEC-MAKTX.
            WA_SPEC-PRDHA = '222'.
          ELSEIF WA_SPEC-MATNR+8 = '1521015603'
            OR WA_SPEC-MATNR+8 = '1521015604'.
            WA_SPEC-VTEXT = TEXT-012.
            WA_SPEC-PRDHA = '444'.
          ELSEIF WA_SPEC-MATNR+8(1) = '4'.
            WA_SPEC-VTEXT = TEXT-011.
            WA_SPEC-PRDHA = '333'.
          ENDIF.
        ENDIF.


        APPEND WA_SPEC TO I_SPEC.
      ENDLOOP.


    ENDFORM.                    " FRM_GET_ORDERSPEC
    *&---------------------------------------------------------------------*
    *&      Form  HANDLE_HOTSPOT_CLICK
    *&---------------------------------------------------------------------*
    *       热点事件方法
    *----------------------------------------------------------------------*
    *      -->P_E_ROW  text
    *      -->P_E_COLUMN  text
    *      -->P_ES_ROW_NO  text
    *----------------------------------------------------------------------*
    FORM HANDLE_HOTSPOT_CLICK  USING  P_ROW_NO TYPE LVC_S_ROID
                                      E_COLUMN_ID TYPE LVC_S_COL.


      CLEAR : WA_BTBHA.
      READ TABLE I_BTBHA INTO WA_BTBHA INDEX P_ROW_NO-ROW_ID.


      IF E_COLUMN_ID-FIELDNAME = 'ICON'.
        IF WA_BTBHA-ICON = ICON_LED_RED.
          MESSAGE '生产投入产出不平衡!' TYPE 'I'.
        ELSE.
          MESSAGE '生产投入产出平衡!' TYPE 'I'.
        ENDIF.
      ELSEIF E_COLUMN_ID-FIELDNAME = 'CPDDH'.
        SET PARAMETER ID 'ANR' FIELD WA_BTBHA-CPDDH.
        CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN.
      ELSEIF E_COLUMN_ID-FIELDNAME = 'BTBHA'.


      ELSEIF E_COLUMN_ID-FIELDNAME = 'MATNR'.
        SET PARAMETER ID 'MAT' FIELD WA_BTBHA-MATNR.
        CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.


    *  ELSEIF E_COLUMN_ID-FIELDNAME = 'RATE'.
    *    MESSAGE '投入产出比 = (原料产品产出 + 波纤)/(投入原材料 + 余料)' TYPE 'I'.
      ENDIF.


    ENDFORM.                    " HANDLE_HOTSPOT_CLICK
    *&---------------------------------------------------------------------*
    *&      Form  HANDLE_DOUBLE_CLICK
    *&---------------------------------------------------------------------*
    *       双击事件方法
    *----------------------------------------------------------------------*
    *      -->P_E_ROW  text
    *      -->P_E_COLUMN  text
    *----------------------------------------------------------------------*
    FORM HANDLE_DOUBLE_CLICK  USING    P_ROW TYPE LVC_S_ROW
                                       P_COLUMN TYPE LVC_S_COL.
      IF P_R5 <> 'X'.
        CLEAR : WA_BTBHA.
        READ TABLE I_BTBHA INTO WA_BTBHA INDEX P_ROW-INDEX.
        IF SY-SUBRC = 0.
          IF P_COLUMN-FIELDNAME = 'YLFT'. "A
    *投入原材料
            PERFORM FRM_GET_DETAIL USING 'A' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'HGPZL'."B
    *合格品
            PERFORM FRM_GET_DETAIL USING 'B' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'DJYPZL'. "C
    *待检品
            PERFORM FRM_GET_DETAIL USING 'C' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'BHGPZL'. "D
    *不合格品
            PERFORM FRM_GET_DETAIL USING 'D' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'FGHGP'. "E
    *返工合格品
            PERFORM FRM_GET_DETAIL USING 'E' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'FGDJP'. "F
    *返工待检品
            PERFORM FRM_GET_DETAIL USING 'F' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'FGBHGP'. "G
    *返工不合格品
            PERFORM FRM_GET_DETAIL USING 'G' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'BXFX'. "H
    *波纤
            PERFORM FRM_GET_DETAIL USING 'H' WA_BTBHA.


          ELSEIF P_COLUMN-FIELDNAME = 'YUL'. "I
    *余料
            PERFORM FRM_GET_DETAIL USING 'I' WA_BTBHA.


          ELSE.
            EXIT.
          ENDIF.
          IF I_DETAIL IS INITIAL.
            MESSAGE '没有任何明细条目!' TYPE 'S' DISPLAY LIKE 'E'.
            EXIT.
          ENDIF.
    *明细画面
          CALL SCREEN 9001.
        ENDIF.
      ENDIF.
    ENDFORM.                    " HANDLE_DOUBLE_CLICK
    *&---------------------------------------------------------------------*
    *&      Form  FRM_GET_DETAIL
    *&---------------------------------------------------------------------*
    *       取明细信息
    *----------------------------------------------------------------------*
    *      -->P_3783   text
    *----------------------------------------------------------------------*
    FORM FRM_GET_DETAIL  USING  P_MARK TYPE CHAR01
                                 P_WA_BTBHA TYPE T_STUC.
      DATA :
            LV_WA_DETAIL TYPE T_TAB.


      REFRESH I_DETAIL.
      CLEAR : LV_WA_DETAIL , WA_DATA.
      IF P_R1 = 'X'.
        IF P_WA_BTBHA-CPDDH <> '合计'.
          LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                        AND BKTXT = P_WA_BTBHA-BTBHA
                                        AND AUFNR = P_WA_BTBHA-CPDDH.
            MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
            APPEND LV_WA_DETAIL TO I_DETAIL.
          ENDLOOP.
        ELSE.
          LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                        AND BKTXT = P_WA_BTBHA-BTBHA.
            MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
            APPEND LV_WA_DETAIL TO I_DETAIL.
          ENDLOOP.
        ENDIF.
      ELSEIF P_R2 = 'X'.
        IF P_WA_BTBHA-BTBHA <> '合计'.
          LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                        AND AUFNR = P_WA_BTBHA-CPDDH
                                        AND BKTXT = P_WA_BTBHA-BTBHA.
            MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
            APPEND LV_WA_DETAIL TO I_DETAIL.
          ENDLOOP.
        ELSE.
          LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                        AND AUFNR = P_WA_BTBHA-CPDDH.
            MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
            APPEND LV_WA_DETAIL TO I_DETAIL.
          ENDLOOP.
        ENDIF.
      ELSEIF P_R3 = 'X'.
        LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                      AND BKTXT = P_WA_BTBHA-BTBHA.
          MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
          APPEND LV_WA_DETAIL TO I_DETAIL.
        ENDLOOP.
      ELSEIF P_R4 = 'X'.
        LOOP AT I_DATA INTO WA_DATA WHERE MARK = P_MARK
                                      AND AUFNR = P_WA_BTBHA-CPDDH.
          MOVE-CORRESPONDING WA_DATA TO LV_WA_DETAIL.
          APPEND LV_WA_DETAIL TO I_DETAIL.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " FRM_GET_DETAIL
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_9001  OUTPUT
    *&---------------------------------------------------------------------*
    *       9001 PBO
    *----------------------------------------------------------------------*
    MODULE STATUS_9001 OUTPUT.
      SET PF-STATUS '9000'.
      SET TITLEBAR 'TITLE' WITH '生产投入产出平衡检查及指标分析 - 明细'.
      PERFORM FRM_INITIAL_CONTAINER.
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_9001  INPUT
    *&---------------------------------------------------------------------*
    *       9001 PAI
    *----------------------------------------------------------------------*
    MODULE USER_COMMAND_9001 INPUT.
      CASE OK_CODE1.
        WHEN 'BACK' OR 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
        WHEN OTHERS .
      ENDCASE.
      CLEAR : OK_CODE1.
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    *&---------------------------------------------------------------------*
    *&      Form  FRM_INITIAL_CONTAINER
    *&---------------------------------------------------------------------*
    *       初始化容器对象
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_INITIAL_CONTAINER .
      IF GV_CONTAINER1 IS INITIAL.
        CREATE OBJECT GV_CONTAINER1
          EXPORTING
            CONTAINER_NAME              = GV_CNAME1
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5.
      ENDIF.


      IF GV_DETAIL IS INITIAL.
    *创建ALV容器
        CREATE OBJECT GV_DETAIL
          EXPORTING
            I_PARENT          = GV_CONTAINER1
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4.


    *ALV的设置
        PERFORM FRM_ALV_LIST_DETAIL.
      ENDIF.


    *AVL的显示
      CALL METHOD GV_DETAIL->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IS_LAYOUT                     = GV_LAYOUT1
    *        I_SAVE                        = 'A'
        CHANGING
          IT_OUTTAB                     = I_DETAIL
          IT_FIELDCATALOG               = I_FCAT
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.


    ENDFORM.                    " FRM_INITIAL_CONTAINER
    *&---------------------------------------------------------------------*
    *&      Form  FRM_ALV_LIST_DETAIL
    *&---------------------------------------------------------------------*
    *       明细ALV设置
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_ALV_LIST_DETAIL .
    *-------------------Layout
      GV_LAYOUT1-SEL_MODE = 'D'.
      GV_LAYOUT1-CWIDTH_OPT = 'X'.
      GV_LAYOUT1-ZEBRA = 'X' .
      GV_LAYOUT1-GRID_TITLE = '明细' .
      GV_LAYOUT1-SMALLTITLE = 'X' .


    *------------------Fieldcat
      DATA:
              LV_WA_FCAT TYPE LVC_S_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'GROUP'.
      LV_WA_FCAT-COLTEXT = '班组'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'REMARK'.
      LV_WA_FCAT-COLTEXT = '标志'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'CHARG'.
      LV_WA_FCAT-COLTEXT = '批次'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'AUFNR'.
      LV_WA_FCAT-COLTEXT = '生产订单号'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'BKTXT'.
      LV_WA_FCAT-COLTEXT = '凭证抬头文本'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MATNR'.
      LV_WA_FCAT-COLTEXT = '物料'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MAKTX'.
      LV_WA_FCAT-COLTEXT = '物料描述'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'SHKZG'.
      LV_WA_FCAT-COLTEXT = 'D/C'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'BWART'.
      LV_WA_FCAT-COLTEXT = 'MvT'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MENGE'.
      LV_WA_FCAT-COLTEXT = '数量(+/-)'.
      LV_WA_FCAT-QFIELDNAME = 'MEINS'.
      LV_WA_FCAT-DO_SUM = 'X'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MEINS'.
      LV_WA_FCAT-COLTEXT = 'BUn'.
      LV_WA_FCAT-REF_FIELD = 'MEINS'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'DMBTR'.
      LV_WA_FCAT-COLTEXT = '本位币金额(+/-)'.
      LV_WA_FCAT-QFIELDNAME = 'WAERS'.
      LV_WA_FCAT-DO_SUM = 'X'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'WAERS'.
      LV_WA_FCAT-COLTEXT = '货币'.
      LV_WA_FCAT-REF_FIELD = 'WAERS'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MJAHR'.
      LV_WA_FCAT-COLTEXT = 'MatYr'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'MBLNR'.
      LV_WA_FCAT-COLTEXT = '物料凭证'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'ZEILE'.
      LV_WA_FCAT-COLTEXT = '项目'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'BUDAT'.
      LV_WA_FCAT-COLTEXT = '过账日期'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'LGORT'.
      LV_WA_FCAT-COLTEXT = '库位'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'SOBKZ'.
      LV_WA_FCAT-COLTEXT = 'S'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'KDAUF'.
      LV_WA_FCAT-COLTEXT = '销售订单号'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'KDPOS'.
      LV_WA_FCAT-COLTEXT = 'SO项目'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'RSNUM'.
      LV_WA_FCAT-COLTEXT = '预留编号'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'RSPOS'.
      LV_WA_FCAT-COLTEXT = '项'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'USNAM'.
      LV_WA_FCAT-COLTEXT = '用户名称'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'SAKTO'.
      LV_WA_FCAT-COLTEXT = '总账科目'.
      APPEND LV_WA_FCAT TO I_FCAT.


      CLEAR LV_WA_FCAT.
      LV_WA_FCAT-FIELDNAME = 'WERKS'.
      LV_WA_FCAT-COLTEXT = '工厂'.
      APPEND LV_WA_FCAT TO I_FCAT.


    ENDFORM.                    " FRM_ALV_LIST_DETAIL
    *&---------------------------------------------------------------------*
    *&      Form  FRM_BY_PRODUCT_LEVEL
    *&---------------------------------------------------------------------*
    *       按产品层次物料代码
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_BY_PRODUCT_LEVEL .
      DATA  :
    *临时存放的内表
            LV_I_PRDHA TYPE STANDARD TABLE OF T_PRDHA,
            LV_WA_PRDHA TYPE T_PRDHA,
            LV_I_TEMP TYPE STANDARD TABLE OF T_PRDHA,
            LV_WA_TEMP TYPE T_PRDHA.
      DATA :
    *存放比较的订单号
             LV_AUFNR TYPE AUFNR.


    *按订单排序
      SORT I_DATA BY AUFNR .


    *取订单产品规格信息
      PERFORM FRM_GET_ORDERSPEC.


    *处理查询结果到输出内表:I_BTBHA
      READ TABLE I_DATA INTO WA_DATA INDEX 1.
      LV_AUFNR = WA_DATA-AUFNR.
      CLEAR : WA_DATA.
      REFRESH : I_BTBHA.


      LOOP AT I_DATA INTO WA_DATA.
        IF LV_AUFNR = WA_DATA-AUFNR.
    *同一个订单
          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.
        ELSE.
    *不同订单
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = WA_DATA-BKTXT.  "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          WA_BTBHA-PRDHA = WA_SPEC-PRDHA.  "产品层次
          WA_BTBHA-VTEXT = WA_SPEC-VTEXT.  "层次描述
          APPEND WA_BTBHA TO I_BTBHA.


          LV_AUFNR = WA_DATA-AUFNR.
          CLEAR : GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料


          PERFORM FRM_SUBTOTAL CHANGING WA_DATA.
        ENDIF.


        MODIFY I_DATA FROM WA_DATA.


        AT LAST.
          CLEAR : WA_SPEC.
          READ TABLE I_SPEC INTO WA_SPEC WITH KEY AUFNR = LV_AUFNR.
          CLEAR : WA_BTBHA.
          WA_BTBHA-BTBHA = WA_DATA-BKTXT.  "台班班号
          WA_BTBHA-CPDDH = LV_AUFNR.       "产品订单号
          WA_BTBHA-YLFT = GV_YLFT.         "投入原材料
          WA_BTBHA-HGPZL = GV_HGPZL.       "合格品
          WA_BTBHA-DJYPZL = GV_DJYPZL.     "待检品
          WA_BTBHA-BHGPZL = GV_BHGPZL.     "不合格品
          WA_BTBHA-FGHGP = GV_FGHGP.       "返工合格品
          WA_BTBHA-FGDJP = GV_FGDJP.       "返工待检品
          WA_BTBHA-FGBHGP = GV_FGBHGP.     "返工不合格品
          WA_BTBHA-BXFX  = GV_BXFX.        "波纤
          WA_BTBHA-YUL = GV_YUL.           "余料
          WA_BTBHA-MAKTX = WA_SPEC-MAKTX.  "订单产品名称
          WA_BTBHA-MATNR = WA_SPEC-MATNR.  "订单产品代码
          WA_BTBHA-PRDHA = WA_SPEC-PRDHA.  "产品层次
          WA_BTBHA-VTEXT = WA_SPEC-VTEXT.  "层次描述
          APPEND WA_BTBHA TO I_BTBHA.


          CLEAR : LV_AUFNR,
                  GV_YLFT ,     "投入原材料
                  GV_HGPZL ,    "合格品
                  GV_DJYPZL ,   "待检品
                  GV_BHGPZL ,   "不合格品
                  GV_FGHGP ,    "返工合格品
                  GV_FGDJP ,    "返工待检品
                  GV_FGBHGP ,   "返工不合格品
                  GV_BXFX ,     "波纤
                  GV_YUL .      "余料
        ENDAT.
      ENDLOOP.


    *小时产量的计算 -- 订单
      LOOP AT I_BTBHA INTO WA_BTBHA.
        REFRESH I_CONFIRM.
        SELECT AUFNR LTXA1 BUDAT LOGRP ISM01 ISM02 ISM03
             INTO CORRESPONDING FIELDS OF TABLE I_CONFIRM
            FROM AFRU
           WHERE AUFNR = WA_BTBHA-CPDDH
             AND BUDAT BETWEEN GV_START AND GV_FINISH
             AND BUDAT IN S_BUDAT
             AND STOKZ <> 'X'
             AND STZHL = ''.
        IF SY-SUBRC = 0.
          LOOP AT I_CONFIRM INTO WA_CONFIRM.
    *机器运行时间
            WA_BTBHA-TIMES = WA_BTBHA-TIMES + WA_CONFIRM-ISM01.
    *工时
            WA_BTBHA-HOURS = WA_BTBHA-HOURS + WA_CONFIRM-ISM02.
          ENDLOOP.
        ENDIF.
        WA_BTBHA-UNITS = 'H'.
        MODIFY I_BTBHA FROM WA_BTBHA.
      ENDLOOP.


    *选择屏幕输入条件筛选
      IF S_PRDHA IS NOT INITIAL.
        DELETE I_BTBHA WHERE PRDHA NOT IN S_PRDHA.
      ENDIF.


      IF S_MATNR IS NOT INITIAL.
        DELETE I_BTBHA WHERE MATNR NOT IN S_MATNR.
      ENDIF.


      REFRESH LV_I_PRDHA.
      LOOP AT I_BTBHA INTO WA_BTBHA.
        MOVE-CORRESPONDING WA_BTBHA TO LV_WA_PRDHA.
        APPEND  LV_WA_PRDHA TO LV_I_PRDHA.
      ENDLOOP.


      SORT LV_I_PRDHA BY PRDHA MATNR.
      REFRESH LV_I_TEMP.
      DATA : LV_CHAR TYPE CHAR200.
      LOOP AT LV_I_PRDHA INTO LV_WA_PRDHA.
        MOVE-CORRESPONDING LV_WA_PRDHA TO LV_WA_TEMP.
        AT END OF MATNR.
          SUM.
          LV_WA_PRDHA-PRDHA = LV_WA_TEMP-PRDHA.
          LV_WA_PRDHA-VTEXT = LV_WA_TEMP-VTEXT.
          LV_WA_PRDHA-MATNR = LV_WA_TEMP-MATNR.
          LV_WA_PRDHA-MAKTX = LV_WA_TEMP-MAKTX.
          LV_WA_PRDHA-BTBHA = ''.
          LV_WA_PRDHA-CPDDH = ''.
          LV_WA_PRDHA-DBCCL = ''.
          LV_WA_PRDHA-DBHSL = ''.
          LV_WA_PRDHA-RATE = ''.
          LV_WA_PRDHA-ICON = ''.
          LV_WA_PRDHA-ROWCOLOR = ''.
          LV_WA_PRDHA-UNITS = 'H'.


          APPEND LV_WA_PRDHA TO LV_I_TEMP.
        ENDAT.


        AT END OF PRDHA.
          SUM.
          CLEAR LV_CHAR.
          CONCATENATE LV_WA_TEMP-PRDHA '合计' INTO LV_CHAR.
          LV_WA_PRDHA-PRDHA = LV_WA_TEMP-PRDHA.
          LV_WA_PRDHA-VTEXT = LV_WA_TEMP-VTEXT.
          LV_WA_PRDHA-MATNR = ''.
          LV_WA_PRDHA-MAKTX = LV_CHAR.
          LV_WA_PRDHA-BTBHA = ''.
          LV_WA_PRDHA-CPDDH = ''.
          LV_WA_PRDHA-DBCCL = ''.
          LV_WA_PRDHA-DBHSL = ''.
          LV_WA_PRDHA-RATE = ''.
          LV_WA_PRDHA-ICON = ''.
          LV_WA_PRDHA-ROWCOLOR = 'C311'.
          LV_WA_PRDHA-UNITS = 'H'.


          APPEND LV_WA_PRDHA TO LV_I_TEMP.
        ENDAT.
      ENDLOOP.


      REFRESH I_BTBHA.
      REFRESH LV_I_PRDHA.
      LOOP AT LV_I_TEMP INTO LV_WA_TEMP.
        MOVE-CORRESPONDING LV_WA_TEMP TO WA_BTBHA.
        APPEND WA_BTBHA TO I_BTBHA.
      ENDLOOP.






    ENDFORM.                    " FRM_BY_PRODUCT_LEVEL
    展开全文
  • 关于做好2018届毕业论文(设计)材料整理存档的通知各学院:2018届毕业论文(设计)是审核评估专家重点查看的材料之一,就材料整理存档工作做以下要求:一、学院存档材料(一)袋内材料,以学生个人为单位存档的材料每生一...

    关于做好2018届毕业论文(设计)

    材料整理存档的通知

    各学院:

    2018届毕业论文(设计)是审核评估专家重点查看的材料之一,就材料整理存档工作做以下要求:

    一、学院存档材料

    (一)袋内材料,以学生个人为单位存档的材料

    每生一个毕业论文(设计)资料袋,分专业、按学号顺序进行档案编号,并与毕业论文(设计)目录清单一一对应。

    1.毕业论文(设计)手册

    检查开题报告、任务书、指导过程记录表、指导教师评定表、专家评定表、答辩记录表、答辩委员会评定表、诚信承诺书填写内容是否符合要求、时间顺序是否合理,各栏签名是否齐备。

    2.毕业论文(设计)定稿正件

    逐一检查各项目的完整性。要求封面、英文封面、毕业论文(设计)原创性声明、毕业论文(设计)授权使用说明、答辩委员会(答辩小组)成员名单、中文摘要、外文摘要、目录、正文、参考文献、附录和致谢内容齐全,装订顺序正确。

    3.查重检测报告(要求见附件1)

    4.其他存档材料:论文(设计)主要修改稿(含修改痕迹),创作作品的图片、设计图纸、光盘等)

    (注:第4项内容根据实际情况,如果有则装入资料袋中)

    (二)工作材料,以学院为单位存档的材料

    1.各学院毕业论文(设计)管理实施细则及质量标准(学院正式发文文件);

    2.校院两级论文(设计)工作的通知及相关原始材料;

    3.××学院2018届毕业论文(设计)质量抽查分析报告(内容要求见附件1)

    4.××学院2018届毕业论文(设计)工作总结

    5.××学院2018届毕业论文(设计)目录清单(附件2)

    二、上报教务处材料

    ××学院2018届毕业论文(设计)题目清单

    三、毕业论文(设计)督查

    学院存档材料要求在下学期开学前整理归档完毕,上报教务处材料要求在下学期开学第一周内将纸质材料及电子文档报送至教务处实践教学科。拟计划于下学期第三周开始,学校对各学院毕业论文(设计)档案进行督查工作。

    联系人:丁老师

    电话:13529801107

    邮箱:1297696269@qq.com

    附件:

    1.教发〔2018〕41号关于2018届毕业论文(设计)的补充通知

    2.××学院毕业论文(设计)目录清单格式

    3.预评估专家针对毕业论文(设计)提出的意见

    红河学院教务处

    2018年6月22日

    展开全文
  • 一个很简单的例子,有一个Unit(单位)类型,有一个Inventory(背包)类型,有一个Item(道具)类型。 接下来先介绍框架中最重要的接口,ISavable,表示这个类型可以存档 public interface ISavable{ uint Id {get...
  • 最近重构了一下我的存档框架。...一个很简单的例子,有一个Unit(单位)类型,有一个Inventory(背包)类型,有一个Item(道具)类型。 接下来先介绍框架中最重要的接口,ISavable,表示这个类型可以存档 publ...

    最近重构了一下我的存档框架。我在这里对实现方法进行简单的解析。注意这里主要演示算法,所以,效率上并不是最佳。一个游戏中,可能有成百上千个物体需要存储,而且有几十种类型,接下来就用一个简单的例子来解释。一个很简单的例子,有一个Unit(单位)类型,有一个Inventory(背包)类型,有一个Item(道具)类型。

    接下来先介绍框架中最重要的接口,ISavable,表示这个类型可以存档

    public interface ISavable{
      uint Id {get; set;}
      Type DataType {get;} // 存档数据类型
      Type DataContainerType {get;} // 存档数据容器类型
      void Read(object data);
      void Write(object data);
    }

    ISavableContainer,用来返回一组ISavable的容器:

    public interface ISavableContainer{
        IEnumerable<ISavable> Savables;
    }

    IId, 具有Id的接口:

    public interface IId
    {
        uint Id {get; set;}
    }

     

    SaveEntity, 这是一个MonoBehaviour,将这个组件放到需要存档的GameObject上就可以实现该GameObject的存档了,这是最核心的类之一:

    public class SaveEntity : MonoBehaviour{
        public void Save(SaveDataContainer container){
            foreach(ISavable savable in GetSavables()){
                if(savable.DataContainerType = container.GetType()){
                    IId newData = Activator.CreateInstance(savable.DataType) as IId;
                    newData.Id = savable.Id;
                    savable.Write(newData);
                    container.SetData(newData);
                }
            }
        }
    
        public void Load(SaveDataContainer container){
            foreach(ISavable savable in GetSavables()){
                if(savable.DataContainerType = container.GetType()){
                    IId data = container.GetData(savable.Id);
                    savable.Read(data);
                }
            }        
        }
    
        public IEnumerable<ISavable> GetSavables(){
            foreach(ISavable savable in GetComponents<ISavable>()){
                yield return savable;
            }
            foreach(ISavable savableContainer in GetComponents<ISavableContainer>()){
                foreach(ISavable savable in savableContainer.Savables){
                    yield return savable;
                }
            }
        }
    }

     

    SaveFile代表一个文件

    [Serializable]
    public class SaveFileData{
        public uint CurId;
        public string DataContainer;
    }
    
    // 代表一个存档文件
    public class SaveFile: MonoBehaviour{
        // 包含实际数据的数据类
        private SaveDataContainer _saveDataContainer;
        private uint _curId;
    
        public string Path{get;set;}
        public SaveDataContainer SaveDataContainer{get{return _saveDataContainer;}}
    
        private uint NextId{get{return ++_curId;}}
    
        // 得到场景里所有的SaveEntity
        private IEnumerable<SaveEntity> GetEntities(){
            // 实现略过
        }
        
        // 将场景物体中的数据存入到_saveDataContainer中
        public void Save<T>() where T:SaveDataContainer, new()
        {
            // 一轮Id赋值,保证Id为0的所有ISavable都赋值一个新Id
            foreach(SaveEntity entity in Entities){
                foreach (Savable savable in entity.GetSavables()){
                    if(savable.DataContainerType == typeof(T)){
                        if(savable.Id == 0){
                            savable.Id = NextId;
                        }
                    }
                }
            }
    
            T dataContainer = new T();
    
            foreach(SaveEntity entity in Entities){
                entity.Save(this, dataContainer);
            }
    
            _saveDataContainer = dataContainer;
        }
    
        // 将_saveDataContainer中的数据载入到场景物体中
        public void Load(){
            foreach(SaveEntity entity in Entities){
                entity.Load(this, _saveDataContainer);
            }
        }
    
        public void LoadFromFile<T>() where T:SaveDataContainer
        {
            string json = File.ReadAllText(Path);
            SaveFileData data = JsonUtility.FromJson<SaveFileData>(json);
            _saveDataContainer = JsonUtility.FromJson<T>(data.DataContainer);
            _curId = data.CurId;
        }
    
        public void SaveToFile(){
            SaveFileData data = new SaveFileData();
            data.CurId = _curId;
            data.DataContainer = JsonUtility.ToJson(_saveDataContainer);
            string json = JsonUtility.ToJson(data);
            File.WriteAllText(Path, json);
        }
    }

    SaveDataContainer:

    // 这个类型存储了实际的数据,相当于是一个数据库
    [Serializable]
    public class SaveDataContainer{
        // 这个中存储这实际物体的数据,需要将这个字典转换成数组并序列化
        private Dictionary<uint, IId> _data;
    
        public Dictionary<unit, IId> Data{get{return _data}}
    
        public IId GetData(uint id){
            return _data[id];
        }
    
        public void SetData(IId data){
            _data[data.Id] = data;
        }
    }

    好了,框架就讲到这里,接下来实现示例代码:

    Unit:

    [Serializable]
    public class UnitSave:IId{
        [SerializeField]
        private uint _id;
        public uint PrefabId;
        public uint InventoryId;
        public int Hp;
        public int Level;
        public uint Id {get{return _id;}set{_id = value;}}
    }
    
    public class Unit:MonoBehaviour, ISavable{
        public int Hp;
        public int Level;
        public int PrefabId;
        public Inventory Inventory;
        
        public uint Id{get;set;}
        ISavable.DataType{get{return typeof(UnitSave);}}
        ISavable.DataContainerType{get{return typeof(ExampleSaveDataContainer);}}
        ISavable.Read(object data){
            UnitSave save = data as UnitSave;
            Hp = save.Hp;
            Level = save.Level;
        }
    
        ISavable.Write(object data){
            UnitSave save = data as UnitSave;
            save.Hp = Hp;
            save.Level = Level;
            save.InventoryId = Inventory.Id;
        }
    }

    Inventory: 

    [Serializable]
    public class InventorySave:IId{
        [SerializeField]
        private uint _id;
        public uint UnitId;
        public uint[] Items;
        public uint Id{get{return _id;}set{_id = value;}}
    }
    
    public class Inventory:MonoBehaviour, ISavable, ISavableContainer{
        public Unit Unit;
        public List<Item> Items;
    
        public uint Id{get;set;}
        ISavable.DataType{get{return typeof(InventorySave);}}
        ISavable.DataContainerType{get{return typeof(ExampleSaveDataContainer));}}
        ISavable.Read(object data){
            // 空
        }
        ISavable.Write(object data){
            InventorySave save = data as InventorySave;
            save.UnitId = Unit.Id;
            save.Items = Items.Select(item => item.Id).ToArray();
        }
    
        ISavableContainer.Savables{
            return Items;
        }
    }

    Item:

    [Serializable]
    public ItemSave: IId{
        [SerializeField]
        private uint _id;
        public uint PrefabId;
        public int Count;
        public uint Id{get{return _id;}set{_id = value;}}
    }
    
    // 道具并不是继承自MonoBehaviour的,是一个普通的类
    public class Item:ISavable{
        // 道具源数据所在Prefab,用于重新创建道具
        public uint PrefabId;
        public int Count;
        public uint Id {get;set;}
    
        public uint Id{get;set;}
        ISavable.DataType{get{return typeof(ItemSave);}}
        ISavable.DataContainerType{get{return typeof(ExampleSaveDataContainer));}}
        ISavable.Read(object data){
            ItemSave save = data as ItemSave;
            Count = save.Count;
        }
        ISavable.Write(object data){
            ItemSave save = data as ItemSave;
            save.PrefabId = PrefabId;
            save.Count = Count;
        }
    }

    ExampleSaveDataContainer:

    [Serializable]
    public class ExampleSaveDataContainer: SaveDataContainer, ISerializationCallbackReceiver {
        public UnitSave[] Units;
        public ItemSave[] Items;
        public InventorySave[] Inventories;
    
        public void OnBeforeSerialize(){
            // 将Data字典中的数据复制到数组中,实现略过
        }
    
        public void OnAfterDeserialize(){
            // 将数组中的数据赋值到Data字典中,实现略过
        }
    }
    
    

    ExampleGame:

    public class ExampleGame:MonoBehaviour{
    
        public void LoadGame(SaveFile file){
            // 从文件中读入数据到SaveDataContainer
            file.LoadFromFile<ExampleSaveDataContainer>();
            SaveDataContainer dataContainer = file.SaveDataContainer;
    
            // 创建所有物体并赋值相应Id
            Unit[] units = dataContainer.Units.Select(u=>CreateUnit(u));
            Item[] items = dataContainer.Items.Select(item=>CreateItem(item));
    
            // 将道具放入相应的道具栏中
            foreach(Unit unit in units){
                uint inventoryId = unit.Inventory.Id;
                InventorySave inventorySave = dataContainer.GetData(inventoryId);
                foreach(Item item in items.Where(i=>inventorySave.Items.Contains(i.Id))){
                    unit.Inventory.Put(item);
                }
            }
    
            // 调用Load进行实际的数据载入
            file.Load();
        }
    
        public void SaveGame(SaveFile file){
            // 相对来说,存档的实现比载入简单了许多
            file.Save<ExampleSaveDataContainer>();
            file.SaveToFile();
        }
    
        public Unit CreateUnit(UnitSave save){
            Unit unit = Instantiate(GetPrefab(save.PrefabId)).GetComponent<Unit>();
            unit.Id = save.Id;
            unit.Inventory.Id = save.InventoryId;
            return unit;
        }
    
        public Item CreateItem(ItemSave save){
            Item item = GetPrefab(save.PrefabId).GetComponent<ItemPrefab>().CreateItem();
            item.Id = save.Id;
            return item;
        }
    }

    使用方法:

    给单位Prefab中的Unit组件和Inventory组件所在的GameObject上放SaveEntity组件即可。

     

    思考问题:

    1. 扩展功能,让SaveFile包含一个SaveDataContainer数组,这样子可以实现包含多个数据容器(数据库)的情况
    2. 对SaveFile存储内容进行压缩,减少存储体积
    3. SaveFile存储到文件时进行加密,避免玩家修改存档
    4. 如何避免存储时候卡顿

     

    存储过程:

    1. 从场景中搜集数据到SaveFile中(SaveFile.Save),得到一个SaveFileData的数据
    2. 将SaveFileData序列化成一个json字符串
    3. 对字符串进行压缩
    4. 对压缩后的数据进行加密
    5. 将加密后的数据存储于文件 

    可以发现,只要完成第1步,得到一个SaveFileData,实际上就已经完成了存档了,接下来实际上就是一个数据转换的过程。所以,这也给出了避免游戏卡顿的一种方法:

    完成第一步之后,将后面的步骤全部都放到另一个线程里面处理。实际上,第一步的速度是相当快的。往往不会超过50ms,可以说,卡顿并不会很明显。

     

    展开全文
  • C1 任务1 修改游戏存档 1.找到游戏存档的位置 一开始没想到,游戏的数据放到哪里,所以刚开始一直在改这个userdata文件夹里的内容,结果存档一直没有效果,后来改劈叉后,删掉重新解压一次 发现数据和存档还在,...
  • 其中转换后大小单位为k,例如:0.5、8、64、256、512、1024………… 比如把test.sav转换成512k存档,输入: DSSaveTools 512 test.sav testout.sav 要转换成512b(0.5K)存档,输入: DSSaveTools 0.5 test...
  • 当前的研究涉及归档,存储文档和账簿,分析填写和存储方法的问题。 该研究同时强调了其起草,文件和账簿... 结论指出,每个经济单位必须在填写,存储和存档会计凭证(包括电子支持会计凭证)的方法方面遵守法律法规。
  • 修改植物大战僵尸存档和金钱 前提 1, 安装《植物大战僵尸》,(https://pan.baidu.com/s/1uygTSdQk48EHItCyHms7Ow) 2,16进制编辑器 HexEditor,免费版(https://www.hhdsoftware.com/free-hex-editor) 修改存档 1,安装...
  • 植物大战僵尸 修改存档和金钱

    千次阅读 2021-04-03 16:56:44
    前提: win 系统安装植物大战僵尸,这里有一个百度云网盘是从网上找的,我用... 修改存档 1.游戏先创建一个名字,然后试玩一下,去 C:\ProgramData\PopCap Games\PlantsVsZombies\userdata\ 会发现有一个 user3.dat 的
  • 文章目录前言一、说明二、任务1.内容2. 所需工具3. 查看用户数据文件4. 修改关卡5....前言 有的玩家在玩游戏时,可能并不想⼀关⼀关地慢慢玩,⽽...⾥,并且还能随意修改存档信息,那是不是就能达到「开挂」的⽬的呢? 答
  • 1.存档文件位置 2.创建用户 3.跳转关卡 4.修改金币 5.解锁迷你游戏 6.解锁益智模式和生存模式
  • 这里介绍一下RSD设计的遥感数据产品生产、分幅和存档与检索的机制。 从基本用户单位角度来看,遥感数据越来越多,数据体量的增加带来一系列的问题。与只有少量的数据的时候完全不同,数据管理的问题日益突出。这...
  • byteLength属性返回类型化数组占据的内存长度,单位为字节。byteOffset属性返回类型化数组从底层ArrayBuffer对象的哪个字节开始。这两个属性都是只读属性。 var b = new ArrayBuffer ( 8 ); var v1 = new...
  • 植物大战僵尸存档修改前言一、前置准备二、进行修改总结 前言 这次是通过对游戏的存档修改为例学习进制的相关知识 一、前置准备 下载一个进制编辑器(此处下载的是EmEditor编辑器) 找到存档位置 X:\ProgramData\...
  • [UE4]实现存档功能

    千次阅读 2017-05-15 11:19:48
    实现存档功能的逻辑是:建立一个类型为SaveGame的蓝图文件 把所有需要保存的参数都放到这个文件里  然后在其他蓝图中用命令把它储存到本地目录下   首先创建一个类型为SaveGame的蓝图文件 ...
  • Windows下的cmd命令存档

    2012-08-22 10:45:50
    先来一下通用的吧,就是不区分版本的 sysinfo 查看系统信息,包含系统信息/硬件信息/运行情况,等 wmic DiskDrive get Size /value 硬盘容量,没有显示单位,但你应该不至于搞错
  • 前端学习博客和文章存档

    千次阅读 2017-01-04 12:22:20
    前端 100 问 ...https://www.cnblogs.com/learnings/p/5912923.html https://blog.csdn.net/a125366161/article/details/49996997 纯CSS3使用vw和vh视口单位实现自适应 ...
  • show CON_NAME CREATE TABLESPACE fda_ts DATAFILE SIZE ...创建闪回存档 show CON_NAME CREATE FLASHBACK ARCHIVE DEFAULT fda_1year TABLESPACE fda_ts QUOTA 10G RETENTION 1 YEAR; GRANT FLASHBACK ARCHIV
  • 【博客存档】TensorFlow之深入理解AlexNet想飞的石头夯实基础,埋头苦干 happy coding38 人赞了该文章前言前面看了一些Tensorflow的文档和一些比较有意思的项目,发现这里面水很深的,需要多花时间好好从头了解下,...
  • 马克思进文庙——存档

    千次阅读 2008-12-29 10:09:00
    而这力量的形式起初是以国家为单位,进而至于国际。这样进行起去,大家于物质上精神上,均能充分地满足各 自的要求,人类的生存然后才能得到最高的幸福。所以我的理想是有一定的步骤,有坚确的实证的呢。 ——是...
  • Paperkey-OpenPGP密钥存档器 大卫·肖(David Shaw) 长期备份OpenPGP(GnuPG,PGP等)密钥的合理方法是将其打印在纸上。 纸张和墨水具有惊人的长保留质量-远比通常用于备份计算机数据的磁性或光学方法长。 纸? ...
  • J2EE代码存档--导出Excel

    千次阅读 2012-04-05 23:04:31
    row.createCell(6).setCellValue("所属单位"); } for (int i = 0; i (); i++) { row = sheet[i/65535].createRow(i%65535 + 1); ab = (WarnerBean) warnings.get(i); row.createCell(0).setCellValue(ab....
  • Lync Server 2010详解系列5:Lync 存档服务器的部署 导语: 前一篇中我们介绍了Lync Server监控服务器的部署。本篇我们将介绍Lync Server存档服务器的部署。大家如果在部署的过程中遇到什么问题可以和我一起讨论...
  • TFS(2)存档。转。

    2014-02-13 21:41:18
    #dataserver 与 nameserver心跳间隔时间, 单位(秒), default: 2 heart_interval = 2 check_interval = 2 #datafile失效时间, 单位(秒), default: 90 #expire_datafile_time = 90 #拷贝...
  • TFS(1)存档。转自

    2014-02-13 21:41:15
    #block 缺失备份时, 需要等待多长时间才进行复制, 单位(秒), default: 240 repl_max_time = 60 #block进行压缩的比例, block 删除的文件的比例达到这个值时进行压缩 compact_delete_ratio =  15 #block...
  • 所需材料: 1.身份证 2.单位介绍信(注明借出理由) 3.押金500元   程序: 1.本人持上述材料到人才中心借出户口卡并缴纳押金 2.户口卡使用完毕后本人持户口卡及押金条退还户口押金...
  • 数据库系统基础知识--存档

    千次阅读 2008-02-15 00:42:00
    2.5 数据库系统基础知识2.5.1 主要知识点掌握数据库模型、数据库系统结构和关系数据库结构的基础知识,熟练掌握SQL语言的使用 关系代数的运算。2.5.1.1 关系数据库的数据体系结构关系模型遵循数据库的3级...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 12,662
精华内容 5,064
关键字:

存档单位