ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ZR_FI_020

ZR_FI_020

原创 Linux操作系统 作者:williamzhou 时间:2019-06-12 16:03:08 0 删除 编辑

*===============================基本信息===============================*
* 标题:制造型公司产品成本表
* 创建日期:2005-09-15       
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_020
NO STANDARD PAGE HEADING
LINE-COUNT 65
LINE-SIZE  319
MESSAGE-ID ZFI1.

************************************************************************
* INCLUDE:包含文件
************************************************************************
INCLUDE OLE2INCL.

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES: MBEW,  "物料评估
        MARA,  "常规物料数据
        MARC,  "
        KONP,  "
        KEKO,  "产品成本核算 - 表头数据
        CKIS,  "项目单位成本核算/产品成本核算分项列举
        MAST,  "BOM链接物料
        STPO,  "BOM项目
        STKO,  "BOM表头
        RESB,  "预定/相关需求
        T001,  "公司代码
        MAKT,  "物料描述
        T023T, "物料组描述
        MARM,  "物料的计量单位
        CRHD.  "工作中心表头
************************************************************************
*INTERNAL TABLES
************************************************************************
*定义输出的内表IT_PRINT_001
*主表
DATA: BEGIN OF ITAB_MAIN OCCURS 0.
        DATA MATNR LIKE MBEW-MATNR.          "成品料号
DATA: END OF ITAB_MAIN.
*明细表
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG.
        DATA NO TYPE I.                      "序号
        DATA WERKS LIKE KEKO-WERKS.          "公司代码
        DATA KALNR LIKE KEKO-KALNR.          "成本估算号(产品成本核算)
        DATA KADKY LIKE KEKO-KADKY.          "成本核算日期
        DATA MATNR LIKE MBEW-MATNR.          "成品料号
        DATA MAKTX LIKE MAKT-MAKTX.          "物料名称
        DATA MATKL LIKE T023T-MATKL.         "物料组
        DATA WGBEZ LIKE T023T-WGBEZ.         "物料组的描述

        DATA CLASS LIKE CKIS-TYPPS.          "记录类别
        DATA ITEM_NAME_ALL LIKE MAKT-MAKTX.  "父项目名称
        DATA ITEM_NAME_SUB LIKE MAKT-MAKTX.  "子项目名称
        DATA ITEM_NAME_ALL2 LIKE MAKT-MAKTX. "父项目名称2
        DATA ITEM_NAME_SUB2 LIKE MAKT-MAKTX. "子项目名称2
        DATA ITEM_CODE LIKE MBEW-MATNR.      "物料号
        DATA ITEM_NAME LIKE MAKT-MAKTX.      "物料名称
        DATA QTY1 TYPE P DECIMALS 4.         "理论用量
        DATA PMEHT1 LIKE CKIS-PMEHT.         "理论用量的计量单位
        DATA QTY2 TYPE P DECIMALS 4.         "损耗用量
        DATA PMEHT2 LIKE CKIS-PMEHT.         "损耗用量的计量单位
        DATA CB1 TYPE P DECIMALS 4.          "理论成本
        DATA CB2 TYPE P DECIMALS 4.          "损耗成本
        DATA CB3 TYPE P DECIMALS 4.          "合计成本
        DATA RATE LIKE CKIS-WRTFW_POS.       "成本项目比率
        DATA RATE_C(20).                     "成本项目比率
        DATA CB4_LL TYPE P DECIMALS 4.       "行业理论成本
        DATA QTY3 TYPE P DECIMALS 4.         "行业理论用量
        DATA PMEHT3 LIKE CKIS-PMEHT.         "行业理论用量的计量单位
        DATA CB4 TYPE P DECIMALS 4.          "行业成本
        DATA RATE2 LIKE CKIS-WRTFW_POS.      "行业成本项目比率
        DATA RATE2_C(20).                    "行业成本项目比率

        DATA WERTN TYPE P DECIMALS 4.        "价格
        DATA PEINH TYPE P DECIMALS 4.        "单位价格
        DATA LSTAR LIKE CKIS-LSTAR.          "活动类型
        DATA INFNR LIKE CKIS-INFNR.          "信息记录
        DATA KSTAR LIKE CKIS-KSTAR.          "成本要素
        DATA KOSTL LIKE CKIS-KOSTL.          "成本中心
        DATA ARBPL LIKE CRHD-ARBPL.          "工作中心
        DATA ARBID LIKE CKIS-ARBID.          "对象 ID
        DATA TPR TYPE I.                     "判断是否是TPR材料标识.(0不是;1是)
        DATA SH TYPE P DECIMALS 4.           "毛胚行业损耗率
        DATA MPCB TYPE P DECIMALS 4.         "毛胚成本
        DATA PRICE_DM TYPE P DECIMALS 4.     "行业理论成本DM单价
        DATA QTY_OH TYPE P DECIMALS 4.       "OH理论用量

        DATA MATNR_FATHER LIKE MBEW-MATNR.   "上层物料号
        DATA CB_HSH TYPE P DECIMALS 4.       "料号103*的行业成本与CK13N中的一样(含损耗)
        DATA IS_U TYPE I.                    "判断料号是否为*-U*
DATA: END OF IT_PRINT_001.
DATA: ITAB_TEMP LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*汇总表
DATA: BEGIN OF IT_PRINT_002 OCCURS 0.
        INCLUDE STRUCTURE ZFI10.
        DATA NO TYPE I.                      "序号
        DATA KALNR LIKE KEKO-KALNR.          "成本估算号(产品成本核算)
        DATA MAKTX LIKE MAKT-MAKTX.          "物料名称
DATA: END OF IT_PRINT_002.

