ITPub博客

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

ZR_FI_019

原创 Linux操作系统 作者:williamzhou 时间:2019-07-12 11:57:08 0 删除 编辑

*===============================基本信息===============================*
* 标题:存货明细账
* 创建日期:2005-08-13       
*===============================定    义==-=============================*

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

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

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES: T001,  "公司代码
        MBEW,  "
        MARC,  "
        MARDH, "
        CKMI1, "
        BKPF,  "会计核算凭证标题(主表)
        BSEG,  "会计核算凭证段(从表)
        MKPF,  "抬头:物料凭证
        MSEG,  "
        MARA,  "常规物料数据
        T023T, "物料组描述
        T003T, "凭证类型文本
        ANLC.  "资产值字段
************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG.
        DATA BUKRS LIKE BKPF-BUKRS.          "公司代码
        DATA MATNR LIKE MBEW-MATNR.          "物料号
        DATA MAKTX LIKE MAKT-MAKTX.          "物料名称
        DATA GROES LIKE MARA-GROES.          "大小/量纲(规格)
        DATA MEINS LIKE MARA-MEINS.          "基本计量单位
        DATA MATKL LIKE MARA-MATKL.          "物料组
        DATA WGBEZ LIKE T023T-WGBEZ.         "物料组描述

        DATA BUDAT LIKE BKPF-BUDAT.          "凭证中的记帐日期
        DATA MBLNR LIKE MKPF-MBLNR.          "物料凭证编号
        DATA BELNR LIKE BKPF-BELNR.          "会计凭证号码
        DATA BLART LIKE T003T-LTEXT.         "凭证类型
        DATA BWART LIKE MSEG-BWART.          "移动类型
        DATA BKTXT LIKE BKPF-BKTXT.          "凭证抬头文本(摘要)
        DATA MENGE1 LIKE BSEG-MENGE.         "数量(收入)
        DATA DMBTR1 LIKE BSEG-DMBTR.         "金额(收入)
        DATA PRICE1 TYPE P DECIMALS 6.       "价格(收入)
        DATA MENGE2 LIKE BSEG-MENGE.         "数量(发出)
        DATA DMBTR2 LIKE BSEG-DMBTR.         "金额(发出)
        DATA PRICE2 TYPE P DECIMALS 6.       "价格(发出)
        DATA MENGE3 LIKE BSEG-MENGE.         "数量(结存)
        DATA DMBTR3 LIKE BSEG-DMBTR.         "金额(结存)
        DATA PRICE3 TYPE P DECIMALS 6.       "价格(结存)

        DATA AWTYP LIKE CKMI1-AWTYP.         "参考过程
        DATA KALN1 LIKE MBEW-KALNR.          "成本估算号
        DATA MENGE0 LIKE BSEG-MENGE.         "总库存量(起始库存)
        DATA DMBTR0 LIKE BSEG-DMBTR.         "总价值(起始库存)
        DATA MENGE LIKE BSEG-MENGE.          "数量(临时)
        DATA DMBTR LIKE BSEG-DMBTR.          "金额(临时)
        DATA PRICE TYPE P DECIMALS 6.        "价格(临时)

        DATA DATUM LIKE CKMI1-DATUM.
        DATA UZEIT LIKE CKMI1-UZEIT.
        DATA AWKEY LIKE BKPF-AWKEY.
DATA: END OF IT_PRINT_001.

DATA: ITAB_TITLE LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.
DATA: ITAB_01 LIKE IT_PRINT_001 OCCURS 16 WITH HEADER LINE.
DATA: ITAB_ALV LIKE IT_PRINT_001 OCCURS 16 WITH HEADER LINE.

DATA: ITAB_TEMP LIKE IT_PRINT_001 OCCURS 16 WITH HEADER LINE.

*定义内表ITAB1
DATA: BEGIN OF ITAB1 OCCURS 10.
        DATA GROES LIKE MARA-GROES.          "大小/量纲(规格)
        DATA MEINS LIKE MARA-MEINS.          "基本计量单位
        DATA MATKL LIKE MARA-MATKL.          "物料组
DATA: END OF ITAB1.

*后台记录表
DATA: BEGIN OF ITAB_HT OCCURS 10.
        INCLUDE STRUCTURE ZFI07.
DATA: END OF ITAB_HT.
DATA: ITAB_HT2 LIKE ITAB_HT OCCURS 10 WITH HEADER LINE.

*往数据库增加运行日志
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.

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.

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

DATA: DS(1)  VALUE 'D'.            "判断是否该换页的标志
DATA: ZYS TYPE I VALUE 0.          "总月数
DATA: ZHS TYPE I VALUE 0.          "总行数
DATA: PAGENUM TYPE I VALUE 0.      "总的页数
DATA: PAGE_CURR TYPE I.            "当前页数
DATA: LIMTA TYPE I VALUE 0.
DATA: LIMTB TYPE I VALUE 0.
DATA: YS TYPE I VALUE 0.           "余数
DATA: XHCS TYPE I VALUE 0.         "循环次数
DATA: PZNO TYPE I VALUE 0.         "每个凭证的页序号
DATA: PZS  TYPE I VALUE 0.         "查询到的凭证数

DATA: G_DATE1 LIKE LIKP-ERDAT,
      G_DATE2 LIKE LIKP-ERDAT,
      G_MONAT1 TYPE D,
      G_MONAT2 TYPE D.

DATA: G_QTY_TOTAL1 LIKE BSEG-MENGE,      "本年累计数量(收入)
      G_PRICE_TOTAL1 TYPE P DECIMALS 6,  "本年价格(收入)
      G_AMOUNT_TOTAL1 LIKE BSEG-DMBTR,   "本年累计金额(收入)
      G_QTY_TOTAL2 LIKE BSEG-MENGE,      "本年累计数量(发出)
      G_PRICE_TOTAL2 TYPE P DECIMALS 6,  "本年价格(发出)
      G_AMOUNT_TOTAL2 LIKE BSEG-DMBTR.   "本年累计金额(发出)

