ITPub博客

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

ZR_FI_008

原创 Linux操作系统 作者:williamzhou 时间:2019-03-26 17:54:04 0 删除 编辑

*===============================基本信息===============================*
* 标题:资产负债报表
* 创建日期:2005-01-19       
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_008
NO STANDARD PAGE HEADING
LINE-SIZE  152
MESSAGE-ID ZFI1.

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

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES: T001,  "公司代码
        GLT0,  "总帐科目主记录业务额
        ANLC,  "资产值字段
        MBEW,  "物料评估
        MBEWH, "物料评估:历史
        MLIT,  "物料分类帐凭证: 项目(MR21主记录)
        MLHD,  "物料总帐凭证:标题(MR21)
        MLCR,  "物料分类帐凭证: 价格更改(货币, 价格)(MR21旧价格)
        MLCRP, "物料分类帐凭证: 价格更改(货币, 价格)(MR21新价格)
        MARD,  "物料的仓储位置数据
        MKPF,  "抬头:物料凭证
        MSEG,  "凭证段:物料
        KNA1,  "客户主文件的一般数据
        ZFI01,
        ZFI04.

************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表ITAB(作为辅助使用)
DATA: BEGIN OF ITAB OCCURS 10.
        INCLUDE STRUCTURE GLT0.
      DATA: TAMOUNT LIKE GLT0-HSLVT.
      DATA: TAMOUNT2 LIKE GLT0-HSLVT.
DATA: END OF ITAB.

*定义内表ITAB_QM(期未数)
DATA: BEGIN OF ITAB_QM OCCURS 10.
DATA: "流动资产:
      XJ      LIKE GLT0-HSLVT,   "现金
      DQTZ    LIKE GLT0-HSLVT,   "短期投资
      YSPJ    LIKE GLT0-HSLVT,   "应收票据
      YSZK    LIKE GLT0-HSLVT,   "应收帐款
      HZZB    LIKE GLT0-HSLVT,   "减:坏帐准备
      YSZKJE  LIKE GLT0-HSLVT,   "应收帐款净额
      YFZK    LIKE GLT0-HSLVT,   "预付帐款
      YSBTK   LIKE GLT0-HSLVT,   "应收补贴款
      QTYSK   LIKE GLT0-HSLVT,   "其他应收款
      CH      LIKE GLT0-HSLVT,   "存货
      DTFY    LIKE GLT0-HSLVT,   "待摊费用
      ZCLS    LIKE GLT0-HSLVT,   "待处理流动资产净损失
      ZQTZ    LIKE GLT0-HSLVT,   "一年内到期的长期债券投资
      QTLDZC      LIKE GLT0-HSLVT,"其他流动资产
      TOTAL_LDZC  LIKE GLT0-HSLVT,"流动资产合计

      "长期投资:
      CQTZ    LIKE GLT0-HSLVT,   "长期投资
      "固定资产:
      GDZCYZ  LIKE GLT0-HSLVT,   "固定资产原价
      LJZJ    LIKE GLT0-HSLVT,   "减:累计折旧
      GDZCJZ  LIKE GLT0-HSLVT,   "固定资产净值
      GDZCQL  LIKE GLT0-HSLVT,   "固定资产清理
      ZJGC    LIKE GLT0-HSLVT,   "在建工程
      GDZCSS      LIKE GLT0-HSLVT,"待处理固定资产净损失
      TOTAL_GDZC  LIKE GLT0-HSLVT,"固定资产合计

      "无形资产及递延资产:
      WXZC    LIKE GLT0-HSLVT,   "无形资产
      TYZC    LIKE GLT0-HSLVT,   "递延资产
      TOTAL_WXZC    LIKE GLT0-HSLVT,"无形资产及递延资产合计

      "其他长期资产:
      QCCQZC    LIKE GLT0-HSLVT, "其他长期资产
      "递延税项
      TYSXJX    LIKE GLT0-HSLVT, "递延税项借项
      TOTAL_ZC  LIKE GLT0-HSLVT, "资产总计

      "流动负债:
      DQJK    LIKE GLT0-HSLVT,   "短期借款
      YFPJ    LIKE GLT0-HSLVT,   "应付票据
      YIFZK   LIKE GLT0-HSLVT,   "应付帐款
      YUSZK    LIKE GLT0-HSLVT,   "预收帐款
      YFGZ    LIKE GLT0-HSLVT,   "应付工资
      YFFLF   LIKE GLT0-HSLVT,   "应付福利费
      YFGL    LIKE GLT0-HSLVT,   "应付股利
      YJSJ    LIKE GLT0-HSLVT,   "应交税金
      QTYJK   LIKE GLT0-HSLVT,   "其他应交款
      QTYFK   LIKE GLT0-HSLVT,   "其他应付款
      YTFY    LIKE GLT0-HSLVT,   "预提费用
      DQCQFZ  LIKE GLT0-HSLVT,   "一年内到期的长期负债
      QTLDFZ  LIKE GLT0-HSLVT,   "其他流动负债
      TOTAL_LDFZ LIKE GLT0-HSLVT,"流动负债合计

      "长期负债:
      CQJK    LIKE GLT0-HSLVT,   "长期借款
      YFZQ    LIKE GLT0-HSLVT,   "应付债券
      CQYFK   LIKE GLT0-HSLVT,   "长期应付款
      QTCQFZ  LIKE GLT0-HSLVT,   "其他长期负债
      ZFZZJ   LIKE GLT0-HSLVT,   "其中:住房周转金
      TOTAL_CQFZ LIKE GLT0-HSLVT,"长期负债合计

      "递延税项:
      TYSXDX    LIKE GLT0-HSLVT, "递延税项贷项
      TOTAL_FZ  LIKE GLT0-HSLVT, "负债合计

      "所有者权益(或股东权益):
      SSZB    LIKE GLT0-HSLVT,   "实收资本(或股本)
      YGFTZ   LIKE GLT0-HSLVT,   "减:已归还投资
      SSZBJE  LIKE GLT0-HSLVT,   "实收资本(或股本)净额
      ZBGJ    LIKE GLT0-HSLVT,   "资本公积
      YYGJ    LIKE GLT0-HSLVT,   "盈余公积
      GYJ     LIKE GLT0-HSLVT,   "其中:公益金
      WFPLL   LIKE GLT0-HSLVT,   "未分配利润
      TOTAL_QY   LIKE GLT0-HSLVT,"所有者权益合计
      TOTAL_FZQY LIKE GLT0-HSLVT,"负债及所有者权益总计

      "其它
      KM_YSZK    LIKE GLT0-HSLVT, "应收帐款???
      KM_CH      LIKE GLT0-HSLVT, "存货???
      KM_YJSJ    LIKE GLT0-HSLVT, "应交税金???

      "其它
      WFPLL_2   LIKE GLT0-HSLVT.  "未分配利润