*定义内部使用的内表ITABS
DATA: BEGIN OF ITABS OCCURS 0.
        DATA FLAG.
        DATA WERKS LIKE KEKO-WERKS.          "公司代码
        DATA KALNR LIKE KEKO-KALNR.          "成本估算号(产品成本核算)
        DATA KADKY LIKE KEKO-KADKY.          "成本核算日期
        DATA MATNR LIKE MBEW-MATNR.          "成品料号

        DATA NO TYPE I.                      "序号
        DATA ISEND TYPE I.                   "是否是最未层
        DATA TIERNO TYPE I.                  "BOM层次
        DATA TYPPS LIKE CKIS-TYPPS.          "记录类别
        DATA RECO_CODE LIKE MBEW-MATNR.      "记录代码(用于存放物料号、信息记录)
        DATA RECO_NAME LIKE MAKT-MAKTX.      "记录名称
        DATA TOTAL TYPE P DECIMALS 4.        "总计值
        DATA FWAER_KPF LIKE CKIS-FWAER_KPF.  "货币
        DATA MENGE TYPE P DECIMALS 4.        "数量
        DATA PMEHT LIKE CKIS-PMEHT.          "计量单位
        DATA MEEHT LIKE CKIS-PMEHT.          "计量单位

        DATA WERTN TYPE P DECIMALS 4.        "价格
        DATA PEINH TYPE P DECIMALS 4.        "单位价格
        DATA LSTAR LIKE CKIS-LSTAR.          "活动类型
        DATA INFNR LIKE CKIS-INFNR.          "信息记录
        DATA KSTAR LIKE CKIS-KSTAR.          "成本要素
        DATA KOSTL LIKE CKIS-KOSTL.          "成本中心
        DATA ARBID LIKE CKIS-ARBID.          "对象ID
        DATA ARBPL LIKE CRHD-ARBPL.          "工作中心
        DATA MATNR_FATHER LIKE MBEW-MATNR.   "上层物料号
        DATA SH TYPE P DECIMALS 4.           "物料的工序损耗金额
        DATA SH2 TYPE P DECIMALS 4.
        DATA SHL TYPE P DECIMALS 4.          "每个物料的损耗率
        DATA SHL2 TYPE P DECIMALS 4.         "每个物料的其上损耗率之积和
        DATA TPR TYPE I.                     "判断是否是TPR材料标识.(0不是;1是)
        DATA ISUSED TYPE I.                  "判断记录是否已被自制加工费使用过.(0不是;1是)
        DATA ISCK13N TYPE I.                 "判断是否要使用CK13N的值
        DATA AUSMG LIKE CKIS-AUSMG.          "废品数量
        DATA AUSMGKO LIKE CKIS-AUSMGKO.      "组件报废

        DATA CB_LL TYPE P DECIMALS 4.        "理论成本
        DATA SL_LL TYPE P DECIMALS 4.        "理论用量
        DATA CB_SH TYPE P DECIMALS 4.        "损耗成本
        DATA SL_SH TYPE P DECIMALS 4.        "损耗用量
DATA: END OF ITABS.

DATA: BEGIN OF ITAB_01 OCCURS 0.
        DATA FLAG.
        DATA KALNR LIKE KEKO-KALNR.          "成本估算号 - 产品成本核算
        DATA LOSGR LIKE KEKO-LOSGR.          "项目类别
        DATA MEINS LIKE KEKO-MEINS.          "基本计量单位
        DATA FWAER_KPF LIKE KEKO-FWAER_KPF.  "币别
DATA: END OF ITAB_01.

DATA: BEGIN OF ITAB_SHL OCCURS 0.
        DATA FLAG.
        DATA AUSCH LIKE STPO-AUSCH.          "组件报废
        DATA AVOAU LIKE STPO-AVOAU.          "工序废品
        DATA IDNRK LIKE STPO-IDNRK.          "组件
        DATA MENGE LIKE STPO-MENGE.          "数量
DATA: END OF ITAB_SHL.

*往数据库增加运行日志
  DATA: BEGIN OF IT_ZREPORTLOG OCCURS  0.
    INCLUDE TYPE ZREPORTLOG.
  DATA: END OF IT_ZREPORTLOG.
************************************************************************
* CONSTANTS : 定义常量
************************************************************************

************************************************************************
* TYPE : 定义数据类型
************************************************************************
TYPE-POOLS: SLIS.

************************************************************************
* DATA : 定义变量
************************************************************************
*单据表格上相关坐标值定义
DATA: A1 TYPE I VALUE 0,
      A2 TYPE I VALUE 0,
      A3 TYPE I VALUE 0,
      A4 TYPE I VALUE 0,
      A5 TYPE I VALUE 0,
      A6 TYPE I VALUE 0,
      A7 TYPE I VALUE 0,
      A8 TYPE I VALUE 0,
      A9 TYPE I VALUE 0,
      A10 TYPE I VALUE 0,
      A11 TYPE I VALUE 0,
      A12 TYPE I VALUE 0,
      A13 TYPE I VALUE 0,
      A14 TYPE I VALUE 0,
      A15 TYPE I VALUE 0,
      A16 TYPE I VALUE 0,
      A17 TYPE I VALUE 0,
      A18 TYPE I VALUE 0,
      A19 TYPE I VALUE 0,
      A20 TYPE I VALUE 0,
      A21 TYPE I VALUE 0.

DATA: B1 TYPE I VALUE 0,
      B2 TYPE I VALUE 0,
      B3 TYPE I VALUE 0,
      B4 TYPE I VALUE 0,
      B5 TYPE I VALUE 0,
      B6 TYPE I VALUE 0,
      B7 TYPE I VALUE 0,
      B8 TYPE I VALUE 0,
      B9 TYPE I VALUE 0,
      B10 TYPE I VALUE 0,
      B11 TYPE I VALUE 0,
      B12 TYPE I VALUE 0,
      B13 TYPE I VALUE 0,
      B14 TYPE I VALUE 0,
      B15 TYPE I VALUE 0,
      B16 TYPE I VALUE 0,
      B17 TYPE I VALUE 0,
      B18 TYPE I VALUE 0,
      B19 TYPE I VALUE 0,
      B20 TYPE I VALUE 0.

DATA: NAME_LAST LIKE USER_ADDR-NAME_LAST,
      NAME_FIRST LIKE USER_ADDR-NAME_FIRST,
      NAME(16).