*用于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.
  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.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6.
  WRITE: AT  A7   SY-VLINE.
  IF &7 <> 0.
    WRITE: AT  B7   &7.
  ELSE.
    WRITE: AT  B7   ''.
  ENDIF.
  WRITE: AT  A8   SY-VLINE.
  IF &8 <> 0.
    WRITE: AT  B8   &8 LEFT-JUSTIFIED.
  ELSE.
    WRITE: AT  B8   ''.
  ENDIF.
  WRITE: AT  A9   SY-VLINE.
  IF &9 <> 0.
    WRITE: AT  B9   &9.
  ELSE.
    WRITE: AT  B9   ''.
  ENDIF.
END-OF-DEFINITION.

DEFINE MACRO2.               "画表格
  WRITE: AT  A10   SY-VLINE.
  IF &1 <> 0.
    WRITE: AT  B10   &1.
  ELSE.
    WRITE: AT  B10   ''.
  ENDIF.
  WRITE: AT  A11   SY-VLINE.
  IF &2 <> 0.
    WRITE: AT  B11   &2 LEFT-JUSTIFIED.
  ELSE.
    WRITE: AT  B11   ''.
  ENDIF.
  WRITE: AT  A12   SY-VLINE.
  IF &3 <> 0.
    WRITE: AT  B12   &3.
  ELSE.
    WRITE: AT  B12   ''.
  ENDIF.
  WRITE: AT  A13   SY-VLINE.
  IF &4 <> 0.
    WRITE: AT  B13   &4.
  ELSE.
    WRITE: AT  B13   ''.
  ENDIF.
  WRITE: AT  A14   SY-VLINE.
  IF &5 <> 0.
    WRITE: AT  B14   &5 LEFT-JUSTIFIED.
  ELSE.
    WRITE: AT  B14   ''.
  ENDIF.
  WRITE: AT  A15   SY-VLINE.
  IF &6 <> 0.
    WRITE: AT  B15   &6.
  ELSE.
    WRITE: AT  B15   ''.
  ENDIF.
  WRITE: AT  A16   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 201.       "公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY
                 DEFAULT SY-DATUM+0(4) MEMORY ID 202."报表年度

    SELECT-OPTIONS : P_PERID FOR CKMI1-POPER OBLIGATORY
                     DEFAULT '1' TO SY-DATUM+4(2) MEMORY ID 203.      "报表期间
    SELECT-OPTIONS : P_MATNR FOR MARDH-MATNR OBLIGATORY MEMORY ID 204."物料编号
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_ALV 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_HT 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. F_READ_DATA.
  IF P_REPORT = 'X'.           "报表输出判断
    PERFORM. F_PRINT_REPORT.
  ELSEIF P_ALV = 'X'.
    PERFORM. F_PRINT_ALV.
  ENDIF.
************************************************************************
* END OF SELECTION
************************************************************************
END-OF-SELECTION.

************************************************************************
* TOP OF PAGE
************************************************************************
TOP-OF-PAGE.
*  PERFORM. F_HEAD.
************************************************************************
* END OF PAGE
************************************************************************
END-OF-PAGE.
*  PERFORM. F_BOTTOM.


*===============================子 例 程===============================*
*&---------------------------------------------------------------------*
*过滤条件有效性检查
*&---------------------------------------------------------------------*
FORM. F_CHECK_INPUT.
DATA: L_KALN1 LIKE MBEW-KALN1,
      L_FLAG(2).

  G_MONAT1 = P_PERID+4(2).
  G_MONAT2 = P_PERID+7(2).

  IF ( G_MONAT1 < '01' ) OR ( G_MONAT1 > '16' ) OR
   ( G_MONAT2 < '01' ) OR ( G_MONAT2 > '16' ).
    MESSAGE E101.    "该会计期间不存在!
  ENDIF.

*判断LOW < HIGH
  IF G_MONAT1 > G_MONAT2.
    MESSAGE E102.    "会计期间LOW值不能大于HIGH值!
  ENDIF.

  L_FLAG = ''.
  L_FLAG = P_MATNR+22(2).
*  IF L_FLAG = ''.
*判断是否存在该物料
  SELECT MATNR
    INTO MARC-MATNR
    FROM MARC
    WHERE MATNR IN P_MATNR
      AND WERKS = P_BUKRS.
  ENDSELECT.
  IF SY-SUBRC <> 0.
    MESSAGE E072. "该物料不存在该工厂中!
  ENDIF.

*判断该物料是否存在相关凭证记录
*  SELECT KALN1
*    FROM MBEW
*    INTO L_KALN1
*    WHERE MATNR IN P_MATNR
*      AND BWKEY = P_BUKRS
*      AND BWTAR = ''.
*  ENDSELECT.
*  SELECT KALNR
*    FROM CKMI1
*    INTO CKMI1-KALNR
*    WHERE KALNR = L_KALN1        "成本估算编号
*      AND BDATJ = P_RYEAR        "年度
*      AND POPER IN P_PERID       "过帐期间
*      AND ( AWTYP = 'MKPF'       "参考过程
*         OR AWTYP = 'PRCHG' )
*      AND AWREF <> ''            "参考凭证
*      AND AWORG = P_RYEAR.       "参照组织单位
*  ENDSELECT.
*
*  IF SY-SUBRC <> 0.
*    MESSAGE E073. "该物料无相关凭证记录!
*  ENDIF.
*  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
DATA:I TYPE I,
     FLAG1 TYPE I,
     L_BUDAT1 LIKE BKPF-BUDAT,
     L_BUDAT2 LIKE BKPF-BUDAT,
     L_QTY LIKE BSEG-MENGE,             "数量(期初)
     L_PRICE LIKE BSEG-DMBTR,           "价格(期初)
     L_AMOUNT LIKE BSEG-DMBTR,          "金额(期初)
     L_QTY_TOTAL1 LIKE BSEG-MENGE,      "本期合计数量(收入)
     L_PRICE_TOTAL1 TYPE P DECIMALS 6,  "本期价格(收入)
     L_AMOUNT_TOTAL1 LIKE BSEG-DMBTR,   "本期合计金额(收入)
     L_QTY_TOTAL2 LIKE BSEG-MENGE,      "本期合计数量(发出)
     L_PRICE_TOTAL2 TYPE P DECIMALS 6,  "本期价格(发出)
     L_AMOUNT_TOTAL2 LIKE BSEG-DMBTR.   "本期合计金额(发出)

  PERFORM. F_GET_DAY.