DATA: END OF ITAB_QM.

*定义内表ITAB_NC(年初数)
DATA: ITAB_NC LIKE ITAB_QM OCCURS 10 WITH HEADER LINE.
*定义内表ITAB_NC2005(2005年初数,用于显示,不参加计算)
DATA: ITAB_NC2005 LIKE ITAB_QM OCCURS 10 WITH HEADER LINE.


*定义内表,处理非寄售出退货信息
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG.
        DATA CNO LIKE KNA1-KUNNR.          "客户代码,送达方
        DATA CNAME LIKE KNA1-NAME1.        "客户名称
        DATA CLASS LIKE KNA1-NAME1.        "事务类别
        DATA ORDERNO LIKE LIKP-VBELN.      "交退货单号
        DATA ORDERDATE LIKE LIKP-ERDAT.    "交货单/退货交货单日期
        DATA OLDERDATE LIKE LIKP-ERDAT.    "交货单原始日期
        DATA OTHERNO LIKE LIKP-VBELN.      "交货单参考单号
        DATA PRODNO LIKE LIPS-MATNR.       "产品型号
        DATA PRODNAME LIKE MAKT-MAKTX.     "产品名称
        DATA PRODQTY LIKE LIPS-LFIMG.      "数量
        DATA PRICE LIKE LIPS-NETPR.        "单价
        DATA KPEIN LIKE VBAP-KPEIN.        "条件定价单位
        DATA AMOUNT LIKE LIPS-NETPR.       "金额
        DATA KURSK LIKE VBKD-KURSK.        "汇率
        DATA WAERK LIKE VBAK-WAERK.        "币别

        DATA PRODQTY_C(20).
        DATA AMOUNT_C(20).
        DATA FKSTK LIKE VBUK-FKSTK.         "开票状态
        DATA AUART LIKE VBAK-AUART.         "订单类型
        DATA VGBEL LIKE LIPS-VGBEL.         "参考凭证的凭证号(销售订单号)
        DATA VGPOS LIKE LIPS-VGPOS.         "销售和分销凭证的项目号
        DATA KDMAT LIKE LIPS-KDMAT.         "客户物料号
        DATA BSTNK LIKE VBAK-BSTNK.         "采购订单编号
        DATA VTWEG LIKE VBAK-VTWEG.         "分销渠道
        DATA FKSAK LIKE VBUK-FKSAK.         "出具发票状态(订单相关的出具发票凭证)
        DATA PRICE_SR LIKE LIPS-NETPR.      "销售单价
        DATA PRICE_CB LIKE LIPS-NETPR.      "成本单价
        DATA AMOUNT_SR LIKE LIPS-NETPR.     "销售金额
        DATA AMOUNT_SJ LIKE LIPS-NETPR.     "内销税金
        DATA AMOUNT_CB LIKE LIPS-NETPR.     "成本金额
        DATA CLASSNAME LIKE KNA1-NAME1.     "事务类别名称
DATA: END OF IT_PRINT_001.

DATA: IT_PRINT_002 LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.
DATA: IT_TEMP LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*定义内表IT_PRINT_003
DATA: BEGIN OF IT_PRINT_003 OCCURS 10.
        INCLUDE STRUCTURE MBEWH.
      DATA: MBEWH_DATE LIKE LIKP-ERDAT.
      DATA: BELNR LIKE MLCRP-BELNR.
DATA: END OF IT_PRINT_003.
*定义内表IT_PRINT_103
DATA: BEGIN OF IT_PRINT_103 OCCURS 10.
        INCLUDE STRUCTURE MLCRP.
      DATA: MBEWH_DATE LIKE LIKP-ERDAT.
DATA: END OF IT_PRINT_103.

*取销售净价及货币
DATA: BEGIN OF IT_PRINT_004 OCCURS 0.
        DATA NETPR LIKE VBAP-NETPR.        "净价
        DATA WAERK LIKE VBAP-WAERK.        "SD 凭证货币
        DATA KPEIN LIKE VBAP-KPEIN.        "条件定价单位
DATA: END OF IT_PRINT_004.
*取汇率
DATA: BEGIN OF IT_PRINT_005 OCCURS 0.
        DATA UKURS LIKE TCURR-UKURS.        "汇率
        DATA GDATU LIKE TCURR-GDATU.        "汇率有效起始日期
DATA: END OF IT_PRINT_005.

*定义内表IT_PRINT_006(为取损益表上的值)
DATA: BEGIN OF IT_PRINT_006 OCCURS 10.
        INCLUDE STRUCTURE ZFI01.
DATA: END OF IT_PRINT_006.

*定义2005/2期初数据内表
DATA: BEGIN OF ITAB_FIRST OCCURS 10.
        INCLUDE STRUCTURE ZFI02.
DATA: END OF ITAB_FIRST.

DATA: BEGIN OF ITAB_LAST OCCURS 10.
        INCLUDE STRUCTURE ZFI02.