DATA: L_TEMP LIKE CKIS-WERTN VALUE 0.
DATA: G_KALNR LIKE KEKO-KALNR,
      G_UKALN LIKE CKIS-UKALN,
      G_KALNR1 LIKE KEKO-KALNR,
      G_UKALN1 LIKE CKIS-UKALN,
      G_MENGE LIKE CKIS-MENGE,        "物料批量
      G_PEINH TYPE P DECIMALS 6,      "价格单位
      G_TIERNO TYPE I.                "BOM层次
DATA: V_MATNR2 LIKE STPO-IDNRK,
      V_MATKL2 LIKE MARA-MATKL.

DATA: G_DAY(2),
      G_LEN TYPE I,
      G_MOD TYPE I,
      G_DATE1 LIKE LIKP-ERDAT,
      G_DATE2 LIKE LIKP-ERDAT,
      G_KUNNR LIKE KNA1-KUNNR,          "客户代码
      G_NAME1(105),                     "客户名称
      G_KBETR LIKE KONP-KBETR,          "客户报价
      G_TOTAL TYPE P DECIMALS 4,
      G_TOTAL2 TYPE P DECIMALS 4,
      G_FLAG_GX TYPE I.                 "工序重复标识
DATA: G_DATE_PRICE LIKE LIKP-ERDAT.

*用于ALV控件双击事件
DATA: G_SELECTED_FIELD_VALUE(80).

*ALV控件构造时需要的参数
DATA: G_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      G_ALV_FIELDCAT_LINE LIKE LINE OF G_ALV_FIELDCAT,
      G_ALV_EVENT         TYPE SLIS_T_EVENT.

*ALV控件输出的表头
DATA: G_ALV_LISTHEADER TYPE SLIS_T_LISTHEADER.

*指定ALV控件触发TOP_OF_PAGE事件时调用的子程序
DATA: G_ALV_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_TOP_OF_PAGE'.
DATA: G_ALV_FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_END_OF_LIST'.

*指定ALV控件的显示特征
DATA : G_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
************************************************************************
* DEFINE: 定义宏
************************************************************************
*普通报表格式的输出宏
DEFINE GRID1.               "画表格
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1.
  WRITE: AT  A2   SY-VLINE.
  WRITE: AT  B2   &2.
  WRITE: AT  A3   SY-VLINE.
  WRITE: AT  B3   &3.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &4.
  WRITE: AT  A5   SY-VLINE.
  WRITE: AT  B5   &5 RIGHT-JUSTIFIED.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6 RIGHT-JUSTIFIED.
  WRITE: AT  A7   SY-VLINE.
  WRITE: AT  B7   &7.
  WRITE: AT  A8   SY-VLINE.
  WRITE: AT  B8   &8.
  WRITE: AT  A9   SY-VLINE.
  WRITE: AT  B9   &9.
END-OF-DEFINITION.

DEFINE GRID2.               "画表格
  WRITE: AT  A10   SY-VLINE.
  WRITE: AT  B10   &1.
  WRITE: AT  A11   SY-VLINE.
  WRITE: AT  B11   &2.
  WRITE: AT  A12   SY-VLINE.
  WRITE: AT  B12   &3.
  WRITE: AT  A13   SY-VLINE.
  WRITE: AT  B13   &4.
  WRITE: AT  A14   SY-VLINE.
  WRITE: AT  B14   &5.
  WRITE: AT  A15   SY-VLINE.
  WRITE: AT  B15   &6.
  WRITE: AT  A16   SY-VLINE.
  WRITE: AT  B16   &7.
  WRITE: AT  A17   SY-VLINE.
  WRITE: AT  B17   &8.
  WRITE: AT  A18   SY-VLINE.
  WRITE: AT  B18   &9.
END-OF-DEFINITION.

DEFINE GRID3.               "画表格
  WRITE: AT  A19   SY-VLINE.
  WRITE: AT  B19   &1.
  WRITE: AT  A20   SY-VLINE.
  WRITE: AT  B20   &2.
  WRITE: AT  A21   SY-VLINE.
END-OF-DEFINITION.
************************************************************************
*  SELECTION SCREEN : 定义报表筛选条件
************************************************************************
*确定过滤参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_001 WITH FRAME. TITLE BLK_001.
    PARAMETERS : P_BUKRS LIKE GLT0-BUKRS OBLIGATORY MEMORY ID 020_2.   "公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY DEFAULT SY-DATUM+0(4).   "报表年度
    PARAMETERS : P_PERID(2) TYPE C OBLIGATORY DEFAULT SY-DATUM+4(2).   "报表期间
    SELECT-OPTIONS : P_MATNR FOR MBEW-MATNR OBLIGATORY MEMORY ID 020_1."物料号
SELECTION-SCREEN END OF BLOCK BLK_001.

*特殊汇总类型参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_003 WITH FRAME. TITLE BLK_003 .
    PARAMETERS: P_TYPE1 AS CHECKBOX DEFAULT 'X'.           "显示完全的记录名称
SELECTION-SCREEN END OF BLOCK BLK_003.

*选择报表类型
SELECTION-SCREEN BEGIN OF BLOCK BLK_002 WITH FRAME. TITLE BLK_002 .
PARAMETERS: P_REPORT RADIOBUTTON GROUP R1 DEFAULT 'X',
            P_ALV RADIOBUTTON GROUP R1,
            P_SHOW RADIOBUTTON GROUP R1.
SELECTION-SCREEN END OF BLOCK BLK_002.

 

*===============================事    件===============================*
************************************************************************
* INITIALIZATION.启动程序开始执行
************************************************************************
INITIALIZATION.
  BLK_001 = '检索参数'.
  BLK_002 = '报表类型'.
  BLK_003 = '特殊参数处理'.

  PERFORM. SUB_INI.
************************************************************************
* AT SELECTION SCREEN:
************************************************************************
AT SELECTION-SCREEN.
  PERFORM. F_CHECK_INPUT.          "检查用户输入