*--取物料列表,成本估算号
  SELECT MATNR KALN1
    FROM MBEW
    INTO CORRESPONDING FIELDS OF TABLE ITAB_TITLE
    WHERE MATNR IN P_MATNR
      AND BWKEY = P_BUKRS
      AND BWTAR = ''.

*-若物料无相关凭证记录,则删除该记录
  LOOP AT ITAB_TITLE.
    SELECT KALNR
      FROM CKMI1
      INTO CKMI1-KALNR
      WHERE KALNR = ITAB_TITLE-KALN1 "成本估算编号
        AND BDATJ = P_RYEAR          "年度
        AND POPER IN P_PERID         "过帐期间
        AND ( AWTYP = 'MKPF'         "参考过程
           OR AWTYP = 'PRCHG' )
        AND AWREF <> ''              "参考凭证
        AND AWORG = P_RYEAR.         "参照组织单位
    ENDSELECT.

    IF SY-SUBRC <> 0.
      DELETE ITAB_TITLE.
    ENDIF.
  ENDLOOP.

  PERFORM. F_GET_PRODNAME.

*分页显示各物料的明细账
  LOOP AT ITAB_TITLE.
    NEW-PAGE.         "针对不同物料进行分页
    PAGE_CURR = 1.    "计算页数
    I = 1.            "计算行数
    FLAG1 = 0.        "每个物料的第一行标识
    L_BUDAT1 = '00000000'.
    L_BUDAT2 = '00000000'.
    L_QTY_TOTAL1 = 0.
    L_AMOUNT_TOTAL1 = 0.
    L_PRICE_TOTAL1 = 0.
    L_QTY_TOTAL2 = 0.
    L_AMOUNT_TOTAL2 = 0.
    L_PRICE_TOTAL2 = 0.
    G_QTY_TOTAL1 = 0.
    G_AMOUNT_TOTAL1 = 0.
    G_PRICE_TOTAL1 = 0.
    G_QTY_TOTAL2 = 0.
    G_AMOUNT_TOTAL2 = 0.
    G_PRICE_TOTAL2 = 0.

    IF P_REPORT = 'X'.
      PERFORM. F_HEAD.
      PERFORM. F_LIST_HEAD.
    ENDIF.

    IF P_QT = 'X'.
      PERFORM. F_GET_DATA USING ITAB_TITLE-KALN1.
    ELSEIF P_HT = 'X'.
      PERFORM. F_GET_DATA USING ITAB_TITLE-KALN1.
      PERFORM. F_SAVE.
    ELSEIF P_SHOW = 'X'.
      PERFORM. F_GET_DATA_HT USING ITAB_TITLE-KALN1.
    ENDIF.

    "获取报表起始期间之前的收入、发出总数量及总金额
    PERFORM. F_GET_TOTAL_INI USING ITAB_TITLE-KALN1.

    LOOP AT ITAB_01.
      "换页处理
      PAGENUM = I MOD 50 .
      IF P_REPORT = 'X'.
      IF PAGENUM = 0.
        PAGE_CURR = PAGE_CURR + 1.

        MACRO1 '' '' '' '' '' '启下页' '' '' ''.
        MACRO2 '' '' '' '' '' ''.
        ULINE AT /A1(261).

        NEW-PAGE.
        PERFORM. F_HEAD.
        PERFORM. F_LIST_HEAD.

        MACRO1 '' '' '' '' '' '承上页' '' '' ''.
        MACRO2 '' '' '' '' '' ''.
        I = I + 2.
      ENDIF.
      ENDIF.

      L_BUDAT2 = ITAB_01-BUDAT.
      "期未处理
      IF ( L_BUDAT2+4(2) > L_BUDAT1+4(2) ) AND ( FLAG1 = 1 ).
        IF P_REPORT = 'X'.
          MACRO1 '' '' '' '' '' '本期合计' L_QTY_TOTAL1 L_PRICE_TOTAL1 L_AMOUNT_TOTAL1.
          MACRO2 L_QTY_TOTAL2 L_PRICE_TOTAL2 L_AMOUNT_TOTAL2 '' '' ''.

          MACRO1 '' '' '' '' '' '本年累计' G_QTY_TOTAL1 G_PRICE_TOTAL1 G_AMOUNT_TOTAL1.
          MACRO2 G_QTY_TOTAL2 G_PRICE_TOTAL2 G_AMOUNT_TOTAL2 '' '' ''.
        ELSEIF P_ALV = 'X'.
          ITAB_ALV-BUKRS = ''.
          ITAB_ALV-MATNR = ''.
          ITAB_ALV-MAKTX = ''.
          ITAB_ALV-GROES = ''.
          ITAB_ALV-MEINS = ''.
          ITAB_ALV-MATKL = ''.
          ITAB_ALV-WGBEZ = ''.
          ITAB_ALV-BUDAT = ''.
          ITAB_ALV-MBLNR = ''.
          ITAB_ALV-BELNR = ''.
          ITAB_ALV-BLART = ''.
          ITAB_ALV-BWART = ''.
          ITAB_ALV-BKTXT = '本期合计'.
          ITAB_ALV-MENGE1 = L_QTY_TOTAL1.
          ITAB_ALV-PRICE1 = L_PRICE_TOTAL1.
          ITAB_ALV-DMBTR1 = L_AMOUNT_TOTAL1.
          ITAB_ALV-MENGE2 = L_QTY_TOTAL2.
          ITAB_ALV-PRICE2 = L_PRICE_TOTAL2.
          ITAB_ALV-DMBTR2 = L_AMOUNT_TOTAL2.
          APPEND ITAB_ALV.

          ITAB_ALV-BUKRS = ''.
          ITAB_ALV-MATNR = ''.
          ITAB_ALV-MAKTX = ''.
          ITAB_ALV-GROES = ''.
          ITAB_ALV-MEINS = ''.
          ITAB_ALV-MATKL = ''.
          ITAB_ALV-WGBEZ = ''.
          ITAB_ALV-BUDAT = ''.
          ITAB_ALV-MBLNR = ''.
          ITAB_ALV-BELNR = ''.
          ITAB_ALV-BLART = ''.
          ITAB_ALV-BWART = ''.
          ITAB_ALV-BKTXT = '本年累计'.
          ITAB_ALV-MENGE1 = G_QTY_TOTAL1.
          ITAB_ALV-PRICE1 = G_PRICE_TOTAL1.
          ITAB_ALV-DMBTR1 = G_AMOUNT_TOTAL1.
          ITAB_ALV-MENGE2 = G_QTY_TOTAL2.
          ITAB_ALV-PRICE2 = G_PRICE_TOTAL2.
          ITAB_ALV-DMBTR2 = G_AMOUNT_TOTAL2.
          APPEND ITAB_ALV.
        ENDIF.

        I = I + 2.
        "变量初始化
        L_QTY_TOTAL1 = 0.
        L_AMOUNT_TOTAL1 = 0.
        L_PRICE_TOTAL1 = 0.
        L_QTY_TOTAL2 = 0.
        L_AMOUNT_TOTAL2 = 0.
        L_PRICE_TOTAL2 = 0.
      ENDIF.

      "期初处理
      IF L_BUDAT2+4(2) > L_BUDAT1+4(2).
        L_QTY = ITAB_01-MENGE0.
        L_AMOUNT = ITAB_01-DMBTR0.
        IF L_QTY <> 0.
          L_PRICE = L_AMOUNT / L_QTY.
        ELSE.
          L_PRICE = 0.
        ENDIF.

        IF P_REPORT = 'X'.
          IF FLAG1 = 1.
            ULINE AT /A1(261).
          ENDIF.
          MACRO1 '' '' '' '' '' '期初结存' '' '' ''.
          MACRO2 '' '' '' L_QTY L_PRICE L_AMOUNT.
        ELSEIF P_ALV = 'X'.
          IF FLAG1 = 0.
            ITAB_ALV-BUKRS = P_BUKRS.
            ITAB_ALV-MATNR = ITAB_TITLE-MATNR.
            ITAB_ALV-MAKTX = ITAB_TITLE-MAKTX.
            ITAB_ALV-GROES = ITAB_TITLE-GROES.
            ITAB_ALV-MEINS = ITAB_TITLE-MEINS.
            ITAB_ALV-MATKL = ITAB_TITLE-MATKL.
            ITAB_ALV-WGBEZ = ITAB_TITLE-WGBEZ.
          ELSE.
            ITAB_ALV-BUKRS = ''.
            ITAB_ALV-MATNR = ''.
            ITAB_ALV-MAKTX = ''.
            ITAB_ALV-GROES = ''.
            ITAB_ALV-MEINS = ''.
            ITAB_ALV-MATKL = ''.
            ITAB_ALV-WGBEZ = ''.
          ENDIF.
          ITAB_ALV-BKTXT = '期初结存'.
          ITAB_ALV-MENGE3 = L_QTY.
          ITAB_ALV-PRICE3 = L_PRICE.
          ITAB_ALV-DMBTR3 = L_AMOUNT.
          APPEND ITAB_ALV.
        ENDIF.

        L_BUDAT1 = ITAB_01-BUDAT.
        I = I + 1.
      ENDIF.
      FLAG1 = 1.

      "明细数据显示
      IF P_REPORT = 'X'.
        MACRO1 ITAB_01-BUDAT ITAB_01-MBLNR ITAB_01-BELNR ITAB_01-BLART ITAB_01-BWART
               ITAB_01-BKTXT ITAB_01-MENGE1 ITAB_01-PRICE1 ITAB_01-DMBTR1.
        MACRO2 ITAB_01-MENGE2 ITAB_01-PRICE2 ITAB_01-DMBTR2
               ITAB_01-MENGE3 ITAB_01-PRICE3 ITAB_01-DMBTR3.
      ELSEIF P_ALV = 'X'.
        ITAB_ALV-BUKRS = ''.
        ITAB_ALV-MATNR = ''.
        ITAB_ALV-MAKTX = ''.
        ITAB_ALV-GROES = ''.
        ITAB_ALV-MEINS = ''.
        ITAB_ALV-MATKL = ''.
        ITAB_ALV-WGBEZ = ''.
        ITAB_ALV-BUDAT = ITAB_01-BUDAT.
        ITAB_ALV-MBLNR = ITAB_01-MBLNR.
        ITAB_ALV-BELNR = ITAB_01-BELNR.
        ITAB_ALV-BLART = ITAB_01-BLART.
        ITAB_ALV-BWART = ITAB_01-BWART.
        ITAB_ALV-BKTXT = ITAB_01-BKTXT.
        ITAB_ALV-MENGE1 = ITAB_01-MENGE1.
        ITAB_ALV-PRICE1 = ITAB_01-PRICE1.
        ITAB_ALV-DMBTR1 = ITAB_01-DMBTR1.
        ITAB_ALV-MENGE2 = ITAB_01-MENGE2.
        ITAB_ALV-PRICE2 = ITAB_01-PRICE2.
        ITAB_ALV-DMBTR2 = ITAB_01-DMBTR2.
        ITAB_ALV-MENGE3 = ITAB_01-MENGE3.
        ITAB_ALV-PRICE3 = ITAB_01-PRICE3.
        ITAB_ALV-DMBTR3 = ITAB_01-DMBTR3.
        APPEND ITAB_ALV.
      ENDIF.

      "计算本期总数量及总金额
      L_QTY_TOTAL1 = L_QTY_TOTAL1 + ITAB_01-MENGE1.
      L_AMOUNT_TOTAL1 = L_AMOUNT_TOTAL1 + ITAB_01-DMBTR1.
      IF L_QTY_TOTAL1 <> 0.
        L_PRICE_TOTAL1 = L_AMOUNT_TOTAL1 / L_QTY_TOTAL1.
      ELSE.
        L_PRICE_TOTAL1 = 0.
      ENDIF.
      L_QTY_TOTAL2 = L_QTY_TOTAL2 + ITAB_01-MENGE2.
      L_AMOUNT_TOTAL2 = L_AMOUNT_TOTAL2 + ITAB_01-DMBTR2.
      IF L_QTY_TOTAL2 <> 0.
        L_PRICE_TOTAL2 = L_AMOUNT_TOTAL2 / L_QTY_TOTAL2.
      ELSE.
        L_PRICE_TOTAL2 = 0.
      ENDIF.

      "计算本年合计总数量及总金额
      G_QTY_TOTAL1 = G_QTY_TOTAL1 + ITAB_01-MENGE1.
      G_AMOUNT_TOTAL1 = G_AMOUNT_TOTAL1 + ITAB_01-DMBTR1.
      IF G_QTY_TOTAL1 <> 0.
        G_PRICE_TOTAL1 = G_AMOUNT_TOTAL1 / G_QTY_TOTAL1.
      ELSE.
        G_PRICE_TOTAL1 = 0.
      ENDIF.
      G_QTY_TOTAL2 = G_QTY_TOTAL2 + ITAB_01-MENGE2.
      G_AMOUNT_TOTAL2 = G_AMOUNT_TOTAL2 + ITAB_01-DMBTR2.
      IF G_QTY_TOTAL2 <> 0.
        G_PRICE_TOTAL2 = G_AMOUNT_TOTAL2 / G_QTY_TOTAL2.
      ELSE.
        G_PRICE_TOTAL2 = 0.
      ENDIF.

      I = I + 1.
    ENDLOOP.

    IF P_REPORT = 'X'.
      MACRO1 '' '' '' '' '' '本期合计' L_QTY_TOTAL1 L_PRICE_TOTAL1 L_AMOUNT_TOTAL1.
      MACRO2 L_QTY_TOTAL2 L_PRICE_TOTAL2 L_AMOUNT_TOTAL2 '' '' ''.
      MACRO1 '' '' '' '' '' '本年累计' G_QTY_TOTAL1 G_PRICE_TOTAL1 G_AMOUNT_TOTAL1.
      MACRO2 G_QTY_TOTAL2 G_PRICE_TOTAL2 G_AMOUNT_TOTAL2 '' '' ''.
      ULINE.
      PERFORM. F_BOTTOM.
    ELSEIF P_ALV = 'X'.
      ITAB_ALV-BUKRS = ''.
      ITAB_ALV-MATNR = ''.
      ITAB_ALV-MAKTX = ''.
      ITAB_ALV-GROES = ''.
      ITAB_ALV-MEINS = ''.
      ITAB_ALV-MATKL = ''.
      ITAB_ALV-WGBEZ = ''.
      ITAB_ALV-BUDAT = ''.
      ITAB_ALV-MBLNR = ''.
      ITAB_ALV-BELNR = ''.
      ITAB_ALV-BLART = ''.
      ITAB_ALV-BWART = ''.
      ITAB_ALV-BKTXT = '本期合计'.
      ITAB_ALV-MENGE1 = L_QTY_TOTAL1.
      ITAB_ALV-PRICE1 = L_PRICE_TOTAL1.
      ITAB_ALV-DMBTR1 = L_AMOUNT_TOTAL1.
      ITAB_ALV-MENGE2 = L_QTY_TOTAL2.
      ITAB_ALV-PRICE2 = L_PRICE_TOTAL2.
      ITAB_ALV-DMBTR2 = L_AMOUNT_TOTAL2.
      APPEND ITAB_ALV.

      ITAB_ALV-BUKRS = ''.
      ITAB_ALV-MATNR = ''.
      ITAB_ALV-MAKTX = ''.
      ITAB_ALV-GROES = ''.
      ITAB_ALV-MEINS = ''.
      ITAB_ALV-MATKL = ''.
      ITAB_ALV-WGBEZ = ''.
      ITAB_ALV-BUDAT = ''.
      ITAB_ALV-MBLNR = ''.
      ITAB_ALV-BELNR = ''.
      ITAB_ALV-BLART = ''.
      ITAB_ALV-BWART = ''.
      ITAB_ALV-BKTXT = '本期合计'.
      ITAB_ALV-MENGE1 = G_QTY_TOTAL1.
      ITAB_ALV-PRICE1 = G_PRICE_TOTAL1.
      ITAB_ALV-DMBTR1 = G_AMOUNT_TOTAL1.
      ITAB_ALV-MENGE2 = G_QTY_TOTAL2.
      ITAB_ALV-PRICE2 = G_PRICE_TOTAL2.
      ITAB_ALV-DMBTR2 = G_AMOUNT_TOTAL2.
      APPEND ITAB_ALV.
    ENDIF.
  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*获取数据