DATA: END OF ITAB_LAST.

*定义后台每期数据内表
DATA: BEGIN OF ITAB_SHOW OCCURS 10.
        INCLUDE STRUCTURE ZFI12.
DATA: END OF ITAB_SHOW.

*ALV导出内表
DATA: ITAB_ALV LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*往数据库增加运行日志
  DATA: BEGIN OF IT_ZREPORTLOG OCCURS  0.
    INCLUDE TYPE ZREPORTLOG.
  DATA: END OF IT_ZREPORTLOG.
************************************************************************
* CONSTANTS : 定义常量
************************************************************************
DATA: L_PRICE_SR TYPE P DECIMALS 6,
      L_PRICE_CB TYPE P DECIMALS 6,
      L_AMOUNT_SR LIKE LIPS-NETPR,
      L_AMOUNT_CB LIKE LIPS-NETPR,
      L_TAX TYPE P DECIMALS 2 VALUE '0.17'.
************************************************************************
* 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.

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.

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

DATA: G_DAY(2),
      G_LEN TYPE I,
      G_MOD TYPE I,
      V_KANSW LIKE ANLC-KANSW, "累积购置和生产费用
      V_KNAFA LIKE ANLC-KNAFA, "累计正常折旧
      P_KANSW LIKE ANLC-KANSW, "
      G_DATE1 LIKE LIKP-ERDAT,
      G_DATE2 LIKE LIKP-ERDAT,
      G_DATE3 LIKE LIKP-ERDAT,
      G_PRODNO LIKE LIPS-MATNR,
      G_DATE LIKE LIKP-ERDAT,
      G_PRICE TYPE P DECIMALS 6.

*用于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 MACRO1.               "画表格
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1.
  WRITE: AT  A2   SY-VLINE.
  WRITE: AT  B2   &2 CENTERED.
  WRITE: AT  A3   SY-VLINE.
  WRITE: AT  B3   &3 RIGHT-JUSTIFIED.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &4 RIGHT-JUSTIFIED.
  WRITE: AT  A5   SY-VLINE.
  WRITE: AT  B5   &5.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6 CENTERED.
  WRITE: AT  A7   SY-VLINE.
  WRITE: AT  B7   &7 RIGHT-JUSTIFIED.
  WRITE: AT  A8   SY-VLINE.
  WRITE: AT  B8   &8 RIGHT-JUSTIFIED.
  WRITE: AT  A9   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 008_1. "公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY MEMORY ID 008_2."报表年度
    PARAMETERS : P_MONAT(2) TYPE C OBLIGATORY MEMORY ID 008_3."报表期间
SELECTION-SCREEN END OF BLOCK BLK_001.

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

*后台相关处理
SELECTION-SCREEN BEGIN OF BLOCK BLK_003 WITH FRAME. TITLE BLK_003 .
PARAMETERS: P_QT RADIOBUTTON GROUP R2,        "前台运行
            P_SHOW RADIOBUTTON GROUP R2.      "显示后台结果
SELECTION-SCREEN END OF BLOCK BLK_003.

*===============================事    件===============================*
************************************************************************
* 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. CAL_DAY.                "每月天数判断

  IF P_QT = 'X'.
  IF P_REPORT = 'X' OR P_KM = 'X'.
    PERFORM. F_READ_DATA.
    IF P_RYEAR = '2005'.
      PERFORM. F_PRINT_REPORT2005.
    ELSE.
      PERFORM. F_PRINT_REPORT.
    ENDIF.
  ELSE.
    IF P_YSZK = 'X'.
      PERFORM. F_YSZK.
    ELSEIF P_YJSJ = 'X'.
      PERFORM. F_YJSJ.
    ELSE.
      PERFORM. F_CH.
    ENDIF.
    PERFORM. F_PRINT_ALV.
  ENDIF.
  ELSEIF P_SHOW = 'X'.
    PERFORM. F_SHOW.
  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_DATE LIKE LIKP-ERDAT.
DATA: S_DATE LIKE SY-DATUM.
      S_DATE = SY-DATUM - 60.
   CONCATENATE P_RYEAR P_MONAT '01' INTO L_DATE.

  IF P_MONAT+1(1) = ''.
    CONCATENATE '0' P_MONAT INTO P_MONAT.
  ENDIF.

 IF P_QT = 'X' AND L_DATE(6) < S_DATE(6) AND SY-UNAME <> 'IT'."IT帐号可以运行程序
    MESSAGE E006 WITH S_DATE(6).    "禁止在前台再运行小于S_DATE(6)的期间报表,但可后台显示
  ENDIF.

  IF ( P_MONAT < '01' ) OR ( P_MONAT > '16' ).
    MESSAGE E000.    "该会计期间不存在!
  ENDIF.
*  IF P_QT = 'X' AND P_RYEAR(4) < '2007'.
*     Message E005.    "不能运行06年的期间的报表!
*  ENDIF.

ENDFORM.                    " F_CHECK_INPUT
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
DATA: L_WFPLL_QM LIKE GLT0-HSLVT,
      L_WFPLL_NC LIKE GLT0-HSLVT.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE ITAB
   FROM GLT0
   WHERE RYEAR = P_RYEAR AND
         BUKRS = P_BUKRS AND
*         RBUSA = '' AND                "业务范围
         RACCT > '0010000000'.

  REFRESH ITAB_QM.
  CLEAR ITAB_QM.
  REFRESH ITAB_NC.
  CLEAR ITAB.