************************************************************************
* START OF SELECTION:
************************************************************************
START-OF-SELECTION.
*往数据库增加运行日志
  IT_ZREPORTLOG-MANDT = SY-MANDT.
  IT_ZREPORTLOG-TCODE = SY-TCODE.
  IT_ZREPORTLOG-DATUM = SY-DATUM.
  IT_ZREPORTLOG-UZEIT = SY-UZEIT.
  IT_ZREPORTLOG-UNAME = SY-UNAME.
  IT_ZREPORTLOG-TITLE = SY-TITLE.
  APPEND IT_ZREPORTLOG.
  INSERT INTO ZREPORTLOG VALUES IT_ZREPORTLOG .

  PERFORM. F_MAIN .

  IF P_REPORT = 'X'.
    PERFORM. F_PRINT_REPORT.
  ELSEIF P_ALV = 'X' OR P_SHOW = 'X'.
    PERFORM. F_PRINT_ALV.
  ENDIF.
************************************************************************
* END OF SELECTION
************************************************************************
END-OF-SELECTION.

************************************************************************
* TOP OF PAGE
************************************************************************
TOP-OF-PAGE.
  PERFORM. SUB_HEAD.
************************************************************************
* END OF PAGE
************************************************************************
END-OF-PAGE.
  PERFORM. SUB_BOTTOM.


*===============================子 例 程===============================*
*&---------------------------------------------------------------------*
*过滤条件有效性检查
*&---------------------------------------------------------------------*
FORM. F_CHECK_INPUT.
DATA: L_TEMP(20),
      L_COUNT TYPE I.

  "日期处理
  IF P_PERID+1(1) = ''.
    CONCATENATE '0' P_PERID INTO P_PERID.
  ENDIF.
  IF ( P_PERID < '01' ) OR ( P_PERID > '16' ).
    MESSAGE E000.    "该会计期间不存在!
  ENDIF.

  "物料判断
  SELECT MATNR
    FROM MARA
    INTO CORRESPONDING FIELDS OF TABLE ITAB_MAIN
    WHERE ( MTART = 'FERT' OR MTART = 'HALB' )
      AND MATNR IN P_MATNR.
  IF SY-SUBRC <> 0.
    MESSAGE E071. "不存在该物料或该物料不是产成品!
  ENDIF.

  "明细或汇总判断
  DESCRIBE TABLE ITAB_MAIN LINES L_COUNT.
  IF ( P_REPORT = 'X' ) AND ( L_COUNT > 1 ).
    MESSAGE E076. "显示REPORT报表时,只能输入单一物料号!
  ENDIF.

  SELECT MATNR
    INTO MARC-MATNR
    FROM MARC
    WHERE MATNR IN P_MATNR
      AND WERKS = P_BUKRS.
  ENDSELECT.
  IF SY-SUBRC <> 0.
    MESSAGE E072. "该物料不存在该工厂中!
  ENDIF.

  "公司代码判断
  IF P_BUKRS <> '2000' AND P_BUKRS <> '4000'.
    MESSAGE E075. "请选择2000或4000的公司代码!!
  ENDIF.
ENDFORM.                    " F_CHECK_INPUT
*&---------------------------------------------------------------------*
*MAIN
*&---------------------------------------------------------------------*
FORM. F_MAIN .
DATA: L_COUNT TYPE I,
     L_P1 LIKE KEKO-CPUDT,
     L_P2(30),
     L_DATE1 LIKE LIKP-ERDAT.

  SELECT MATNR
    FROM MARA
    INTO CORRESPONDING FIELDS OF TABLE ITAB_MAIN
    WHERE ( MTART = 'FERT' OR MTART = 'HALB' )
      AND MATNR IN P_MATNR.

  "明细或汇总判断
  DESCRIBE TABLE ITAB_MAIN LINES L_COUNT.
  IF ( P_REPORT = 'X' ) AND ( L_COUNT = 1 ).
    LOOP AT ITAB_MAIN.
      PERFORM. CAL_DAY.                "每月天数判断
      P_MATNR = ITAB_MAIN-MATNR.
      PERFORM. F_READ_DATA.
    ENDLOOP.
  ELSEIF P_ALV = 'X'.
    LOOP AT ITAB_MAIN.
      PERFORM. CAL_DAY.                "每月天数判断
      CLEAR IT_PRINT_001.
      REFRESH IT_PRINT_001.
      CLEAR ITABS.
      REFRESH ITABS.
      P_MATNR = ITAB_MAIN-MATNR.
      PERFORM. F_READ_DATA .

      IT_PRINT_002-FLAG = '2'.
      IT_PRINT_002-BUKRS = P_BUKRS.
      IT_PRINT_002-RYEAR = P_RYEAR.
      IT_PRINT_002-RPMAX = P_PERID.
      IT_PRINT_002-MATNR = ITAB_MAIN-MATNR.
      PERFORM. F_GET_PRODNAME USING IT_PRINT_002-MATNR
                             CHANGING IT_PRINT_002-MAKTX.
      PERFORM. F_HEAD_SUB USING IT_PRINT_002-MATNR
                             CHANGING IT_PRINT_002-KADKY L_P2.
      CONCATENATE P_RYEAR P_PERID '01' INTO L_DATE1.
      IT_PRINT_002-BUDAT = L_DATE1.

      LOOP AT IT_PRINT_001.
        IF IT_PRINT_001-ITEM_NAME_ALL = '合  计:'.
          IT_PRINT_002-CB_BZ = IT_PRINT_001-CB3.
          IT_PRINT_002-CB_HY = IT_PRINT_001-CB4.
        ENDIF.
      ENDLOOP.
      APPEND IT_PRINT_002.
    ENDLOOP.

    "将汇总数据保存到后台
    PERFORM. F_SAVE.
  ELSEIF P_SHOW = 'X'.
    PERFORM. F_SHOW.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*将汇总数据保存到后台