*&---------------------------------------------------------------------*
FORM. F_GET_DATA USING P_KALN1.
  CLEAR ITAB_01.
  REFRESH ITAB_01.
  SELECT LBKUM AS MENGE0         "总库存量
         SALK3 AS DMBTR0         "总价值
         STPRS AS PRICE          "标准价格
         MENGE                   "出入库数量
         WRBTR AS DMBTR          "出入库金额
         AWREF AS MBLNR          "物料凭证号
         DATUM                   "
         UZEIT                   "
         AWTYP                   "参考过程
    FROM CKMI1
    INTO CORRESPONDING FIELDS OF TABLE ITAB_01
    WHERE KALNR = P_KALN1        "成本估算编号
      AND BDATJ = P_RYEAR        "年度
      AND POPER IN P_PERID       "过帐期间
      AND ( AWTYP = 'MKPF'       "参考过程
         OR AWTYP = 'PRCHG' )
      AND AWREF <> ''            "参考凭证
      AND AWORG = P_RYEAR        "参照组织单位
    ORDER BY DATUM UZEIT.

*-取凭证中的记帐日期、抬头(摘要)
  CLEAR ITAB_TEMP.
  REFRESH ITAB_TEMP.
  LOOP AT ITAB_01.
    SELECT BUDAT    "过账日期
           BKTXT    "凭证抬头文本
      INTO CORRESPONDING FIELDS OF TABLE ITAB_TEMP
      FROM MKPF
      WHERE MBLNR = ITAB_01-MBLNR
        AND MJAHR = P_RYEAR.

    LOOP AT ITAB_TEMP.
      ITAB_01-BUDAT = ITAB_TEMP-BUDAT.
      ITAB_01-BKTXT = ITAB_TEMP-BKTXT.
      MODIFY ITAB_01.
    ENDLOOP.
  ENDLOOP.