*开始循环,处理每月期未数
LOOP AT ITAB.
  CASE P_MONAT.
    WHEN '01'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL01.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01.
      ENDIF.
    WHEN '02'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL02.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02.
      ENDIF.
    WHEN '03'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL03.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03.
      ENDIF.
    WHEN '04'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL04.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04.
      ENDIF.
    WHEN '05'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL05.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05.
      ENDIF.
    WHEN '06'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL06.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06.
      ENDIF.
    WHEN '07'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL07.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07.
      ENDIF.
    WHEN '08'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL08.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08.
      ENDIF.
    WHEN '09'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL09.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09.
      ENDIF.
    WHEN '10'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL10.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10.
      ENDIF.
    WHEN '11'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL11.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11.
      ENDIF.
    WHEN '12'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15 + ITAB-HSL16.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15
                     + ITAB-HSL16.
      ENDIF.
*    WHEN '13'.
*      IF ITAB-BUKRS = '0999'.
*        ITAB-TAMOUNT = ITAB-HSL13.
*      ELSE.
*        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
*                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
*                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
*                     + ITAB-HSL12 + ITAB-HSL13.
*      ENDIF.
*    WHEN '14'.
*      IF ITAB-BUKRS = '0999'.
*        ITAB-TAMOUNT = ITAB-HSL14.
*      ELSE.
*        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
*                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
*                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
*                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14.
*      ENDIF.
*    WHEN '15'.
*      IF ITAB-BUKRS = '0999'.
*        ITAB-TAMOUNT = ITAB-HSL15.
*      ELSE.
*        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
*                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
*                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
*                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15.
*      ENDIF.
*    WHEN '16'.
*      IF ITAB-BUKRS = '0999'.
*        ITAB-TAMOUNT = ITAB-HSL16.
*      ELSE.
*        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
*                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
*                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
*                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15
*                     + ITAB-HSL16.
*     ENDIF.
  ENDCASE.
  MODIFY ITAB INDEX SY-TABIX.

*  汇总明细科目至总账科目
  "存货
  IF ITAB-RACCT+2(2) = '12' OR ITAB-RACCT+2(8) = '41020001'
   OR ITAB-RACCT+2(8) = '41020002' OR ITAB-RACCT+2(8) = '41020003'.
    IF ITAB-RACCT+2(8) <> '12329999'.
      ITAB_QM-CH = ITAB_QM-CH + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-CH  = ITAB_NC-CH + ITAB-HSLVT.     "期初数(ITAB_NC)

      ITAB_QM-KM_CH = ITAB_QM-KM_CH + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-KM_CH  = ITAB_NC-KM_CH + ITAB-HSLVT.     "期初数(ITAB_NC)
    ENDIF.
  ELSE.
  CASE ITAB-RACCT+2(4).
"====流动资产:
    "货币资金
    WHEN '1001' OR '1002' OR '1009'.
      ITAB_QM-XJ = ITAB_QM-XJ + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-XJ  = ITAB_NC-XJ + ITAB-HSLVT.     "期初数(ITAB_NC)
    "短期投资
    WHEN '1101' OR '1102'.
      ITAB_QM-DQTZ = ITAB_QM-DQTZ + ITAB-TAMOUNT.
      ITAB_NC-DQTZ  = ITAB_NC-DQTZ + ITAB-HSLVT.
    "应收票据
    WHEN '1111'.
      ITAB_QM-YSPJ = ITAB_QM-YSPJ + ITAB-TAMOUNT.
      ITAB_NC-YSPJ  = ITAB_NC-YSPJ + ITAB-HSLVT.
    "应收帐款
    WHEN '1131'.
      ITAB_QM-YSZK = ITAB_QM-YSZK + ITAB-TAMOUNT.
      ITAB_NC-YSZK  = ITAB_NC-YSZK + ITAB-HSLVT.

      ITAB_QM-KM_YSZK = ITAB_QM-KM_YSZK + ITAB-TAMOUNT2.
      ITAB_NC-KM_YSZK  = ITAB_NC-KM_YSZK + ITAB-HSLVT.
    "减:坏帐准备
    WHEN '1141'.
      ITAB_QM-HZZB = ITAB_QM-HZZB + ITAB-TAMOUNT.
      ITAB_NC-HZZB  = ITAB_NC-HZZB + ITAB-HSLVT.
    "应收帐款净额(略)
    "预付帐款
    WHEN '1151'.
      ITAB_QM-YFZK = ITAB_QM-YFZK + ITAB-TAMOUNT.
      ITAB_NC-YFZK  = ITAB_NC-YFZK + ITAB-HSLVT.
    "应收补贴款
    WHEN '1161'.
      ITAB_QM-YSBTK = ITAB_QM-YSBTK + ITAB-TAMOUNT.
      ITAB_NC-YSBTK  = ITAB_NC-YSBTK + ITAB-HSLVT.
    "其他应收款
    WHEN '1133'.
      ITAB_QM-QTYSK = ITAB_QM-QTYSK + ITAB-TAMOUNT.
      ITAB_NC-QTYSK  = ITAB_NC-QTYSK + ITAB-HSLVT.
    "存货(在上面处理)
    "待摊费用
    WHEN '1301'.
      ITAB_QM-DTFY = ITAB_QM-DTFY + ITAB-TAMOUNT.
      ITAB_NC-DTFY  = ITAB_NC-DTFY + ITAB-HSLVT.
    "待处理流动资产净损失(无)
    "一年内到期的长期债券投资(无)
    "其他流动资产
    WHEN '1498' OR '6001'.
      IF ( ITAB-RACCT+2(8) = '14980001' ) OR ( ITAB-RACCT+2(8) = '14980002' )
       OR ( ITAB-RACCT+2(8) = '60010001' ).
        ITAB_QM-QTLDZC = ITAB_QM-QTLDZC + ITAB-TAMOUNT.
        ITAB_NC-QTLDZC  = ITAB_NC-QTLDZC + ITAB-HSLVT.
      ENDIF.
    "流动资产合计(略)

"====长期投资:
    "长期投资
    WHEN '1401'.
      ITAB_QM-CQTZ = ITAB_QM-CQTZ + ITAB-TAMOUNT.
      ITAB_NC-CQTZ  = ITAB_NC-CQTZ + ITAB-HSLVT.