*&---------------------------------------------------------------------*
FORM. F_SAVE.
DATA: ITAB_TEMP LIKE IT_PRINT_002 OCCURS 10 WITH HEADER LINE.

  LOOP AT IT_PRINT_002.
    SELECT *
      FROM ZFI10
      INTO CORRESPONDING FIELDS OF TABLE ITAB_TEMP
      WHERE BUKRS = P_BUKRS
        AND RYEAR = P_RYEAR
        AND RPMAX = P_PERID
        AND MATNR = IT_PRINT_002-MATNR
        AND FLAG = '2'.

    IF SY-SUBRC = 0.
      "更新相同的记录
      UPDATE ZFI10
           SET CB_HY = IT_PRINT_002-CB_HY
               CB_BZ = IT_PRINT_002-CB_BZ
               KADKY = IT_PRINT_002-KADKY
               BUDAT = IT_PRINT_002-BUDAT
               AEDAT = SY-DATUM
               AENAM = SY-UNAME
         WHERE BUKRS = P_BUKRS
           AND RYEAR = P_RYEAR
           AND RPMAX = P_PERID
           AND MATNR = IT_PRINT_002-MATNR
           AND FLAG = '2'.
    ELSE.
      "新增记录
      IT_PRINT_002-ERDAT = SY-DATUM.
      IT_PRINT_002-AEDAT = SY-DATUM.
      IT_PRINT_002-ERNAM = SY-UNAME.
      IT_PRINT_002-AENAM = SY-UNAME.

      INSERT INTO ZFI10
        VALUES IT_PRINT_002 .
    ENDIF.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*显示已汇总的后台数据
*&---------------------------------------------------------------------*
FORM. F_SHOW.

  SELECT *
      FROM ZFI10
      INTO CORRESPONDING FIELDS OF TABLE IT_PRINT_002
      WHERE BUKRS = P_BUKRS
        AND RYEAR = P_RYEAR
        AND RPMAX = P_PERID
        AND MATNR IN P_MATNR
        AND FLAG = '2'.

  LOOP AT IT_PRINT_002.
    PERFORM. F_GET_PRODNAME USING IT_PRINT_002-MATNR
                        CHANGING IT_PRINT_002-MAKTX.
    MODIFY IT_PRINT_002.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
DATA: L_CB1 TYPE P DECIMALS 4,
      L_CB2 TYPE P DECIMALS 4,
      L_CB4_LL TYPE P DECIMALS 4,
      L_NAME1 LIKE MAKT-MAKTX,
      L_NAME2 LIKE MAKT-MAKTX,
      L_TEMP(10).

  "日期重定位
  PERFORM. F_DO_DATE.

  "取该产品的客户号及报价
  PERFORM. F_GET_CUSTIFNO.

  "获取成本估算明细表
  PERFORM. F_GET_DETAIL.

  "判断及区分TPR材料
  IF P_BUKRS = '2000'.
    PERFORM. F_GET_TPR.
  ENDIF.

  "判断是否要使用CK13N的值
  PERFORM. F_GET_ISCK13N.

  "处理材料费
  PERFORM. F_GET_CLF.

  "计算自制加工费的损耗成本
  PERFORM. F_GET_ZZF_SH.
  "处理自制加工费
  PERFORM. F_GET_ZZF.

  IF P_BUKRS = '2000'.
    "处理电镀加工费(即托外费)
    PERFORM. F_GET_ZZF_DD2000.

    "处理行业理论用量
    PERFORM. F_DO_HYYL_LL2000.
    "处理行业成本(物料)
    PERFORM. F_DO_HYCB_WL2000.
    "处理行业成本(工序)
    PERFORM. F_DO_HYCB_GX2000.
    "处理毛胚损耗率之积和及毛胚损耗成本之和
    PERFORM. F_DO_MPSHL_2000.
    "处理行业理论成本
    PERFORM. F_DO_HYCB_LL2000.
  ELSEIF P_BUKRS = '4000'.
    "处理托外费
    PERFORM. F_GET_TGF_4000.

    "处理行业成本(物料)
    PERFORM. F_DO_HYCB_WL4000.
  ENDIF.

  "处理底行合计
  L_CB1 = 0.
  L_CB2 = 0.
  G_TOTAL = 0.
  G_TOTAL2 = 0.
  LOOP AT IT_PRINT_001.
    L_CB1 = L_CB1 + IT_PRINT_001-CB1.
    L_CB2 = L_CB2 + IT_PRINT_001-CB2.
    G_TOTAL = G_TOTAL + IT_PRINT_001-CB1 + IT_PRINT_001-CB2.
    G_TOTAL2 = G_TOTAL2 + IT_PRINT_001-CB4.
    L_CB4_LL = L_CB4_LL + IT_PRINT_001-CB4_LL.
  ENDLOOP.
  CLEAR IT_PRINT_001.
  IT_PRINT_001-ITEM_NAME_ALL = '合  计:'.
  IT_PRINT_001-ITEM_NAME = ''.
  IT_PRINT_001-QTY1 = 0.
  IT_PRINT_001-QTY2 = 0.
  IT_PRINT_001-PMEHT1 = ''.
  IT_PRINT_001-PMEHT2 = ''.
  IT_PRINT_001-CB1 = L_CB1.
  IT_PRINT_001-CB2 = L_CB2.
  IT_PRINT_001-CB3 = G_TOTAL.
  IT_PRINT_001-CB4 = G_TOTAL2.
  IT_PRINT_001-CB4_LL = L_CB4_LL.
  APPEND IT_PRINT_001.

  "处理成本项目比
  LOOP AT IT_PRINT_001.
    IF G_TOTAL <> 0.
      IT_PRINT_001-RATE = IT_PRINT_001-CB3 * 100 / G_TOTAL.
    ENDIF.
    L_TEMP = IT_PRINT_001-RATE.
    CONCATENATE L_TEMP '%' INTO L_TEMP.
    IT_PRINT_001-RATE_C = L_TEMP.
    MODIFY IT_PRINT_001.
  ENDLOOP.
  LOOP AT IT_PRINT_001.
    IF G_TOTAL2 <> 0.
      IT_PRINT_001-RATE2 = IT_PRINT_001-CB4 * 100 / G_TOTAL2.
    ENDIF.
    L_TEMP = IT_PRINT_001-RATE2.
    IF L_TEMP >= 0.
      CONCATENATE L_TEMP '%' INTO L_TEMP.
    ELSE.
      L_TEMP = 0 - L_TEMP.
      CONCATENATE '-' L_TEMP INTO L_TEMP.
      CONDENSE L_TEMP.
      CONCATENATE L_TEMP '%' INTO L_TEMP.
    ENDIF.
    IT_PRINT_001-RATE2_C = L_TEMP.
    MODIFY IT_PRINT_001.
  ENDLOOP.

  "格式处理1
  IF P_TYPE1 <> 'X'.
    LOOP AT IT_PRINT_001.
      IF IT_PRINT_001-ITEM_NAME_ALL = L_NAME1.
        IT_PRINT_001-ITEM_NAME_ALL = ''.
        MODIFY IT_PRINT_001.
      ELSE.
        L_NAME1 = IT_PRINT_001-ITEM_NAME_ALL.
      ENDIF.

      IF IT_PRINT_001-ITEM_NAME_SUB = L_NAME2.
        IT_PRINT_001-ITEM_NAME_SUB = ''.
        MODIFY IT_PRINT_001.
      ELSE.
        L_NAME2 = IT_PRINT_001-ITEM_NAME_SUB.
      ENDIF.
    ENDLOOP.
  ENDIF.

  "成本大、小项目copy处理
  LOOP AT IT_PRINT_001.
    IT_PRINT_001-ITEM_NAME_ALL2 = IT_PRINT_001-ITEM_NAME_ALL.
    IT_PRINT_001-ITEM_NAME_SUB2 = IT_PRINT_001-ITEM_NAME_SUB.
    MODIFY IT_PRINT_001.
  ENDLOOP.
ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*日期重定位处理
*&---------------------------------------------------------------------*
FORM. F_DO_DATE.
  SELECT KALNR
    FROM KEKO
    INTO KEKO-KALNR
    WHERE MATNR = P_MATNR
        AND WERKS = P_BUKRS
        AND KADKY = G_DATE1              "成本核算日期(每月只有一条记录)
        AND KALKA = '01'                 "成本核算类型=PPC1
        AND TVERS = '01'                 "成本核算版本
        AND LOEKZ = ''                   "产品成本核算的删除标志
        AND BZOBJ = '0'                  "参考对象
        AND BWVAR = '001'                "成本核算中的估算变式
        AND KKZMA = ''.                  "在附加或自动成本估算中手工输入的成本
  ENDSELECT.

  IF SY-SUBRC <> 0 AND G_DATE1+0(4) >= '2005'.
    G_DATE1 = G_DATE1 - 1.
    CONCATENATE G_DATE1+0(4) G_DATE1+4(2) '01' INTO G_DATE1.
    PERFORM. F_DO_DATE.
  ENDIF.

  "取各物料的成本估算时取价格的日期
  G_DATE_PRICE = G_DATE1 - 1.