*-取移动类型
  LOOP AT ITAB_01.
    SELECT BWART
      INTO ITAB_01-BWART
      FROM MSEG
      WHERE MBLNR = ITAB_01-MBLNR
        AND MJAHR = P_RYEAR
        AND ZEILE = '1'.
    ENDSELECT.
    MODIFY ITAB_01.
  ENDLOOP.

*-判断是入库还是出库
  LOOP AT ITAB_01.
    ITAB_01-MENGE3 = ITAB_01-MENGE0 + ITAB_01-MENGE.
    ITAB_01-DMBTR3 = ITAB_01-DMBTR0 + ITAB_01-DMBTR.
    IF ITAB_01-MENGE3 <> 0.
      ITAB_01-PRICE3 = ITAB_01-DMBTR3 / ITAB_01-MENGE3.
    ELSE.
      ITAB_01-PRICE3 = ''.
    ENDIF.

    IF ITAB_01-MENGE > 0.
      ITAB_01-MENGE1 = ITAB_01-MENGE.
      ITAB_01-DMBTR1 = ITAB_01-DMBTR.
      ITAB_01-PRICE1 = ITAB_01-DMBTR1 / ITAB_01-MENGE1.
    ELSEIF ITAB_01-MENGE < 0.
      ITAB_01-MENGE2 = 0 - ITAB_01-MENGE.
      ITAB_01-DMBTR2 = 0 - ITAB_01-DMBTR.
      ITAB_01-PRICE2 = ITAB_01-DMBTR2 / ITAB_01-MENGE2.
    ELSEIF ITAB_01-MENGE = 0.
      ITAB_01-MENGE1 = ITAB_01-MENGE.
      ITAB_01-DMBTR1 = ITAB_01-DMBTR.
    ENDIF.
    MODIFY ITAB_01.
  ENDLOOP.