"====固定资产:
    "固定资产原价
    WHEN '1501'.
      ITAB_QM-GDZCYZ = ITAB_QM-GDZCYZ + ITAB-TAMOUNT.
      ITAB_NC-GDZCYZ  = ITAB_NC-GDZCYZ + ITAB-HSLVT.
    "减:累计折旧
    WHEN '1502'.
      ITAB_QM-LJZJ = ITAB_QM-LJZJ + ITAB-TAMOUNT.
      ITAB_NC-LJZJ  = ITAB_NC-LJZJ + ITAB-HSLVT.
    "固定资产净值(无)
    "固定资产清理
    WHEN '1701'.
      ITAB_QM-GDZCQL = ITAB_QM-GDZCQL + ITAB-TAMOUNT.
      ITAB_NC-GDZCQL  = ITAB_NC-GDZCQL + ITAB-HSLVT.
    "在建工程
    WHEN '1603'.
      ITAB_QM-ZJGC = ITAB_QM-ZJGC + ITAB-TAMOUNT.
      ITAB_NC-ZJGC  = ITAB_NC-ZJGC + ITAB-HSLVT.
    "待处理固定资产净损失
    WHEN '1911'.
      ITAB_QM-GDZCSS = ITAB_QM-GDZCSS + ITAB-TAMOUNT.
      ITAB_NC-GDZCSS  = ITAB_NC-GDZCSS + ITAB-HSLVT.
    "固定资产合计(略)

"====无形资产及递延资产:
    "无形资产
    WHEN '1801'.
      ITAB_QM-WXZC = ITAB_QM-WXZC + ITAB-TAMOUNT.
      ITAB_NC-WXZC  = ITAB_NC-WXZC + ITAB-HSLVT.
    "递延资产(无)
    "无形资产及递延资产合计(略)

"====其他长期资产:
    "其他长期资产
    WHEN '1901'.
      ITAB_QM-QCCQZC = ITAB_QM-QCCQZC + ITAB-TAMOUNT.
      ITAB_NC-QCCQZC  = ITAB_NC-QCCQZC + ITAB-HSLVT.
"====递延税项
    "递延税项借项(无)
    "资产总计(略)


"====流动负债:
    "短期借款
    WHEN '2101'.
      ITAB_QM-DQJK = ITAB_QM-DQJK + ITAB-TAMOUNT.
      ITAB_NC-DQJK  = ITAB_NC-DQJK + ITAB-HSLVT.
    "应付票据
    WHEN '2111'.
      ITAB_QM-YFPJ = ITAB_QM-YFPJ + ITAB-TAMOUNT.
      ITAB_NC-YFPJ  = ITAB_NC-YFPJ + ITAB-HSLVT.
    "应付帐款
    WHEN '2121'.
      ITAB_QM-YIFZK = ITAB_QM-YIFZK + ITAB-TAMOUNT.
      ITAB_NC-YIFZK  = ITAB_NC-YIFZK + ITAB-HSLVT.
    "预收帐款
    WHEN '2131'.
      ITAB_QM-YUSZK = ITAB_QM-YUSZK + ITAB-TAMOUNT.
      ITAB_NC-YUSZK  = ITAB_NC-YUSZK + ITAB-HSLVT.
    "应付工资
    WHEN '2151'.
      ITAB_QM-YFGZ = ITAB_QM-YFGZ + ITAB-TAMOUNT.
      ITAB_NC-YFGZ  = ITAB_NC-YFGZ + ITAB-HSLVT.
    "应付福利费
    WHEN '2153'.
      ITAB_QM-YFFLF = ITAB_QM-YFFLF + ITAB-TAMOUNT.
      ITAB_NC-YFFLF  = ITAB_NC-YFFLF + ITAB-HSLVT.
    "应付股利
    WHEN '2161'.
      ITAB_QM-YFGL = ITAB_QM-YFGL + ITAB-TAMOUNT.
      ITAB_NC-YFGL  = ITAB_NC-YFGL + ITAB-HSLVT.
    "应交税金
    WHEN '2171'.
      ITAB_QM-YJSJ = ITAB_QM-YJSJ + ITAB-TAMOUNT.
      ITAB_NC-YJSJ  = ITAB_NC-YJSJ + ITAB-HSLVT.

      ITAB_QM-KM_YJSJ = ITAB_QM-KM_YJSJ + ITAB-TAMOUNT2.
      ITAB_NC-KM_YJSJ  = ITAB_NC-KM_YJSJ + ITAB-HSLVT.
    "其他应交款(无)
    WHEN '2176'.
      ITAB_QM-QTYJK = ITAB_QM-QTYJK + ITAB-TAMOUNT.
      ITAB_NC-QTYJK  = ITAB_NC-QTYJK + ITAB-HSLVT.
    "其他应付款
    WHEN '2181'.
      ITAB_QM-QTYFK = ITAB_QM-QTYFK + ITAB-TAMOUNT.
      ITAB_NC-QTYFK  = ITAB_NC-QTYFK + ITAB-HSLVT.
    "预提费用
    WHEN '2191'.
      ITAB_QM-YTFY = ITAB_QM-YTFY + ITAB-TAMOUNT.
      ITAB_NC-YTFY  = ITAB_NC-YTFY + ITAB-HSLVT.
    "一年内到期的长期负债(无)
    "其他流动负债(无)
    "流动负债合计(略)
"====长期负债:
    "长期借款
    WHEN '2201'.
    ITAB_QM-CQJK = ITAB_QM-CQJK + ITAB-TAMOUNT.
    ITAB_NC-CQJK  = ITAB_NC-CQJK + ITAB-HSLVT.