ENDFORM.
*&---------------------------------------------------------------------*
*区分TPR材料(该区别方法不全面,需改善)
*&---------------------------------------------------------------------*
FORM. F_GET_TPR.
DATA: L_SL TYPE I,
      L_MATNR LIKE MBEW-MATNR,
      L_FLAG TYPE I.
DATA: ITABS_TEMP LIKE ITABS OCCURS 10 WITH HEADER LINE.

*--
  CLEAR ITABS_TEMP.
  REFRESH ITABS_TEMP.
  LOOP AT ITABS.
    ITABS_TEMP-NO = ITABS-NO.
    ITABS_TEMP-TIERNO = ITABS-TIERNO.
    ITABS_TEMP-TYPPS = ITABS-TYPPS.
    ITABS_TEMP-RECO_CODE = ITABS-RECO_CODE.
    ITABS_TEMP-LSTAR = ITABS-LSTAR.
    ITABS_TEMP-MATNR_FATHER = ITABS-MATNR_FATHER.
    ITABS_TEMP-SH = ITABS-SH.
    ITABS_TEMP-ARBPL = ITABS-ARBPL.
    APPEND ITABS_TEMP.
  ENDLOOP.

  LOOP AT ITABS.
    L_SL = 0.
    IF ITABS-TYPPS = 'M'.
      L_MATNR = ITABS-RECO_CODE.
      "----
      LOOP AT ITABS_TEMP.
        IF ( ITABS_TEMP-MATNR_FATHER = L_MATNR ) AND ( ( ITABS_TEMP-ARBPL+0(2) = 'PC' ) OR
         ( ITABS_TEMP-ARBPL+0(2) = 'PZ' ) ).
          L_SL = 1.
        ENDIF.
      ENDLOOP.

      LOOP AT ITABS_TEMP.
        IF ITABS_TEMP-MATNR_FATHER = L_MATNR.
          ITABS_TEMP-TPR = L_SL.
          MODIFY ITABS_TEMP.
        ENDIF.
      ENDLOOP.
      "----
    ENDIF.

    ITABS-TPR = ITABS-TPR + L_SL.
    MODIFY ITABS.
  ENDLOOP.

  LOOP AT ITABS_TEMP.
    LOOP AT ITABS.
      IF ITABS-NO = ITABS_TEMP-NO.
        ITABS-TPR = ITABS-TPR + ITABS_TEMP-TPR.
      ENDIF.
      MODIFY ITABS.
    ENDLOOP.
  ENDLOOP.

*--再次汇总处理
  L_FLAG = 0.
  LOOP AT ITABS.
    IF ( ITABS-TIERNO = 1 ) AND ( ITABS-TPR = 2 ).
      L_FLAG = 1.
      EXIT.
    ENDIF.
  ENDLOOP.
  LOOP AT ITABS.
    IF ( ITABS-TIERNO = 1 ) AND ( L_FLAG = 1 ).
      ITABS-TPR = 2.
      MODIFY ITABS.
    ENDIF.
  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*判断是否要使用CK13N的值
*&---------------------------------------------------------------------*
FORM. F_GET_ISCK13N.
DATA: L_FLAG TYPE I,
      L_STLNR LIKE MAST-STLNR.
DATA: BEGIN OF ITAB_STPO OCCURS  0.
        INCLUDE TYPE STPO.