*-取会计凭证号及会计凭证类型
  PERFORM. F_GET_KJPJ.

ENDFORM.
*&---------------------------------------------------------------------*
*取会计凭证号及会计凭证类型
*----------------------------------------------------------------------*
FORM. F_GET_KJPJ.
DATA: L_AWKEY LIKE BKPF-AWKEY,
      L_LTEXT LIKE T003T-LTEXT.

  CLEAR ITAB_TEMP.
  REFRESH ITAB_TEMP.
  LOOP AT ITAB_01.
    CONCATENATE ITAB_01-MBLNR P_RYEAR INTO L_AWKEY.
    SELECT BLART
           BELNR
           BUDAT
           AWKEY
       INTO CORRESPONDING FIELDS OF TABLE ITAB_TEMP
       FROM BKPF
       WHERE BUKRS = P_BUKRS
         AND GJAHR = P_RYEAR
         AND BELNR <> ''
         AND AWKEY = L_AWKEY
       ORDER BY AWKEY.

    LOOP AT ITAB_TEMP.
      ITAB_01-BLART = ITAB_TEMP-BLART.
      ITAB_01-BELNR = ITAB_TEMP-BELNR.
      ITAB_01-BUDAT = ITAB_TEMP-BUDAT.
    ENDLOOP.
    MODIFY ITAB_01.
  ENDLOOP.

*-由凭证类型得其名称
  LOOP AT ITAB_01.
    SELECT LTEXT
      INTO L_LTEXT
      FROM T003T
      WHERE SPRAS = '1'
        AND BLART = ITAB_01-BLART.
    ENDSELECT.

    CONCATENATE ITAB_01-BLART '(' L_LTEXT ')' INTO ITAB_01-BLART.
    MODIFY ITAB_01.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*获取报表起始期间之前的收入、发出总数量及总金额