"====递延税项:(无)
"====所有者权益(或股东权益):
    "实收资本(或股本)
    WHEN '3101'.
      ITAB_QM-SSZB = ITAB_QM-SSZB + ITAB-TAMOUNT.
      ITAB_NC-SSZB  = ITAB_NC-SSZB + ITAB-HSLVT.
    "减:已归还投资(无)
    "实收资本(或股本)净额(无)
    "资本公积
    WHEN '3111'.
      ITAB_QM-ZBGJ = ITAB_QM-ZBGJ + ITAB-TAMOUNT.
      ITAB_NC-ZBGJ  = ITAB_NC-ZBGJ + ITAB-HSLVT.
    "盈余公积
    WHEN '3121'.
      ITAB_QM-YYGJ = ITAB_QM-YYGJ + ITAB-TAMOUNT.
      ITAB_NC-YYGJ  = ITAB_NC-YYGJ + ITAB-HSLVT.
    "其中:公益金(无)
    "未分配利润
    WHEN '3131' OR '3141'.
      ITAB_QM-WFPLL_2 = ITAB_QM-WFPLL_2 + ITAB-TAMOUNT.
      ITAB_NC-WFPLL_2 = ITAB_NC-WFPLL_2 + ITAB-HSLVT.
      IF P_RYEAR = '2005'.
        L_WFPLL_QM = L_WFPLL_QM + ITAB-HSL02.
      ENDIF.
    "所有者权益合计(略)
    "负债及所有者权益总计(略)
  ENDCASE.
  ENDIF.

*更新内表ITAB_NC,ITAB_QM
  MODIFY ITAB_NC INDEX SY-TABIX.
  MODIFY ITAB_QM INDEX SY-TABIX.
ENDLOOP.

*2005年年初数据特殊处理
  IF P_RYEAR = '2005'.
    PERFORM. F_FIRST_DO.
  ENDIF.

IF P_KM <> 'X'.
  IF NOT ( ( P_RYEAR = '2005' ) AND ( P_MONAT = '02' ) ).
*应收账款处理
    PERFORM. F_YSZK.
*存货处理
    PERFORM. F_CH.
*应交税金处理
    PERFORM. F_YJSJ.

*未分配利润处理
    PERFORM. F_WFPLL.
*2000公司"其他流动资产"&"未分配利润"特殊处理
    IF P_BUKRS = '2000'.
      PERFORM. F_MPS.
    ENDIF.
    "2005年之后年度的期初数处理
    IF P_RYEAR > '2005'.
      PERFORM. F_INI.
    ENDIF.
  ENDIF.

  IF P_RYEAR = '2005'.
    ITAB_NC-WFPLL = ITAB_NC-WFPLL + ITAB_NC-WFPLL_2.
    ITAB_QM-WFPLL = ITAB_QM-WFPLL + ITAB_QM-WFPLL_2 - L_WFPLL_QM + ITAB_QM-YYGJ.
  ENDIF.
  MODIFY ITAB_NC INDEX SY-TABIX.
  MODIFY ITAB_QM INDEX SY-TABIX.
ENDIF.

*最终数据合计及总计
  PERFORM. F_TOTAL.

*上年底期未数保存
  IF P_MONAT = '12'.
    PERFORM. F_SAVE.
  ENDIF.

*保存本期数据(年初数及期末数)
  PERFORM. F_SAVE_02.
ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*&      2005年数据特殊处理
*&      从表ZFI02中取2004年12月31日的期初数据
*&      从表ZFI02中取2005年1月&2月的本年数
*&---------------------------------------------------------------------*
FORM. F_FIRST_DO.
*取2004年12月31日的期未数据(为了显示期初值)
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB_FIRST
    FROM ZFI02
    WHERE RRCTY = '2'
      AND BUKRS = P_BUKRS.

  LOOP AT ITAB_FIRST.
*-----资产
    ITAB_NC2005-CH = ITAB_FIRST-CH.
    ITAB_NC2005-XJ = ITAB_FIRST-XJ.
    ITAB_NC2005-DQTZ = ITAB_FIRST-DQTZ.
    ITAB_NC2005-YSPJ = ITAB_FIRST-YSPJ.
    ITAB_NC2005-YSZK = ITAB_FIRST-YSZK.
    ITAB_NC2005-HZZB = 0 - ITAB_FIRST-HZZB.
    ITAB_NC2005-YFZK = ITAB_FIRST-YFZK.
    ITAB_NC2005-YSBTK = ITAB_FIRST-YSBTK.
    ITAB_NC2005-QTYSK = ITAB_FIRST-QTYSK.
    ITAB_NC2005-DTFY = ITAB_FIRST-DTFY.
    ITAB_NC2005-QTLDZC = ITAB_FIRST-QTLDZC.
    ITAB_NC2005-CQTZ = ITAB_FIRST-CQTZ.
    ITAB_NC2005-GDZCYZ = ITAB_FIRST-GDZCYZ.
    ITAB_NC2005-LJZJ = 0 - ITAB_FIRST-LJZJ.
    ITAB_NC2005-GDZCQL = ITAB_FIRST-GDZCQL.
    ITAB_NC2005-ZJGC = ITAB_FIRST-ZJGC.
    ITAB_NC2005-GDZCSS = ITAB_FIRST-GDZCSS.
    ITAB_NC2005-WXZC = ITAB_FIRST-WXZC.
    ITAB_NC2005-QCCQZC = ITAB_FIRST-QCCQZC.