DATA: END OF ITAB_STPO.

  "取物料单号
  L_FLAG = 0.
  LOOP AT ITABS.
    IF ITABS-TYPPS = 'M'.
      SELECT STLNR
        FROM MAST
        INTO L_STLNR
        WHERE MATNR = ITABS-RECO_CODE  "物料号
          AND WERKS = P_BUKRS          "工厂
          AND STLAN = '1'              "BOM用途
          AND STLNR <> ''              "物料单
          AND STLAL = '01'.            "可选的BOM
      ENDSELECT.

      "取[部件废品]和[工序废品]
      SELECT IDNRK              "组件
        FROM STPO
        INTO CORRESPONDING FIELDS OF TABLE ITAB_STPO
        WHERE STLTY = 'M'       "BOM 类别
          AND STLNR = L_STLNR   "物料单
          AND STLKN <> 0        "项目节点
          AND STPOZ <> 0        "计数器
          AND LKENZ = ''.       "删除ID

      LOOP AT ITAB_STPO.
        SELECT SOBSL
          FROM MARC
          INTO MARC-SOBSL
          WHERE WERKS = P_BUKRS
            AND MATNR = ITAB_STPO-IDNRK.

          IF MARC-SOBSL <> ''.
            L_FLAG = 1.
            EXIT.
          ENDIF.
        ENDSELECT.
      ENDLOOP.
    ENDIF.
  ENDLOOP.

  IF L_FLAG = 1.
    LOOP AT ITABS.
      ITABS-ISCK13N = 1.
      MODIFY ITABS.
    ENDLOOP.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*处理材料费
*&---------------------------------------------------------------------*
FORM. F_GET_CLF.
DATA: L_MATNRNAME(26),
      L_AUSCH LIKE STPO-AUSCH,      "部件废品百分数
      L_AVOAU LIKE STPO-AVOAU,      "工序废品
      L_MENGE LIKE STPO-MENGE,      "数量
      L_PMEHT1 LIKE CKIS-PMEHT,     "
      L_QTY1 TYPE P DECIMALS 4,
      L_CB1 TYPE P DECIMALS 4.
DATA: L_PRICE LIKE ZFI09-CB.

*-处理原材料
  LOOP AT ITABS.
    IF ( ITABS-TYPPS = 'M' ).
      PERFORM. F_GET_SHL USING ITABS-MATNR_FATHER ITABS-RECO_CODE
                        CHANGING L_AUSCH L_AVOAU L_MENGE.
      ITABS-SL_LL = L_MENGE.
      MODIFY ITABS.
    ENDIF.

    L_MENGE = 0. L_AUSCH = 0. L_AVOAU = 0.
    IF ( ITABS-TYPPS = 'M' ) AND ( ITABS-ISEND = 1 )
     AND ( ITABS-RECO_CODE+0(2) = '10' ) AND ( ITABS-RECO_CODE+0(4) <> '1012' ).
      IT_PRINT_001-ITEM_NAME_ALL = '材料费'.
      IT_PRINT_001-ITEM_NAME_SUB = '原材料'.
      IT_PRINT_001-MATNR_FATHER = ITABS-MATNR_FATHER.
      IT_PRINT_001-ITEM_CODE = ITABS-RECO_CODE.
      PERFORM. F_GET_PRODNAME USING ITABS-RECO_CODE CHANGING L_MATNRNAME.
      IT_PRINT_001-ITEM_NAME = L_MATNRNAME.

      PERFORM. F_GET_SHL USING ITABS-MATNR_FATHER ITABS-RECO_CODE
                        CHANGING L_AUSCH L_AVOAU L_MENGE.
      IF ITABS-ISCK13N = 1.
*        IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( L_AUSCH + L_AVOAU ) / 100 ).
*        IT_PRINT_001-QTY2 = IT_PRINT_001-QTY1 * ( L_AUSCH / 100 ).
        IF L_MENGE = 0.
          ITABS-AUSMG = 2.
          ITABS-AUSMGKO = 0.
          IT_PRINT_001-QTY1 = ITABS-MENGE.
          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
        ELSE.
*          ITABS-AUSMG = ITABS-AUSMG / L_MENGE.
*          ITABS-AUSMGKO = ITABS-AUSMGKO / L_MENGE.
*          IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( ITABS-AUSMG + ITABS-AUSMGKO ) ).
*          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
           IT_PRINT_001-QTY1 = L_MENGE.
           IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
        ENDIF.
      ELSE.
        IT_PRINT_001-QTY1 = L_MENGE.
        IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
      ENDIF.
      IT_PRINT_001-PMEHT1 = ITABS-PMEHT.
      IT_PRINT_001-PMEHT2 = '%'.        "ITABS-PMEHT.

      L_PRICE = 0.
      CALL FUNCTION 'Z_GET_PRICE_CB'
        EXPORTING
           PA_PRODNO = ITABS-RECO_CODE
           PA_BUKRS = P_BUKRS
           PA_DATE = G_DATE_PRICE
        IMPORTING
           PA_PRICE3 = L_PRICE.
      IT_PRINT_001-CB1 = IT_PRINT_001-QTY1 * L_PRICE.
      IT_PRINT_001-CB2 = IT_PRINT_001-CB1 * ( ( L_AUSCH + L_AVOAU ) / 100 ).
      IT_PRINT_001-CB3 = IT_PRINT_001-CB1 + IT_PRINT_001-CB2.
      IT_PRINT_001-TPR = ITABS-TPR.
      "IT_PRINT_001-CB1 = ITABS-TOTAL / ( 1 + ( L_AUSCH + L_AVOAU ) / 100 ).
      "IT_PRINT_001-CB2 = IT_PRINT_001-CB1 * ( L_AUSCH / 100 ).
      "IT_PRINT_001-CB2 = IT_PRINT_001-CB1 * ( ( L_AUSCH + L_AVOAU ) / 100 ).

      APPEND IT_PRINT_001.
    ENDIF.
    CLEAR IT_PRINT_001.
  ENDLOOP.

*-处理辅料
  LOOP AT ITABS.
    IF ( ITABS-TYPPS = 'M' ) AND ( ITABS-ISEND = 1 )
     AND ( ( ITABS-RECO_CODE+0(2) = '91' ) OR ( ITABS-RECO_CODE+0(4) = '1012' ) ).
      IT_PRINT_001-ITEM_NAME_ALL = '材料费'.
      IT_PRINT_001-ITEM_NAME_SUB = '辅料'.
      IT_PRINT_001-MATNR_FATHER = ITABS-MATNR_FATHER.
      IT_PRINT_001-ITEM_CODE = ITABS-RECO_CODE.
      PERFORM. F_GET_PRODNAME USING ITABS-RECO_CODE CHANGING L_MATNRNAME.
      IT_PRINT_001-ITEM_NAME = L_MATNRNAME.

      PERFORM. F_GET_SHL USING ITABS-MATNR_FATHER ITABS-RECO_CODE
                        CHANGING L_AUSCH L_AVOAU L_MENGE.
      IF ITABS-ISCK13N = 1.