*&---------------------------------------------------------------------*
FORM. F_GET_TOTAL_INI USING P_KALN1.
DATA: L_PERID1 LIKE CKMI1-POPER,
      L_PERID2 LIKE CKMI1-POPER.

  L_PERID1 = '01'.
  L_PERID2 = P_PERID+4(2).

  CLEAR ITAB_TEMP.
  REFRESH ITAB_TEMP.
  SELECT LBKUM AS MENGE0         "总库存量
         SALK3 AS DMBTR0         "总价值
         STPRS AS PRICE          "标准价格
         MENGE                   "出入库数量
         WRBTR AS DMBTR          "出入库金额
         AWREF AS MBLNR          "物料凭证号
         DATUM
         UZEIT
    FROM CKMI1
    INTO CORRESPONDING FIELDS OF TABLE ITAB_TEMP
    WHERE KALNR = P_KALN1        "成本估算编号
      AND BDATJ = P_RYEAR        "年度
      AND POPER < L_PERID2       "过帐期间
      AND AWTYP = 'MKPF'         "参考过程
      AND AWREF <> ''            "参考凭证
      AND AWORG = P_RYEAR        "参照组织单位
    ORDER BY DATUM UZEIT.

  LOOP AT ITAB_TEMP.
    IF ITAB_TEMP-MENGE >= 0.
      G_QTY_TOTAL1 = G_QTY_TOTAL1 + ITAB_TEMP-MENGE.
      G_AMOUNT_TOTAL1 = G_AMOUNT_TOTAL1 + ITAB_TEMP-DMBTR.
    ELSE.
      G_QTY_TOTAL2 = G_QTY_TOTAL2 + ITAB_TEMP-MENGE.
      G_AMOUNT_TOTAL2 = G_AMOUNT_TOTAL2 + ITAB_TEMP-DMBTR.
    ENDIF.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*获取物料名称,规格,单位,物料组,物料组描述
*&---------------------------------------------------------------------*
FORM. F_GET_PRODNAME.
  LOOP AT ITAB_TITLE.
    "取物料名称
    SELECT MAKTX
      INTO ITAB_TITLE-MAKTX
      FROM MAKT
      WHERE SPRAS = '1'
        AND MATNR = ITAB_TITLE-MATNR.
    ENDSELECT.

    "取物料规格,单位,物料组
    SELECT GROES
           MEINS
           MATKL
      FROM MARA
      INTO CORRESPONDING FIELDS OF TABLE ITAB1
      WHERE MATNR = ITAB_TITLE-MATNR.

    LOOP AT ITAB1.
      ITAB_TITLE-GROES = ITAB1-GROES.
      ITAB_TITLE-MEINS = ITAB1-MEINS.
      ITAB_TITLE-MATKL = ITAB1-MATKL.
    ENDLOOP.

    "取物料组描述
    IF ITAB_TITLE-MATKL <> ''.
      SELECT WGBEZ
        INTO ITAB_TITLE-WGBEZ
        FROM T023T
        WHERE SPRAS = '1'
          AND MATKL = ITAB_TITLE-MATKL.
      ENDSELECT.
    ENDIF.

    MODIFY ITAB_TITLE.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*数据保存
*----------------------------------------------------------------------*
FORM. F_SAVE.
DATA: L_ZNO TYPE I.

  L_ZNO = 0.
  CLEAR ITAB_HT.
  REFRESH ITAB_HT.
  LOOP AT ITAB_01.
    L_ZNO = L_ZNO + 1.
    ITAB_HT-ZNO = L_ZNO.
    ITAB_HT-BUKRS = P_BUKRS.
    ITAB_HT-RYEAR = P_RYEAR.
    ITAB_HT-RPMAX = ''.
    ITAB_HT-MATNR = ITAB_TITLE-MATNR.
    ITAB_HT-KALN1 = ITAB_TITLE-KALN1.
    ITAB_HT-BUDAT = ITAB_01-BUDAT.
    ITAB_HT-MBLNR = ITAB_01-MBLNR.
    ITAB_HT-BELNR = ITAB_01-BELNR.
    ITAB_HT-BLART = ITAB_01-BLART.
    ITAB_HT-BWART = ITAB_01-BWART.
    ITAB_HT-BKTXT = ITAB_01-BKTXT.
    ITAB_HT-MAKTX = ITAB_TITLE-MAKTX.
    ITAB_HT-GROES = ITAB_TITLE-GROES.
    ITAB_HT-MEINS = ITAB_TITLE-MEINS.
    ITAB_HT-MATKL = ITAB_TITLE-MATKL.
    ITAB_HT-WGBEZ = ITAB_TITLE-WGBEZ.
    ITAB_HT-ZMENGE1 = ITAB_01-MENGE1.
    ITAB_HT-ZDMBTR1 = ITAB_01-DMBTR1.
    ITAB_HT-ZPRICE1 = ITAB_01-PRICE1.
    ITAB_HT-ZMENGE2 = ITAB_01-MENGE2.
    ITAB_HT-ZDMBTR2 = ITAB_01-DMBTR2.
    ITAB_HT-ZPRICE2 = ITAB_01-PRICE2.
    ITAB_HT-ZMENGE3 = ITAB_01-MENGE3.
    ITAB_HT-ZDMBTR3 = ITAB_01-DMBTR3.
    ITAB_HT-ZPRICE3 = ITAB_01-PRICE3.
    APPEND ITAB_HT.
  ENDLOOP.

  LOOP AT ITAB_HT.
    SELECT *
      FROM ZFI07
      INTO CORRESPONDING FIELDS OF TABLE ITAB_HT2
      WHERE ZNO = ITAB_HT-ZNO
        AND BUKRS = P_BUKRS
        AND RYEAR = P_RYEAR
        AND RPMAX = ''
        AND MATNR = ITAB_HT-MATNR
        AND KALN1 = ITAB_HT-KALN1
        AND BUDAT = ITAB_HT-BUDAT
        AND MBLNR = ITAB_HT-MBLNR.

    IF SY-SUBRC = 0.
      "更新相同的记录
      LOOP AT ITAB_HT2.
         UPDATE ZFI07
           SET BELNR = ITAB_HT-BELNR
               BLART = ITAB_HT-BLART
               BWART = ITAB_HT-BWART
               BKTXT = ITAB_HT-BKTXT
               MAKTX = ITAB_HT-MAKTX
               GROES = ITAB_HT-GROES
               MEINS = ITAB_HT-MEINS
               MATKL = ITAB_HT-MATKL
               WGBEZ = ITAB_HT-WGBEZ
               ZMENGE1 = ITAB_HT-ZMENGE1
               ZDMBTR1 = ITAB_HT-ZDMBTR1
               ZPRICE1 = ITAB_HT-ZPRICE1
               ZMENGE2 = ITAB_HT-ZMENGE2
               ZDMBTR2 = ITAB_HT-ZDMBTR2
               ZPRICE2 = ITAB_HT-ZPRICE2
               ZMENGE3 = ITAB_HT-ZMENGE3
               ZDMBTR3 = ITAB_HT-ZDMBTR3
               ZPRICE3 = ITAB_HT-ZPRICE3
               AEDAT = SY-DATUM
               AENAM = SY-UNAME
         WHERE ZNO = ITAB_HT-ZNO
           AND BUKRS = P_BUKRS
           AND RYEAR = P_RYEAR
           AND RPMAX = ''
           AND MATNR = ITAB_HT-MATNR
           AND KALN1 = ITAB_HT-KALN1
           AND BUDAT = ITAB_HT-BUDAT
           AND MBLNR = ITAB_HT-MBLNR.
      ENDLOOP.
    ELSE.
      "新增记录
      ITAB_HT-ERDAT = SY-DATUM.
      ITAB_HT-AEDAT = SY-DATUM.
      ITAB_HT-ERNAM = SY-UNAME.
      ITAB_HT-AENAM = SY-UNAME.

      INSERT INTO ZFI07
        VALUES ITAB_HT .
    ENDIF.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*后台数据读取