*------负债及所有者权益
    ITAB_NC2005-DQJK = 0 - ITAB_FIRST-DQJK.
    ITAB_NC2005-YFPJ = 0 - ITAB_FIRST-YFPJ.
    ITAB_NC2005-YIFZK = 0 - ITAB_FIRST-YIFZK.
    ITAB_NC2005-YUSZK = 0 - ITAB_FIRST-YUSZK.
    ITAB_NC2005-YFGZ = 0 - ITAB_FIRST-YFGZ.
    ITAB_NC2005-YFFLF = 0 - ITAB_FIRST-YFFLF.
    ITAB_NC2005-YFGL = 0 - ITAB_FIRST-YFGL.
    ITAB_NC2005-YJSJ = 0 - ITAB_FIRST-YJSJ.
    ITAB_NC2005-QTYJK = 0 - ITAB_FIRST-QTYJK.
    ITAB_NC2005-QTYFK = 0 - ITAB_FIRST-QTYFK.
    ITAB_NC2005-YTFY = 0 - ITAB_FIRST-YTFY.
    ITAB_NC2005-SSZB = 0 - ITAB_FIRST-SSZB.
    ITAB_NC2005-ZBGJ = 0 - ITAB_FIRST-ZBGJ.
    ITAB_NC2005-YYGJ = 0 - ITAB_FIRST-YYGJ.
    ITAB_NC2005-WFPLL = 0 - ITAB_FIRST-WFPLL.

*---更新内表ITAB_NC
    MODIFY ITAB_NC2005 INDEX SY-TABIX.
  ENDLOOP.


*取2005年2月的本年数(该值是为了显示2005年2月份的期未数)
  IF P_MONAT = '02'.
  CLEAR ITAB_FIRST.
  REFRESH ITAB_FIRST.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB_FIRST
    FROM ZFI02
    WHERE RRCTY = '4'
      AND BUKRS = P_BUKRS.

  LOOP AT ITAB_FIRST.
*-----资产
    ITAB_QM-CH = ITAB_FIRST-CH.
    ITAB_QM-KM_CH = ITAB_FIRST-CH.
    ITAB_QM-XJ = ITAB_FIRST-XJ.
    ITAB_QM-DQTZ = ITAB_FIRST-DQTZ.
    ITAB_QM-YSPJ = ITAB_FIRST-YSPJ.
    ITAB_QM-YSZK = ITAB_FIRST-YSZK.
    ITAB_QM-KM_YSZK = ITAB_FIRST-YSZK.
    ITAB_QM-HZZB = 0 - ITAB_FIRST-HZZB.
    ITAB_QM-YFZK = ITAB_FIRST-YFZK.
    ITAB_QM-YSBTK = ITAB_FIRST-YSBTK.
    ITAB_QM-QTYSK = ITAB_FIRST-QTYSK.
    ITAB_QM-DTFY = ITAB_FIRST-DTFY.
    ITAB_QM-QTLDZC = ITAB_FIRST-QTLDZC.
    ITAB_QM-CQTZ = ITAB_FIRST-CQTZ.
    ITAB_QM-GDZCYZ = ITAB_FIRST-GDZCYZ.
    ITAB_QM-LJZJ = 0 - ITAB_FIRST-LJZJ.
    ITAB_QM-GDZCQL = ITAB_FIRST-GDZCQL.
    ITAB_QM-ZJGC = ITAB_FIRST-ZJGC.
    ITAB_QM-GDZCSS = ITAB_FIRST-GDZCSS.
    ITAB_QM-WXZC = ITAB_FIRST-WXZC.
    ITAB_QM-QCCQZC = ITAB_FIRST-QCCQZC.

*------负债及所有者权益
    ITAB_QM-DQJK = 0 - ITAB_FIRST-DQJK.
    ITAB_QM-YFPJ = 0 - ITAB_FIRST-YFPJ.
    ITAB_QM-YIFZK = 0 - ITAB_FIRST-YIFZK.
    ITAB_QM-YUSZK = 0 - ITAB_FIRST-YUSZK.
    ITAB_QM-YFGZ = 0 - ITAB_FIRST-YFGZ.
    ITAB_QM-YFFLF = 0 - ITAB_FIRST-YFFLF.
    ITAB_QM-YFGL = 0 - ITAB_FIRST-YFGL.
    ITAB_QM-YJSJ = 0 - ITAB_FIRST-YJSJ.
    ITAB_QM-KM_YJSJ = 0 - ITAB_FIRST-YJSJ.
    ITAB_QM-QTYJK = 0 - ITAB_FIRST-QTYJK.
    ITAB_QM-QTYFK = 0 - ITAB_FIRST-QTYFK.
    ITAB_QM-YTFY = 0 - ITAB_FIRST-YTFY.
    ITAB_QM-SSZB = 0 - ITAB_FIRST-SSZB.
    ITAB_QM-ZBGJ = 0 - ITAB_FIRST-ZBGJ.
    ITAB_QM-YYGJ = 0 - ITAB_FIRST-YYGJ.
    ITAB_QM-WFPLL = 0 - ITAB_FIRST-WFPLL.

*---更新内表ITAB_NC
    MODIFY ITAB_QM INDEX SY-TABIX.
  ENDLOOP.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*保存上年底期未数
*&---------------------------------------------------------------------*
FORM. F_SAVE.
DATA: L_YJSJ LIKE GLT0-HSLVT,
      L_WFPLL LIKE GLT0-HSLVT,
      L_FLAG TYPE I,
      L_RYEAR LIKE GLT0-RYEAR.

  CLEAR ITAB_LAST.
  REFRESH ITAB_LAST.
  L_YJSJ = 0 - ITAB_QM-YJSJ.
  L_WFPLL = 0 - ITAB_QM-WFPLL.
  L_RYEAR = P_RYEAR.
  L_RYEAR = L_RYEAR + 1.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB_LAST
    FROM ZFI02
    WHERE RRCTY = '6'
      AND BUKRS = P_BUKRS
      AND RYEAR = L_RYEAR.

  L_FLAG = 0.
  LOOP AT ITAB_LAST.
    UPDATE ZFI02
        SET YSZK = ITAB_QM-YSZK
            CH = ITAB_QM-CH
            QTLDZC = ITAB_QM-QTLDZC
            YJSJ = L_YJSJ
            WFPLL = L_WFPLL
            TEXT = '上年底期未数'
        WHERE RRCTY = '6'
          AND BUKRS = P_BUKRS
          AND RYEAR = L_RYEAR.
    L_FLAG = 1.
  ENDLOOP.

  IF L_FLAG = 0.
    ITAB_LAST-RRCTY = '6'.
    ITAB_LAST-BUKRS = P_BUKRS.
    ITAB_LAST-RYEAR = L_RYEAR.
    ITAB_LAST-RPMAX = '01'.
    ITAB_LAST-YSZK = ITAB_QM-YSZK.
    ITAB_LAST-CH = ITAB_QM-CH.
    ITAB_LAST-QTLDZC = ITAB_QM-QTLDZC.
    ITAB_LAST-YJSJ = L_YJSJ.
    ITAB_LAST-WFPLL = L_WFPLL.
    ITAB_LAST-TEXT = '上年底期未数'.
    ITAB_LAST-ERDAT = SY-DATUM.
    ITAB_LAST-AEDAT = SY-DATUM.
    ITAB_LAST-ERNAM = SY-UNAME.
    ITAB_LAST-AENAM = SY-UNAME.

    INSERT INTO ZFI02
           VALUES ITAB_LAST .
  ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*保存本期数据(年初数及期末数)