*        IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( L_AUSCH + L_AVOAU ) / 100 ).
*        IT_PRINT_001-QTY2 = IT_PRINT_001-QTY1 * ( L_AUSCH / 100 ).
        IF L_MENGE = 0.
          ITABS-AUSMG = 2.
          ITABS-AUSMGKO = 0.
          IT_PRINT_001-QTY1 = ITABS-MENGE.
          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
        ELSE.
*          ITABS-AUSMG = ITABS-AUSMG / L_MENGE.
*          ITABS-AUSMGKO = ITABS-AUSMGKO / L_MENGE.
*          IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( ITABS-AUSMG + ITABS-AUSMGKO ) ).
*          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
           IT_PRINT_001-QTY1 = L_MENGE.
           IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
        ENDIF.
      ELSE.
        IT_PRINT_001-QTY1 = L_MENGE.
        IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
      ENDIF.
      IT_PRINT_001-PMEHT1 = ITABS-PMEHT.
      IT_PRINT_001-PMEHT2 = '%'.        "ITABS-PMEHT.

      L_PRICE = 0.
      CALL FUNCTION 'Z_GET_PRICE_CB'
        EXPORTING
           PA_PRODNO = ITABS-RECO_CODE
           PA_BUKRS = P_BUKRS
           PA_DATE = G_DATE_PRICE
        IMPORTING
           PA_PRICE3 = L_PRICE.
      IT_PRINT_001-CB1 = IT_PRINT_001-QTY1 * L_PRICE.
      IT_PRINT_001-CB2 = IT_PRINT_001-CB1 * ( ( L_AUSCH + L_AVOAU ) / 100 ).
      IT_PRINT_001-CB3 = IT_PRINT_001-CB1 + IT_PRINT_001-CB2.
      IT_PRINT_001-TPR = ITABS-TPR.

      APPEND IT_PRINT_001.
    ENDIF.
    CLEAR IT_PRINT_001.
  ENDLOOP.

*-处理外购件
  LOOP AT ITABS.
    IF ( ITABS-TYPPS = 'M' ) AND ( ITABS-ISEND = 1 )
     AND ( ITABS-RECO_CODE+0(2) <> '10' ) AND ( ITABS-RECO_CODE+0(2) <> '91' ).
      IT_PRINT_001-ITEM_NAME_ALL = '材料费'.
      IT_PRINT_001-ITEM_NAME_SUB = '外购件'.
      IT_PRINT_001-MATNR_FATHER = ITABS-MATNR_FATHER.
      IT_PRINT_001-ITEM_CODE = ITABS-RECO_CODE.
      PERFORM. F_GET_PRODNAME USING ITABS-RECO_CODE CHANGING L_MATNRNAME.
      IT_PRINT_001-ITEM_NAME = L_MATNRNAME.

      PERFORM. F_GET_SHL USING ITABS-MATNR_FATHER ITABS-RECO_CODE
                        CHANGING L_AUSCH L_AVOAU L_MENGE.
      IF ITABS-ISCK13N = 1.
*        IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( L_AUSCH + L_AVOAU ) / 100 ).
*        IT_PRINT_001-QTY2 = IT_PRINT_001-QTY1 * ( L_AUSCH / 100 ).
        IF L_MENGE = 0.
          ITABS-AUSMG = 2.
          ITABS-AUSMGKO = 0.
          IT_PRINT_001-QTY1 = ITABS-MENGE.
          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
        ELSE.
*          ITABS-AUSMG = ITABS-AUSMG / L_MENGE.
*          ITABS-AUSMGKO = ITABS-AUSMGKO / L_MENGE.
*          IT_PRINT_001-QTY1 = ITABS-MENGE / ( 1 + ( ITABS-AUSMG + ITABS-AUSMGKO ) ).
*          IT_PRINT_001-QTY2 = ( ITABS-AUSMG / 100 ).
           IT_PRINT_001-QTY1 = L_MENGE.
           IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
        ENDIF.
      ELSE.
        IT_PRINT_001-QTY1 = L_MENGE.
        IT_PRINT_001-QTY2 = ( ( L_AUSCH + L_AVOAU ) / 100 ).
      ENDIF.
      IT_PRINT_001-PMEHT1 = ITABS-PMEHT.
      IT_PRINT_001-PMEHT2 = '%'.        "ITABS-PMEHT.

      L_PRICE = 0.
      CALL FUNCTION 'Z_GET_PRICE_CB'
        EXPORTING
           PA_PRODNO = ITABS-RECO_CODE
           PA_BUKRS = P_BUKRS
           PA_DATE = G_DATE_PRICE
        IMPORTING
           PA_PRICE3 = L_PRICE.
      IT_PRINT_001-CB1 = IT_PRINT_001-QTY1 * L_PRICE.
      IT_PRINT_001-CB2 = IT_PRINT_001-CB1 * ( ( L_AUSCH + L_AVOAU ) / 100 ).
      IT_PRINT_001-CB3 = IT_PRINT_001-CB1 + IT_PRINT_001-CB2.
      IT_PRINT_001-TPR = ITABS-TPR.

      APPEND IT_PRINT_001.
      CLEAR IT_PRINT_001.
    ENDIF.
  ENDLOOP.

  LOOP AT IT_PRINT_001.
    IF IT_PRINT_001-ITEM_NAME_ALL = '材料费'.
      LOOP AT ITABS.
        IF ( ITABS-RECO_CODE = IT_PRINT_001-MATNR_FATHER ) AND ( ITABS-SL_LL <> 0 ).
          IT_PRINT_001-QTY1 = IT_PRI

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/765243/viewspace-253300/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ZR_FI_016
下一篇: ZR_FI_017
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    43
  • 访问量
    33279