*----------------------------------------------------------------------*
FORM. F_GET_DATA_HT USING P_KALN2.
  SELECT BUKRS KALN1 BUDAT MBLNR BELNR BLART BWART BKTXT GROES MEINS
         MATKL WGBEZ
         ZMENGE1 AS MENGE1
         ZDMBTR1 AS DMBTR1
         ZPRICE1 AS PRICE1
         ZMENGE2 AS MENGE2
         ZDMBTR2 AS DMBTR2
         ZPRICE2 AS PRICE2
         ZMENGE3 AS MENGE3
         ZDMBTR3 AS DMBTR3
         ZPRICE3 AS PRICE3
  FROM ZFI07
  INTO CORRESPONDING FIELDS OF TABLE ITAB_01
  WHERE BUKRS = P_BUKRS
    AND RYEAR = P_RYEAR
    AND RPMAX = ''
    AND KALN1 = P_KALN2
    AND BUDAT >= G_DATE1
    AND BUDAT <= G_DATE2.

ENDFORM.
*&---------------------------------------------------------------------*
*各月天数判断
*----------------------------------------------------------------------*
FORM. F_GET_DAY.
DATA: L_DAY(2),
      L_MOD TYPE I,
      L_MONAT1 TYPE D,
      L_MONAT2 TYPE D.

 L_MONAT1 = P_PERID+4(2).
 L_MONAT2 = P_PERID+7(2).

 IF L_MONAT2 = '04' OR L_MONAT2 = '06' OR
   L_MONAT2 = '09' OR L_MONAT2 = '11'.
   L_DAY = '30'.
 ELSEIF L_MONAT2 = '02'.
   L_MOD = P_RYEAR MOD 4.
   IF L_MOD = 0.
     L_DAY = '29'.
   ELSE.
     L_DAY = '28'.
   ENDIF.
 ELSE.
   L_DAY = '31'.
 ENDIF.
 CONDENSE L_DAY NO-GAPS.

 CONCATENATE P_RYEAR L_MONAT1 '01' INTO G_DATE1.
 CONCATENATE P_RYEAR L_MONAT2 L_DAY INTO G_DATE2.
ENDFORM.                    "CAL_DAY
*&---------------------------------------------------------------------*
*普通报表格式的打印
*&---------------------------------------------------------------------*
FORM. F_PRINT_REPORT.

ENDFORM.
*&---------------------------------------------------------------------*
*&      单据表头显示
*&---------------------------------------------------------------------*
FORM. F_HEAD.
DATA: L_COMP(30),
      L_TITLE1(30),
      L_MONAT1(2),
      L_MONAT2(2),
      L_TEMP(2).

  "取公司名称
  IF P_BUKRS = '1000'.
    L_COMP = '单位名称:厦门松霖卫浴有限公司'.
  ELSEIF P_BUKRS = '2000'.
    L_COMP = '单位名称:厦门益周塑胶有限公司'.
  ELSEIF P_BUKRS = '3000'.
    L_COMP = '单位名称:厦门易洁卫浴有限公司'.
  ELSEIF P_BUKRS = '4000'.
    L_COMP = '单位名称:厦门玩铜五金有限公司'.
  ELSEIF P_BUKRS = '3000'.
    L_COMP = '单位名称:厦门松霖科技有限公司'.
  ENDIF.

  L_MONAT1 = G_MONAT1.
  L_MONAT2 = G_MONAT2.
  L_TEMP = PAGE_CURR.
  WRITE: 127 '存货明细账'.
  SKIP.
  WRITE

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

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

注册时间:2006-03-01

  • 博文量
    43
  • 访问量
    33244