*&---------------------------------------------------------------------*
FORM. F_SAVE_02.
DATA: L_FLAG TYPE I.

*-年初数
  IF P_RYEAR = '2005'.
    PERFORM. F_SAVE_2005.
  ELSE.
    IF P_MONAT = '12'.
      PERFORM. F_SAVE_2005LATER.
    ENDIF.
  ENDIF.

*-期末数
*  LOOP AT ITAB_QM.
  CLEAR ITAB_SHOW.
  REFRESH ITAB_SHOW.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB_SHOW
    FROM ZFI12
    WHERE RRCTY = '1'
      AND BUKRS = P_BUKRS
      AND RYEAR = P_RYEAR
      AND RPMAX = P_MONAT.

  L_FLAG = 0.
  LOOP AT ITAB_SHOW.
    UPDATE ZFI12
*-----资产
        SET XJ = ITAB_QM-XJ
            DQTZ = ITAB_QM-DQTZ
            YSPJ = ITAB_QM-YSPJ
            YSZK = ITAB_QM-YSZK
*            YSZK = ITAB_QM-KM_YSZK
            HZZB = ITAB_QM-HZZB
            YSZKJE = ITAB_QM-YSZKJE
            YFZK = ITAB_QM-YFZK
            YSBTK = ITAB_QM-YSBTK
            QTYSK = ITAB_QM-QTYSK
            CH = ITAB_QM-CH
            DTFY = ITAB_QM-DTFY
            ZCLS = ITAB_QM-ZCLS
            ZQTZ = ITAB_QM-ZQTZ
            QTLDZC = ITAB_QM-QTLDZC
            TOTAL_LDZC = ITAB_QM-TOTAL_LDZC

            CQTZ = ITAB_QM-CQTZ
            GDZCYZ = ITAB_QM-GDZCYZ
            LJZJ = ITAB_QM-LJZJ
            GDZCJZ = ITAB_QM-GDZCJZ
            GDZCQL = ITAB_QM-GDZCQL
            ZJGC = ITAB_QM-ZJGC
            GDZCSS = ITAB_QM-GDZCSS
            TOTAL_GDZC = ITAB_QM-TOTAL_GDZC
            WXZC = ITAB_QM-WXZC
            TYZC = ITAB_QM-TYZC
            TOTAL_WXZC = ITAB_QM-TOTAL_WXZC
            QCCQZC = ITAB_QM-QCCQZC
            TYSXJX = ITAB_QM-TYSXJX
            TOTAL_ZC = ITAB_QM-TOTAL_ZC

*------负债及所有者权益
            DQJK = ITAB_QM-DQJK
            YFPJ = ITAB_QM-YFPJ
            YIFZK = ITAB_QM-YIFZK
            YUSZK = ITAB_QM-YUSZK
            YFGZ = ITAB_QM-YFGZ
            YFFLF = ITAB_QM-YFFLF
            YFGL = ITAB_QM-YFGL
            YJSJ = ITAB_QM-YJSJ
            QTYJK = ITAB_QM-QTYJK
            QTYFK = ITAB_QM-QTYFK
            YTFY = ITAB_QM-YTFY
            DQCQFZ = ITAB_QM-DQCQFZ
            QTLDFZ = ITAB_QM-QTLDFZ
            TOTAL_LDFZ = ITAB_QM-TOTAL_LDFZ
            CQJK = ITAB_QM-CQJK
            YFZQ = ITAB_QM-YFZQ
            CQYFK = ITAB_QM-CQYFK
            QTCQFZ = ITAB_QM-QTCQFZ
            ZFZZJ = ITAB_QM-ZFZZJ
            TOTAL_CQFZ = ITAB_QM-TOTAL_CQFZ
            TYSXDX = ITAB_QM-TYSXDX
            TOTAL_FZ = ITAB_QM-TOTAL_FZ

            SSZB = ITAB_QM-SSZB
            YGFTZ = ITAB_QM-YGFTZ
            SSZBJE = ITAB_QM-SSZBJE
            ZBGJ = ITAB_QM-ZBGJ
            YYGJ = ITAB_QM-YYGJ
            GYJ = ITAB_QM-GYJ
            WFPLL = ITAB_QM-WFPLL
            TOTAL_QY = ITAB_QM-TOTAL_QY
            TOTAL_FZQY = ITAB_QM-TOTAL_FZQY

            AEDAT = SY-DATUM
            AENAM = SY-UNAME
        WHERE RRCTY = '1'
          AND BUKRS = P_BUKRS
          AND RYEAR = P_RYEAR
          AND RPMAX = P_MONAT.
    L_FLAG = 1.
  ENDLOOP.

  IF L_FLAG =

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

上一篇: ZR_FI_005
下一篇: ZR_FI_012
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    26
  • 访问量
    19197