首页 > 代码库 > ZFIR054-现金流量表

ZFIR054-现金流量表

***********************************************************************
* Title           : ZFIR102                                           *
* Application     : FI                                               *
* Subject         : 现金流量表                                        *
* Requested by    : 财务部                                            *
* Execution       : any time                                          *
* Ref no:         :                                                   *
* Author          : ABAP30/ABAP20                                     *
* Req Date        : 20151103                                          *
***********************************************************************
*                                                                     *
***********************************************************************
***********************************************************************
* 增强1.FBCJ(现金日记账) 财务凭证过账保存BSEG同时,用业务交易从自建表 *
* 关联原因代码将原因代码直接存入BSEG表,                              *
* GBB1 替代实现,                                                     *
*     2.业务交易 原因代码关联表 ZFIT102.                              *
*                                                                     *
*1.取数:按照 年度,公司代码,科目 = 1001*&1002*.                      *
*  会计期间 取数公司代码货币计金额(BSEG-DMBTR)根据项目类型对应原因代码
*  按类型合计DMBTR,
*
*2.以固定格式,ALV list显示报表( 6列、35行 )
*
***********************************************************************
* MODIFICATIONS (latest entry at the top)                             *
* ------------------------------------------------------------------- *
* REL  DATE    NAME (COMPANY)   DESCRIPTION               TASK-NO     *
* ---  ----    ---- ---------   -----------               -------     *
*                                                                     *
***********************************************************************
REPORT ZFIR054 MESSAGE-ID ZMM_001
               LINE-COUNT 130
               LINE-SIZE  300.



*----------------------------------------------------------------------
*                          TYPE-POOLS
*----------------------------------------------------------------------
TYPE-POOLS: SLIS.

"相关表引用声明
TABLES:BKPF,
       BSEG,
       T001,
       TF189.



*----------------------------------------------------------------------
*                          Internal table
*----------------------------------------------------------------------
*&ALV
DATA: BEGIN OF GT_DATA OCCURS 0,
        TEXT_XM TYPE STRING,
        LINE_XM TYPE STRING,
        DMBTR   LIKE BSEG-DMBTR,"项目金额-BSEG
        TEXT_BC TYPE STRING,
        LINE_BC TYPE STRING,
        HSL00   LIKE FAGLFLEXT-HSL01,"补充金额-FAGLFLEXT
        SEL TYPE C,
      END OF GT_DATA.
DATA:WA_DATA LIKE GT_DATA.
DATA: BEGIN OF GT_REGUP OCCURS 0,
  VBLNR TYPE REGUP-VBLNR,
  BUKRS TYPE  REGUP-BUKRS,
*  VBLNR TYPE REGUP-VBLNR,
  BELNR TYPE REGUP-BELNR,
  GJAHR TYPE REGUP-GJAHR,
  BUZEI TYPE REGUP-BUZEI,
  DMBTR TYPE REGUP-DMBTR,
*  vbeln type
END OF GT_REGUP.
DATA:LT_REGUP_ADD LIKE TABLE OF GT_REGUP WITH HEADER LINE.
*&现金流量表-项目
DATA:BEGIN OF GT_BSEG OCCURS 0,
      BUKRS LIKE BSEG-BUKRS,
      BELNR LIKE BSEG-BELNR,
      BUZEI LIKE BSEG-BUZEI,
      GJAHR LIKE BSEG-GJAHR,"会计年度
      RSTGR LIKE BSEG-RSTGR,"原因代码
      HKONT LIKE BSEG-HKONT,"科目
      SHKZG LIKE BSEG-SHKZG,"借贷方(S(+) H(-))
      DMBTR LIKE BSEG-DMBTR,"项目金额-BSEG
      EBELN LIKE BSEG-EBELN,
*BUKRS
*BELNR
*GJAHR
*BUZEI
*&->add on 20160324 BY ABAP30 req by fi_ljj.
  KOART LIKE BSEG-KOART,
  LIFNR LIKE BSEG-LIFNR,
*&->end add.
    END OF GT_BSEG.
DATA:WA_BSEG LIKE GT_BSEG.

*&1000版本
DATA:BEGIN OF GT_1000 OCCURS 0,
      ZZNUMB  LIKE ZFI030_TEXT-ZZNUMB,
      ZZTEXT  LIKE ZFI030_TEXT-ZZTEXT,
      ZZSUM   LIKE ZFI030_TEXT-ZZSUM,
      ZZTXPE  LIKE ZFI030_TEXT-ZZTXPE,
      HSLVT   LIKE FAGLFLEXT-HSLVT,
      HSL01   LIKE FAGLFLEXT-HSL01,
      HSL02   LIKE FAGLFLEXT-HSL01,
      HSL03   LIKE FAGLFLEXT-HSL01,
      HSL04   LIKE FAGLFLEXT-HSL01,
      HSL05   LIKE FAGLFLEXT-HSL01,
      HSL06   LIKE FAGLFLEXT-HSL01,
      HSL07   LIKE FAGLFLEXT-HSL01,
      HSL08   LIKE FAGLFLEXT-HSL01,
      HSL09   LIKE FAGLFLEXT-HSL01,
      HSL10   LIKE FAGLFLEXT-HSL01,
      HSL11   LIKE FAGLFLEXT-HSL01,
      HSL12   LIKE FAGLFLEXT-HSL01,
      HSL01_Y LIKE FAGLFLEXT-HSL01,
      LIN     TYPE SY-TABIX,
    END OF GT_1000.
DATA:WA_1000 LIKE GT_1000.

DATA: BEGIN OF GT_FAGT OCCURS 0,
       RYEAR LIKE FAGLFLEXT-RYEAR,
       RACCT LIKE FAGLFLEXT-RACCT,
       DRCRK LIKE FAGLFLEXT-DRCRK,"借方/贷方标识
       HSLVT LIKE FAGLFLEXT-HSLVT,
       HSL01 LIKE FAGLFLEXT-HSLVT,
       HSL02 LIKE FAGLFLEXT-HSLVT,
       HSL03 LIKE FAGLFLEXT-HSLVT,
       HSL04 LIKE FAGLFLEXT-HSLVT,
       HSL05 LIKE FAGLFLEXT-HSLVT,
       HSL06 LIKE FAGLFLEXT-HSLVT,
       HSL07 LIKE FAGLFLEXT-HSLVT,
       HSL08 LIKE FAGLFLEXT-HSLVT,
       HSL09 LIKE FAGLFLEXT-HSLVT,
       HSL10 LIKE FAGLFLEXT-HSLVT,
       HSL11 LIKE FAGLFLEXT-HSLVT,
       HSL12 LIKE FAGLFLEXT-HSLVT,
       HSL13 LIKE FAGLFLEXT-HSLVT,
       HSL14 LIKE FAGLFLEXT-HSLVT,
       HSL15 LIKE FAGLFLEXT-HSLVT,
       HSL16 LIKE FAGLFLEXT-HSLVT,
      END OF GT_FAGT.
DATA:WA_FAGT LIKE GT_FAGT.

*&ADD
DATA:BEGIN OF GT_TAB OCCURS 0,
       ZZSUM   LIKE ZFI030-ZZSUM,   "汇总栏位
       ZZNUMB  LIKE ZFI030-ZZNUMB,  "栏位编号
       HKONT   LIKE ZFI030-HKONT,   "总账科目
       HSLVT   LIKE FAGLFLEXT-HSLVT,
       HSL01   LIKE FAGLFLEXT-HSL01,
       HSL02   LIKE FAGLFLEXT-HSL01,
       HSL03   LIKE FAGLFLEXT-HSL01,
       HSL04   LIKE FAGLFLEXT-HSL01,
       HSL05   LIKE FAGLFLEXT-HSL01,
       HSL06   LIKE FAGLFLEXT-HSL01,
       HSL07   LIKE FAGLFLEXT-HSL01,
       HSL08   LIKE FAGLFLEXT-HSL01,
       HSL09   LIKE FAGLFLEXT-HSL01,
       HSL10   LIKE FAGLFLEXT-HSL01,
       HSL11   LIKE FAGLFLEXT-HSL01,
       HSL12   LIKE FAGLFLEXT-HSL01,
       HSL01_Y LIKE FAGLFLEXT-HSL01,
* DMBTR1 LIKE FAGLFLEXT-HSLVT, "当月
* DMBTR2 LIKE FAGLFLEXT-HSLVT, "本年
     END OF GT_TAB.
DATA:WA_TAB LIKE GT_TAB.
DATA:GT_SUM_C LIKE TABLE OF GT_TAB WITH HEADER LINE,
     GT_SUM_S LIKE TABLE OF GT_TAB WITH HEADER LINE.


FIELD-SYMBOLS:<FN1>,
              <FN2>,
              <FN1_QC>,
              <FN2_QC>.
DATA:GV_BZ_HSL00 LIKE FAGLFLEXT-HSL01.

*----------------------------------------------------------------------
*                          Variants
*----------------------------------------------------------------------
DATA: G_LEN   TYPE I,   "内表行数
      G_TABIX TYPE SY-TABIX.

*---------------------------------------------------------------------*
*  Data parameters for alv report use
*---------------------------------------------------------------------*
DATA: G_PROGRAM    TYPE SY-REPID,
      GS_LAYOUT    TYPE SLIS_LAYOUT_ALV,
      GS_LAYOUT1   TYPE SLIS_LAYOUT_ALV,
      GT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV,
      GS_FIELDCAT  LIKE LINE OF GT_FIELDCAT,
      GT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
      GS_FIELDCAT1 LIKE LINE OF GT_FIELDCAT,
      WA_FIELDCAT  TYPE SLIS_FIELDCAT_ALV,
      WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV,
      IT_EVENTS    TYPE SLIS_T_EVENT WITH HEADER LINE,
      GT_EVENT     TYPE SLIS_T_EVENT,
      WA_EVENT     TYPE SLIS_ALV_EVENT.
DATA: GT_LIST_TOP_OF_PAGE     TYPE SLIS_T_LISTHEADER.
DATA: GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
                              VALUE ALV_TOP_OF_PAGE.

************************************************************************
*             Select Screen                                            *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

PARAMETERS:P_BUKRS LIKE BKPF-BUKRS OBLIGATORY DEFAULT 3000,
           P_GJAHR LIKE BKPF-GJAHR DEFAULT SY-DATUM(4) OBLIGATORY.
SELECT-OPTIONS:S_MONAT FOR BKPF-MONAT DEFAULT SY-DATUM+4(2) NO-EXTENSION OBLIGATORY MODIF ID R01.
PARAMETERS:P_MONAT LIKE BKPF-MONAT DEFAULT SY-DATUM+4(2) NO-DISPLAY."MODIF ID R02
PARAMETERS:P_PRINT AS CHECKBOX MODIF ID R02.
PARAMETERS:P_EXCEL AS CHECKBOX MODIF ID R02.
PARAMETERS:FN1 LIKE RLGRAP-FILENAME MEMORY ID  M01 MODIF ID R02  DEFAULT C:\‘ NO-DISPLAY.
*SELECT-OPTIONS:S_HKONT FOR BSEG-HKONT ."NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK BLK1.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:RB_01 RADIOBUTTON GROUP RB DEFAULT X USER-COMMAND RB."3000版本
SELECTION-SCREEN COMMENT 3(12) TEXT-B01 MODIF ID RZ2.
PARAMETERS:P_3000 AS CHECKBOX.
SELECTION-SCREEN COMMENT 18(10) TEXT-B02 MODIF ID RZ2.
SELECTION-SCREEN END OF LINE.

PARAMETERS:RB_02 RADIOBUTTON GROUP RB. "1000 版本
PARAMETERS:RB_03 NO-DISPLAY."集团版本
*SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-003.
*PARAMETERS:RB_ RADIOBUTTON GROUP RB . "1000 版本
*SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF BLOCK B1.


*&------------------------------------------------------------------*
*&              INITIALIZATION
*&------------------------------------------------------------------*
INITIALIZATION.
*&初始化数据
  PERFORM FRM_INIT_DATA.

AT SELECTION-SCREEN OUTPUT.
  CASE X.
    WHEN RB_01.
      LOOP AT SCREEN.
        IF SCREEN-GROUP1 EQ R02.
          SCREEN-ACTIVE = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.

    WHEN RB_02 OR RB_03.
      LOOP AT SCREEN.
        IF SCREEN-GROUP1 EQ R01.
          SCREEN-ACTIVE = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    WHEN OTHERS.

  ENDCASE.

*&------------------------------------------------------------------*
*&              AT SELECTION-SCREEN
*&------------------------------------------------------------------*
AT SELECTION-SCREEN.

  PERFORM FRM_CHECK_AUTHOR.

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

  CASE X.
    WHEN RB_01.
      PERFORM FRM_GET_DATA.
      PERFORM FRM_ALV_OUTPUT.

    WHEN RB_02.
      PERFORM FRM_GET_1000.
      IF P_PRINT = X.
*    PERFORM FRM_ALV_OUTPUT_3000.
        PERFORM FRM_PRINT_DATA.
      ELSE.
        IF P_EXCEL = X.
          PERFORM FRM_EXCEL_OUT.
          PERFORM FRM_WRITE_OUT.
        ELSE.
          PERFORM FRM_WRITE_OUT.
        ENDIF.

      ENDIF.

    WHEN RB_03.

  ENDCASE.

END-OF-SELECTION.

*& page header
TOP-OF-PAGE.
  PERFORM DISPLAY_HEADER.

*& page footer
END-OF-PAGE.

*&------------------------------------------------------------------*
*&              END-OF-SELECTION
*&------------------------------------------------------------------*
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTHOR .

*&init screen.
  CASE X.
    WHEN RB_02 OR RB_03.
      P_BUKRS = 1000.
    WHEN RB_01.
      P_BUKRS = 3000.
    WHEN OTHERS.

  ENDCASE.

  LOOP AT S_MONAT.
    IF S_MONAT-HIGH IS INITIAL.
      S_MONAT-HIGH = S_MONAT-LOW.
    ENDIF.

    IF S_MONAT-LOW IS INITIAL.
      S_MONAT-LOW = S_MONAT-HIGH.
    ENDIF.
    MODIFY S_MONAT.
  ENDLOOP.

  IF P_EXCEL = X AND P_PRINT = X.
    MESSAGE E000(ZMM_001) WITH 不能同时打印并导出 DISPLAY LIKE S.
  ENDIF.
ENDFORM.                    " FRM_CHECK_AUTHOR
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA.
  DATA:LT_DA LIKE TABLE OF GT_DATA WITH HEADER LINE.
  DATA:BEGIN OF LT_BKPF OCCURS 0,
        BUKRS LIKE BKPF-BUKRS,
        BELNR LIKE BKPF-BELNR,
        GJAHR LIKE BKPF-GJAHR,
        BLART LIKE BKPF-BLART,
       END OF LT_BKPF.
  DATA:LT_BKPF_C LIKE TABLE OF LT_BKPF WITH HEADER LINE.
  DATA:LT_BSEG LIKE TABLE OF GT_BSEG WITH HEADER LINE,
       LT_BSEG_C LIKE TABLE OF GT_BSEG WITH HEADER LINE,
       LT_BSEG_P LIKE TABLE OF GT_BSEG WITH HEADER LINE,
       LT_BSEG_BC LIKE TABLE OF GT_BSEG WITH HEADER LINE.
  DATA:LT_BSEG_BF LIKE TABLE OF GT_BSEG WITH HEADER LINE.
  DATA:LT_BSEG_ADD LIKE TABLE OF GT_BSEG WITH HEADER LINE.

  DATA:LV_DMBTR LIKE BSEG-DMBTR,
       LV_VAL16 LIKE BSEG-DMBTR,
       LV_VAL17 LIKE BSEG-DMBTR,
       LV_HSL00 LIKE FAGLFLEXT-HSL01.
  DATA:LV_DMBTR_9  LIKE BSEG-DMBTR,
       LV_DMBTR_20 LIKE BSEG-DMBTR.
  DATA:LV_HSL00_1  LIKE BSEG-DMBTR,
       LV_HSL00_2  LIKE BSEG-DMBTR.
  RANGES:R_HKONT  FOR BSEG-HKONT.
  RANGES:R_HKONT1 FOR BSEG-HKONT.

*&项目数据 科目为1001*和1002*的才需要处理.
*& +1022*(银行清算科目)
  CLEAR:R_HKONT,R_HKONT[].
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001001*.
  APPEND R_HKONT.
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001002*.
  APPEND R_HKONT.
*&->start add by ABAP30 on 20160126 REQ BY fi_wxq (项目列添加银行清算科目: 1022*)
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001022*.
  APPEND R_HKONT.
*&->end add.

*&S1.BKPF 凭证抬头表取出 年度+期间内的数据
  SELECT BUKRS
         BELNR
         GJAHR
         BLART
    INTO TABLE LT_BKPF
    FROM BKPF
   WHERE BUKRS EQ P_BUKRS
     AND GJAHR EQ P_GJAHR
     AND MONAT IN S_MONAT
     AND BSTAT NE S.
*&--->不能加
*     AND STBLG = ‘‘"冲销凭证号
*     AND BLART NOT IN (WA,WE,WL).
*&---<
*& WA 发货/ WE  收货/ WI  库存凭证

  IF SY-SUBRC NE 0.
    MESSAGE S007 DISPLAY LIKE E.
* STOP.
  ELSE.
    SORT LT_BKPF BY BUKRS BELNR GJAHR.
    DELETE ADJACENT DUPLICATES FROM LT_BKPF COMPARING BUKRS BELNR GJAHR.
*&add_lxq on 20151109 排除凭证状态为S的会计凭证
* DELETE LT_BKPF WHERE BSTAT EQ S."S注释项目
*& bseg 四个主键
*BUKRS
*BELNR
*BUZEI
*GJAHR
*&S2.取BSEG 凭证金额
    SELECT BUKRS
           BELNR
           BUZEI
           GJAHR
           RSTGR
           HKONT
           SHKZG
           DMBTR
           EBELN

           KOART
           LIFNR
      INTO TABLE LT_BSEG
* INTO CORRESPONDING FIELDS OF TABLE LT_BSEG
      FROM BSEG
       FOR ALL ENTRIES IN LT_BKPF
     WHERE BUKRS EQ LT_BKPF-BUKRS
       AND BELNR EQ LT_BKPF-BELNR
       AND GJAHR EQ LT_BKPF-GJAHR.
* AND ( HKONT LIKE 001001% OR HKONT LIKE 001002% ).
  ENDIF.

*&for test
  CLEAR:R_HKONT1,R_HKONT1[].
  R_HKONT1(3) = IBT.
  R_HKONT1-LOW = 0014020101.                              "001402*.
  R_HKONT1-HIGH = 0014129999.                             "001412*.
  APPEND R_HKONT1.

  LT_BSEG_BF[] = LT_BSEG[].
  DELETE LT_BSEG_BF WHERE HKONT NOT IN R_HKONT1.

*&S3.汇总本位币金额 BSEG-DMBTR(借方为S(+) ,贷方为H(-),)
  LOOP AT LT_BSEG.
*"WHERE HKONT IN R_HKONT.

*&S3.1.项目列 通过原因代码汇总,+科目为1001*和1002*(已加001022*)的才需要处理.
    IF LT_BSEG-HKONT IN R_HKONT.
      GT_BSEG-RSTGR = LT_BSEG-RSTGR.
      IF LT_BSEG-SHKZG EQ S.
        GT_BSEG-DMBTR = LT_BSEG-DMBTR.
      ELSE.
        GT_BSEG-DMBTR = -1 * LT_BSEG-DMBTR.
      ENDIF.
      COLLECT GT_BSEG.
      CLEAR GT_BSEG.
    ENDIF.

*&S3.2补充资料列 通过科目汇总,
*&001602*根据期间科目贷方(SHKZG = H)金额汇总 - 16020798、16020704两个科目
    IF LT_BSEG-HKONT(6) EQ 001602.
      LT_BSEG_BC-SHKZG = LT_BSEG-SHKZG.
    ENDIF.

*&对于项目部分,为后续处理去除科目前导0.
    CALL FUNCTION CONVERSION_EXIT_ALPHA_OUTPUT
      EXPORTING
        INPUT  = LT_BSEG-HKONT
      IMPORTING
        OUTPUT = LT_BSEG_BC-HKONT.
*    LT_BSEG_BC-HKONT = LT_BSEG-HKONT.

    IF LT_BSEG-SHKZG EQ S.
      LT_BSEG_BC-DMBTR = LT_BSEG-DMBTR.
    ELSE.
      LT_BSEG_BC-DMBTR = -1 * LT_BSEG-DMBTR.
    ENDIF.
    COLLECT LT_BSEG_BC.
    CLEAR LT_BSEG_BC.
  ENDLOOP.
  SORT GT_BSEG BY RSTGR.
  SORT LT_BSEG_BC BY HKONT SHKZG.

  " ADD BY ABAP20
  MOVE LT_BKPF[] TO LT_BKPF_C[].

*&->add on 20160324 req by FI_LJJ   要把固定资产这块 从“140”转到“240”来
*&-就是从140里面取1601和1604数据转换成240,这步可以做到了是吧 by Lizhihua on 20160323.
*  BREAK ABAP30.
*&S1.处理原因代码为 140 的条目
  LOOP AT LT_BSEG INTO WA_BSEG WHERE RSTGR = 140.
    READ TABLE LT_BSEG WITH KEY BUKRS = WA_BSEG-BUKRS
                                BELNR = WA_BSEG-BELNR
                                GJAHR = WA_BSEG-GJAHR
                                KOART = K.
    IF SY-SUBRC EQ 0.
      WA_BSEG-LIFNR = LT_BSEG-LIFNR.
    ENDIF.
*& 通过K类型财务凭证找 REGUP付款凭证
    CLEAR:LT_REGUP_ADD,LT_REGUP_ADD[].
    CLEAR:LT_BSEG_ADD,LT_BSEG_ADD[].
    CLEAR:LT_REGUP_ADD.
    SELECT VBLNR
           BUKRS
           BELNR
           GJAHR
           BUZEI
           DMBTR
      INTO CORRESPONDING FIELDS OF TABLE LT_REGUP_ADD
      FROM REGUP
     WHERE ZBUKR = WA_BSEG-BUKRS
       AND VBLNR = WA_BSEG-BELNR
       AND LIFNR = WA_BSEG-LIFNR
       AND GJAHR = WA_BSEG-GJAHR.
    IF SY-SUBRC EQ 0.
*&通过付款凭证 找回 科目为 A    资产
*& 科目类型 = S的 总分类账科目
      SELECT BUKRS
             BELNR
             BUZEI
             GJAHR
             RSTGR
             HKONT
             SHKZG
             DMBTR
             EBELN

             KOART
             LIFNR
        INTO CORRESPONDING FIELDS OF TABLE LT_BSEG_ADD
        FROM BSEG
         FOR ALL ENTRIES IN LT_REGUP_ADD
       WHERE BUKRS EQ LT_REGUP_ADD-BUKRS
         AND BELNR EQ LT_REGUP_ADD-BELNR
         AND GJAHR EQ LT_REGUP_ADD-GJAHR
         AND KOART EQ A.

      DATA:LV_140_240 LIKE BSEG-DMBTR.
      IF SY-SUBRC EQ 0.
*&科目为 1601*1604*,则记为 原因代码 = 240
        LOOP AT LT_BSEG_ADD." WHERE HKONT
          IF LT_BSEG_ADD-HKONT(6) = 001601 OR LT_BSEG_ADD-HKONT(6) = 001604.
*            IF LT_BSEG-SHKZG EQ S.
*              GT_BSEG-DMBTR = LT_BSEG-DMBTR.
*            ELSE.
*              GT_BSEG-DMBTR = -1 * LT_BSEG-DMBTR.
*            ENDIF.
            READ TABLE LT_REGUP_ADD WITH KEY BUKRS = LT_BSEG_ADD-BUKRS
                                             BELNR = LT_BSEG_ADD-BELNR
                                             GJAHR = LT_BSEG_ADD-GJAHR.
            IF SY-SUBRC EQ 0.
              LV_140_240 = LV_140_240 + LT_REGUP_ADD-DMBTR.
              EXIT.
            ENDIF.

          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.

  ENDLOOP.
*&->end add.

*&->删除 凭证类型 <> ZP---删除掉 付款过帐 的凭证.
  DELETE LT_BKPF_C[] WHERE BLART NEZP.

  IF LT_BKPF_C[] IS NOT   INITIAL .

    SELECT REGUP~VBLNR
           REGUP~BUKRS
           REGUP~BELNR
           REGUP~GJAHR
           REGUP~BUZEI
    FROM REGUP "来自收付程序的处理项目
    INTO CORRESPONDING FIELDS OF TABLE GT_REGUP
     FOR ALL ENTRIES IN LT_BKPF_C
   WHERE  XVORL = ‘‘
     AND  GJAHR = LT_BKPF_C-GJAHR
     AND  VBLNR = LT_BKPF_C-BELNR
     AND  BUKRS = LT_BKPF_C-BUKRS.
*    BELNR = LT_BKPF-VBLNR AND
*  GJAHR = LT_BKPF-GJAHR.

    IF GT_REGUP[] IS NOT INITIAL.
*& 取会计凭证
      SELECT BUKRS
      BELNR
      BUZEI
      GJAHR
      RSTGR
      HKONT
      SHKZG
      DMBTR
        EBELN
      INTO TABLE LT_BSEG_C
* INTO CORRESPONDING FIELDS OF TABLE LT_BSEG
      FROM BSEG
       FOR ALL ENTRIES IN GT_REGUP
    WHERE BUKRS EQ GT_REGUP-BUKRS
      AND BELNR EQ GT_REGUP-BELNR
      AND GJAHR EQ GT_REGUP-GJAHR.

*& 取付款凭证
      SELECT BUKRS
         BELNR
         BUZEI
         GJAHR
         RSTGR
         HKONT
         SHKZG
         DMBTR
         EBELN
         INTO TABLE LT_BSEG_P
* INTO CORRESPONDING FIELDS OF TABLE LT_BSEG
         FROM BSEG
         FOR ALL ENTRIES IN GT_REGUP
         WHERE BUKRS EQ GT_REGUP-BUKRS
         AND BELNR EQ GT_REGUP-VBLNR
         AND GJAHR EQ GT_REGUP-GJAHR.
    ENDIF.

*BREAK ABAP30.
*&->来自收付程序的处理项目(付款数据处理)
*->use it
    LOOP AT GT_REGUP.

      AT END OF GJAHR.
        READ TABLE LT_BSEG_C WITH KEY BUKRS = GT_REGUP-BUKRS   "汇总1601或16002的科目值
         BELNR = GT_REGUP-BELNR   HKONT(6) = 001601 .
        IF SY-SUBRC NE 0.
          READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                                         BELNR = GT_REGUP-BELNR
                                         HKONT(6) = 001604 .
          IF SY-SUBRC = 0.
*& 加上科目 2202*
            READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                                           BELNR = GT_REGUP-BELNR
                                           HKONT(6) = 002202 .
            IF SY-SUBRC = 0.
              LV_VAL16 =  LT_BSEG_C-DMBTR + LV_VAL16.
            ENDIF.
          ENDIF.
        ELSE.
*& 加上科目 2202*
          READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
          BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
          IF SY-SUBRC = 0.
            LV_VAL16 =  LT_BSEG_C-DMBTR + LV_VAL16.
          ENDIF.
        ENDIF.


        READ TABLE LT_BSEG_P WITH  KEY BUKRS = GT_REGUP-BUKRS
                                       BELNR = GT_REGUP-VBLNR
                                       HKONT(6) = 001002 .
        IF SY-SUBRC = 0 .
          "排除0010021702/0010021901
          READ TABLE LT_BSEG_P WITH  KEY BUKRS = GT_REGUP-BUKRS
                 BELNR = GT_REGUP-VBLNR  HKONT = 0010021702 .
          IF SY-SUBRC = 0.
            CONTINUE.
          ENDIF.
          READ TABLE LT_BSEG_P WITH  KEY BUKRS = GT_REGUP-BUKRS
          BELNR = GT_REGUP-VBLNR  HKONT = 0010021901 .
          IF SY-SUBRC = 0.
            CONTINUE.
          ENDIF.
          "***************
          READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
          BELNR = GT_REGUP-BELNR   EBELN(3) = 412."取zac3的采购订单凭证后取002202的金额汇总LV_VAL17
          IF SY-SUBRC NE 0.
            READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
            BELNR = GT_REGUP-BELNR    EBELN(3) = 422."取zaf3的采购订单凭证后取002202的金额汇总LV_VAL17
            IF SY-SUBRC = 0.
              READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
              BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
              IF SY-SUBRC = 0.
                LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
              ENDIF.
            ENDIF.
          ELSE.
            READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
            BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
            IF SY-SUBRC = 0.
              LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
            ENDIF.
          ENDIF.
        ELSE.
          "处理001001开头的科目
          READ TABLE LT_BSEG_P WITH  KEY BUKRS = GT_REGUP-BUKRS
                                         BELNR = GT_REGUP-VBLNR
                                         HKONT(6) = 001001 .
          IF SY-SUBRC = 0 .
            READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
            BELNR = GT_REGUP-BELNR   EBELN(3) = 412."取zac3的采购订单凭证后取002202的金额汇总LV_VAL17
            IF SY-SUBRC NE 0.
              READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
              BELNR = GT_REGUP-BELNR    EBELN(3) = 422."取zaf3的采购订单凭证后取002202的金额汇总LV_VAL17
              IF SY-SUBRC = 0.
                READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
                IF SY-SUBRC = 0.
                  LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
                ENDIF.
              ENDIF.
            ELSE.
              READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
              BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
              IF SY-SUBRC = 0.
                LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
              ENDIF.
            ENDIF.

*&->add by abap30 on 20160128 REQ BY FI_WXQ (添加 科目 = 1022* 银行清算类科目)
          ELSE.
*& 处理001022 开头的科目
            READ TABLE LT_BSEG_P WITH  KEY BUKRS = GT_REGUP-BUKRS
                                           BELNR = GT_REGUP-VBLNR
                                           HKONT(6) = 001022 .
            IF SY-SUBRC = 0 .
              READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
              BELNR = GT_REGUP-BELNR   EBELN(3) = 412."取zac3的采购订单凭证后取002202的金额汇总LV_VAL17
              IF SY-SUBRC NE 0.
                READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                BELNR = GT_REGUP-BELNR    EBELN(3) = 422."取zaf3的采购订单凭证后取002202的金额汇总LV_VAL17
                IF SY-SUBRC = 0.
                  READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                  BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
                  IF SY-SUBRC = 0.
                    LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
                  ENDIF.
                ENDIF.
              ELSE.
                READ TABLE LT_BSEG_C WITH  KEY BUKRS = GT_REGUP-BUKRS
                BELNR = GT_REGUP-BELNR   HKONT(6) = 002202 .
                IF SY-SUBRC = 0.
                  LV_VAL17 =  LT_BSEG_C-DMBTR + LV_VAL17.
                ENDIF.
              ENDIF.
*&->end add.
            ENDIF.
          ENDIF.
        ENDIF.
*
      ENDAT.
    ENDLOOP.
*    LOOP AT GT_REGUP.
*      AT END OF GJAHR.

*      ENDAT.
*    ENDLOOP.
  ENDIF.
  "END ADD BY ABAP20
  "END ADD BY BAIYUZHUANG
*&->行项目写入
*&1    一、经营活动产生的现金流量:         -------            /1、将净利润调节为经营活动现金流量
  CLEAR:LV_DMBTR,LV_HSL00.
**&test
*  LV_DMBTR = 1000.
*  LV_HSL00 = 1000.
  PERFORM FRM_APPEND_DATA USING 一、经营活动产生的现金流量: ‘‘ LV_DMBTR   1、将净利润调节为经营活动现金流量 ‘‘  LV_HSL00.

*  GT_DATA-TEXT_XM = 一、经营活动产生的现金流量:.
*  GT_DATA-LINE_XM = ‘‘.
*  GT_DATA-DMBTR   = ‘‘.
*  GT_DATA-TEXT_BC = 1、将净利润调节为经营活动现金流量  .
*  GT_DATA-LINE_BC = ‘‘.
*  GT_DATA-HSL00   = ‘‘.
*  APPEND GT_DATA.

*&2     销售商品、提供劳务收到的现金 1 原因代码101汇总   /
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 101 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  PERFORM FRM_APPEND_DATA USING 销售商品、提供劳务收到的现金 1  LV_DMBTR  ‘‘ ‘‘  LV_HSL00.

*&3     收到的税费返还               3 原因代码102汇总   /净利润 57 等于利润表总净利润 (?1) 净利润=6001*+6051*-6401*-6402*-6403*-6601*-6602*-6603*-6701*+6101*+6111*+6301*-6711*-6801*
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 102 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

*  BREAK ABAP30.
*&->start change by ABAP30 on 20160401.
* 净利润
  CLEAR:R_HKONT,R_HKONT[].
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 006*.
  APPEND R_HKONT.

  DATA:L_P_J        LIKE P_MONAT,
       L_PJ_C       LIKE P_MONAT,
       L_NAME_J     TYPE CHAR13,
       L_NAME2_J    TYPE CHAR13,
       L_NAME_QC_J  TYPE CHAR13,
       L_NAME2_QC_J TYPE CHAR13.
  DATA:LT_FAGT LIKE TABLE OF GT_FAGT WITH HEADER LINE.
**&将这个值,改成抓FAGLFLEXT 里的值,006* 科目的,当期的总额,HSL*(月份对应):
*&  净利润栏位取值改为从T表取数据
*&  FAGLFLEXT表中取现金的余额汇总 (期余额和期初余额)
*&->start add by ABAP30 on 20160405 req by FI_LJJ
  CLEAR:GT_FAGT,GT_FAGT[],
   L_P_J       ,
   L_NAME_J    ,
   L_NAME2_J   ,
   L_NAME_QC_J ,
   L_NAME2_QC_J.
  CLEAR:LV_HSL00.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE GT_FAGT
    FROM FAGLFLEXT
   WHERE RBUKRS EQ P_BUKRS
      AND RACCT IN R_HKONT
      AND RYEAR = P_GJAHR
      AND RRCTY = 0.

  IF SY-SUBRC EQ 0.
*&Way 1.
*&1.按月汇总
    LOOP AT GT_FAGT.
      LT_FAGT = GT_FAGT.
      CLEAR:LT_FAGT-RACCT,LT_FAGT-DRCRK.
      COLLECT LT_FAGT.
    ENDLOOP.
    CLEAR:GT_FAGT[].
    GT_FAGT[] = LT_FAGT[].

    CONCATENATE GT_FAGT-HSL S_MONAT-HIGH INTO L_NAME_J.
    CONCATENATE GT_FAGT-HSL S_MONAT-LOW  INTO L_NAME_QC_J.
    L_PJ_C = S_MONAT-HIGH.
    LOOP AT GT_FAGT.
*&确定月数
      L_P_J = S_MONAT-HIGH - S_MONAT-LOW.

      IF S_MONAT-HIGH = S_MONAT-LOW.
        CONCATENATE GT_FAGT-HSL S_MONAT-HIGH INTO L_NAME2_QC_J.
        ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
        LV_HSL00 = LV_HSL00 + <FN1_QC>.
      ELSE.
*&得到当月余额
        ASSIGN (L_NAME_J) TO <FN2_QC>.
        DO L_P_J TIMES.
          IF L_P_J EQ 1.
            CONCATENATE GT_FAGT-HSL L_P_J INTO L_NAME2_QC_J.
            ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
            <FN2_QC> = <FN2_QC> + <FN1_QC>.
          ELSEIF L_P_J GT 1.
*&按月份往前推
            L_PJ_C = L_PJ_C  - 1.
            CONCATENATE GT_FAGT-HSL L_PJ_C INTO L_NAME2_QC_J.
            ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
            <FN2_QC> = <FN2_QC> + <FN1_QC>.
          ENDIF.
        ENDDO.
*&净利润计算:
        LV_HSL00 = LV_HSL00 + <FN2_QC>.
      ENDIF.
      CLEAR:GT_FAGT.
      IF <FN1_QC> IS NOT INITIAL.
        CLEAR <FN1_QC>.
      ENDIF.
      IF <FN2_QC> IS NOT INITIAL.
        CLEAR <FN2_QC>.
      ENDIF.

    ENDLOOP.

**&Way 2.
*    CONCATENATE GT_FAGT-HSL S_MONAT-HIGH INTO L_NAME_J.
*    CONCATENATE GT_FAGT-HSL S_MONAT-LOW  INTO L_NAME_QC_J.
**    CLEAR:LV_QC_J,LV_QM_J.
*    LOOP AT GT_FAGT.
**&确定月数
*      L_P_J = S_MONAT-HIGH - S_MONAT-LOW.
**&L1.只查询一个月
*      IF S_MONAT-HIGH = S_MONAT-LOW.
*        CONCATENATE GT_FAGT-HSL S_MONAT-HIGH INTO L_NAME2_QC_J.
*        ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
*        LV_HSL00 = LV_HSL00 + <FN1_QC>.
*      ELSE.
**&L2.查询多月:
**&得到当月余额
*        ASSIGN (L_NAME_J) TO <FN2_QC>.
*        DO L_P_J TIMES.
*          IF L_P_J EQ 1.
*            CONCATENATE GT_FAGT-HSL L_P_J INTO L_NAME2_QC_J.
*            ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
*            <FN2_QC> = <FN2_QC> + <FN1_QC>.
*          ELSEIF L_P_J GT 1.
**&按月份往前推
*            L_P_J = L_P_J - 1.
*            CONCATENATE GT_FAGT-HSL L_P_J INTO L_NAME2_QC_J.
*            ASSIGN (L_NAME2_QC_J) TO <FN1_QC>.
*            <FN2_QC> = <FN2_QC> + <FN1_QC>.
*          ENDIF.
*        ENDDO.
**&净利润计算:
*        LV_HSL00 = LV_HSL00 + <FN2_QC>.
*      ENDIF.
*      CLEAR:GT_FAGT.
*      IF <FN1_QC> IS NOT INITIAL.
*        CLEAR <FN1_QC>.
*      ENDIF.
*      IF <FN2_QC> IS NOT INITIAL.
*        CLEAR <FN2_QC>.
*      ENDIF.
*    ENDLOOP.
  ENDIF.
*&->end add.

*  LOOP AT GT_FAGT INTO WA_FAGT WHERE RACCT IN R_HKONT.
*    LV_HSL00 = LV_HSL00 + WA_FAGT-DMBTR.
*  ENDLOOP.
*  LV_HSL00 = LV_HSL00 * -1.

*&->change on 20151110.以6*科目的余额汇总
  LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = LV_HSL00 * -1.

*  LOOP AT LT_BSEG_BC.
*    IF LT_BSEG_BC-HKONT(4) = 6001.
*      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
** PERFORM FRM_GET_HSLOO USING LT_BSEG_BC-DMBTR LV_HSL00.
*    ENDIF.
**&收入的发生是在贷方,费用的产生是在借方
**&收入类的科目需要* -1.
*    LV_HSL00 = LV_HSL00 * -1.
*    IF LT_BSEG_BC-HKONT(4) = 6051.
*      LT_BSEG_BC-DMBTR = LT_BSEG_BC-DMBTR * -1.
*      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6401.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6402.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6403.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6601.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6602.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6603.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6701.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6101.
*      LT_BSEG_BC-DMBTR =  LT_BSEG_BC-DMBTR * -1.
*      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6111.
*      LT_BSEG_BC-DMBTR =  LT_BSEG_BC-DMBTR * -1.
*      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6301.
*      LT_BSEG_BC-DMBTR =  LT_BSEG_BC-DMBTR * -1.
*      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6711.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*    IF LT_BSEG_BC-HKONT(4) = 6801.
*      LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*    ENDIF.
*  ENDLOOP.

  PERFORM FRM_APPEND_DATA USING 收到的税费返还   3 LV_DMBTR  净利润 57  LV_HSL00.

*4      收到的其他与经营活动有关的现金 8 原因代码103汇总 /加:   资产减值准备  58  001603*根据期间科目余额加总
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 103 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1603.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
* READ TABLE LT_BSEG_BC WITH KEY HKONT(4) = 1603 BINARY SEARCH.
* IF SY-SUBRC EQ 0.
*   LV_HSL00 = LT_BSEG_BC-DMBTR.
* ENDIF.

  PERFORM FRM_APPEND_DATA USING 收到的其他与经营活动有关的现金   8 LV_DMBTR  加:   资产减值准备 58  LV_HSL00.

*5      现金流入小计          9 101~103金额加总          /固定资产折旧、油气资产折耗、生产性生物资产折旧 59  001602*根据期间科目贷方(SHKZG = H)金额加总排除16020798、16020704两个科目
  CLEAR:LV_DMBTR,LV_HSL00.
*&取101~103金额加总.
  LOOP AT GT_DATA INTO WA_DATA.
    AT LAST.
      SUM.
      LV_DMBTR = WA_DATA-DMBTR.
    ENDAT.
  ENDLOOP.

*BC->001602*根据期间科目贷方(SHKZG = H)金额加总
  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1602 AND SHKZG = H.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  READ TABLE LT_BSEG_BC WITH KEY HKONT = 16020798 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
  ENDIF.
  READ TABLE LT_BSEG_BC WITH KEY HKONT = 16020704 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
  ENDIF.
*&累积折旧需要显示正数
  LV_HSL00 = LV_HSL00 * -1.
*LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING      现金流入小计   9 LV_DMBTR  固定资产折旧、油气资产折耗、生产性生物资产折旧  59  LV_HSL00.

*6      购买商品、接受劳务支付的现金  10  原因代码140汇总   /无形资产摊销      60 001702*根据期间科目余额加总
* BREAK ABAP30.
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 140.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.

*&->注释 on 20160324
*  LV_DMBTR = LV_DMBTR - LV_VAL16 - LV_VAL17."add by abap20
*BREAK ABAP30.
*&->add by ABAP30 on 20160324. -LV_140_240 (- 固定资产)
  IF LV_140_240 NE 0.
    LV_DMBTR = LV_DMBTR - LV_140_240.
  ENDIF.
*&->end add.

*BC->001702*根据期间科目余额加总
*&->C3.change by rainy on 20151108 改成:无形资产摊销=16020798+16020704
*  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1702.
*    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
*  ENDLOOP.
  READ TABLE LT_BSEG_BC WITH KEY HKONT = 16020798.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LT_BSEG_BC-DMBTR.
  ENDIF.
  READ TABLE LT_BSEG_BC WITH KEY HKONT = 16020704.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDIF.
  LV_HSL00 = LV_HSL00 * -1.
*LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 购买商品、接受劳务支付的现金    10 LV_DMBTR  无形资产摊销  60  LV_HSL00.

*7      支付给职工以及为职工支付的现金  12 原因代码141汇总  /长期待摊费用摊销  61  001801*根据期间科目余额加总
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 141.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.

*BREAK ABAP30.
  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1801.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
*  LV_HSL00 = 3.
*&C4.余额的贷方应该为整数
  LV_HSL00 = LV_HSL00 * -1.
*&->start add on 20160323 by ABAP30. req by fi_ljj
*& 61 这一项增加科目:2503*
  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 2503.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
*&->end add.

  PERFORM FRM_APPEND_DATA USING 支付给职工以及为职工支付的现金    12 LV_DMBTR  长期待摊费用摊销  61  LV_HSL00.

*8      支付的各项税费       13  原因代码142汇总            /处置固定资产、无形资产和其他长期资产的损失(收益以“-”号填列)64  64050303 按照期间余额加总
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 142.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.

  READ TABLE LT_BSEG_BC WITH KEY HKONT = 64050303 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LT_BSEG_BC-DMBTR.
  ENDIF.
*LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 支付的各项税费    13 LV_DMBTR  处置固定资产、无形资产和其他长期资产的损失(收益以“-”号填列)  64  LV_HSL00.

*  BREAK ABAP30.
  BREAK TEST_13.
*9      支付的其他与经营活动有关的现金 18  原因代码143汇总  /固定资产报废损失(收益以“-”号填列)           65  64050301 按照期间余额加总
*BREAK ABAP30.

*&->add by ABAP30 on 20160415.
*(原因代码143汇总*-1 + )
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 143.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.
*&->change by ABAP30 on 20160419 (数据不对要调对)
* LV_DMBTR  = LV_DMBTR + LV_VAL17."ADD BY ABAP20 (被FI_LZH 反映这个处理有问题 on 20160415)
  READ TABLE LT_BSEG_BC WITH KEY HKONT = 64050301 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LT_BSEG_BC-DMBTR.
  ENDIF.
*LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 支付的其他与经营活动有关的现金   18 LV_DMBTR  固定资产报废损失(收益以“-”号填列)  65  LV_HSL00.

  RANGES:R_RSTGR FOR BSEG-RSTGR.
*10   现金流出小计          20  140~143金额加总           /公允价值变动损失(收益以“-”号填列)           66
  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:R_RSTGR,R_RSTGR[].

*BREAK ABAP30.
*&->start change by ABAP30 on 20160325.
*& 现金流出小计 = line 10 + 12 + 13 + 18.
  READ TABLE GT_DATA WITH KEY LINE_XM = 10.
  IF SY-SUBRC EQ 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.

  READ TABLE GT_DATA WITH KEY LINE_XM = 12.
  IF SY-SUBRC EQ 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.

  READ TABLE GT_DATA WITH KEY LINE_XM = 13.
  IF SY-SUBRC EQ 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.

  READ TABLE GT_DATA WITH KEY LINE_XM = 18.
  IF SY-SUBRC EQ 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.
*&->end change.

**&add_lxq 140~143 加总
*  R_RSTGR(3) = IBT.
*  R_RSTGR-LOW = 140.
*  R_RSTGR-HIGH = 143.
*  APPEND R_RSTGR.
**&取140~143金额加总
*  LOOP AT GT_BSEG WHERE RSTGR IN R_RSTGR.
*    LV_DMBTR = GT_BSEG-DMBTR + LV_DMBTR.
*  ENDLOOP.
**  LV_DMBTR = LV_DMBTR * -1.
*  LV_DMBTR = LV_DMBTR * -1.
*  LV_DMBTR = LV_DMBTR - LV_VAL16."add by abap20
  PERFORM FRM_APPEND_DATA USING      现金流出小计   20 LV_DMBTR  公允价值变动损失(收益以“-”号填列) 66  LV_HSL00.

*11   经营活动产生的现金流量净额 21  现金流入-现金流出    /
  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:LV_DMBTR_9,LV_DMBTR_20.
*&计算 现金流入-现金流出
*&现金流入小计
  READ TABLE GT_DATA WITH KEY LINE_XM = 9.
  LV_DMBTR = GT_DATA-DMBTR.
*&现金流出小计
  READ TABLE GT_DATA WITH KEY LINE_XM = 20.
  LV_DMBTR = LV_DMBTR - GT_DATA-DMBTR.

  PERFORM FRM_APPEND_DATA USING 经营活动产生的现金流量净额    21 LV_DMBTR    ‘‘  LV_HSL00.

*12 二、投资活动产生的现金流量                            /财务费用(收益以“-”号填列)           67  66031501 按照期间余额加总
  CLEAR:LV_DMBTR,LV_HSL00.

  READ TABLE LT_BSEG_BC WITH KEY HKONT = 66031501 BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    LV_HSL00 = LT_BSEG_BC-DMBTR.
  ENDIF.
*LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 二、投资活动产生的现金流量   ‘‘ LV_DMBTR  财务费用(收益以“-”号填列)  67  LV_HSL00.

*13   收回投资所收到的现金          22  原因代码201汇总  -/投资损失(收益以“-”号填列)           68 (?2)
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 201.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
*  LV_DMBTR = LV_DMBTR * -1."MOD BY ABAP20 CHANGE BY wxq_20151130 201不需要乘-1

  PERFORM FRM_APPEND_DATA USING 收回投资所收到的现金   22 LV_DMBTR  投资损失(收益以“-”号填列)   68  LV_HSL00.

*14   取得投资收益所收到的现金      23  原因代码202汇总  -/递延所得税资产减少(增加以“-”号填列)           69  1811*(期初数-期末数->0-DMBTR
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 202.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1811.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = 0 - LV_HSL00.
*  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 取得投资收益所收到的现金   23 LV_DMBTR  递延所得税资产减少(增加以“-”号填列)  69  LV_HSL00.

*15   处置固定资产、无形资产和其他长期资产所收回的现金净额          25  原因代码203汇总   /递延所得税负债增加(减少以“-”号填列) 70  2901*(期末数-期初数->DMBTR - 0
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 203.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 2901.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
*&贷方为 正
  LV_HSL00 = LV_HSL00 * -1.
*  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 处置固定资产、无形资产和其他长期资产所收回的现金净额   25 LV_DMBTR  递延所得税负债增加(减少以“-”号填列)  70   LV_HSL00.

*16   收到的其他与投资活动有关的现金 28  原因代码204汇总  /存货的减少(增加以“-”号填列) 71 1402*~1412*(期初数-期末数)
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 204.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  CLEAR:R_HKONT,R_HKONT[].
  R_HKONT(3) = IBT.
  R_HKONT-LOW = 1402*.
  R_HKONT-HIGH = 1412*.
  APPEND R_HKONT.
  LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = 0 - LV_HSL00.

*&add on 20151108 by wxq增加1471*
  CLEAR:LV_HSL00_1.
  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1471.
    LV_HSL00_1 = LV_HSL00_1 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00_1 = 0 - LV_HSL00_1.

  LV_HSL00 = LV_HSL00 + LV_HSL00_1.

*LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 收到的其他与投资活动有关的现金   28 LV_DMBTR  存货的减少(增加以“-”号填列)  71   LV_HSL00.

*17   现金流入小计          29  201~204金额加总 /经营性应收项目的减少(增加以“-”号填列)72  (1122*+1121*+1123*+1221*+1801*)-1231*期末余额 (期初数-期末数)add on 20151108 by wxq 需要删除1801*
*BREAK ABAP30.

  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:R_RSTGR,R_RSTGR[].

  R_RSTGR(3) = IBT.
  R_RSTGR-LOW  = 201.
  R_RSTGR-HIGH = 204.
  APPEND R_RSTGR.
  CLEAR:R_RSTGR.

  LOOP AT GT_BSEG WHERE RSTGR IN R_RSTGR.
    LV_DMBTR = LV_DMBTR + GT_BSEG-DMBTR.
  ENDLOOP.

  CLEAR:R_HKONT,R_HKONT[].
  DEFINE MCR_RANGE .
    R_HKONT(3) = ICP.
    R_HKONT-LOW  = &1.
* R_HKONT-HIGH = &2.
    APPEND R_HKONT.
  END-OF-DEFINITION.

  MCR_RANGE:1122*.
  MCR_RANGE:1121*.
  MCR_RANGE:1123*.
  MCR_RANGE:1221*.
  MCR_RANGE:1801*.
*A
  CLEAR:LV_HSL00_1, LV_HSL00_2.

  LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
    LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = 0 - LV_HSL00.

  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1231.
    LV_HSL00_1 = LV_HSL00_1 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = LV_HSL00 - LV_HSL00_1.

*&C8-需要删除1801*
  LOOP AT LT_BSEG_BC WHERE HKONT(4) = 1801.
    LV_HSL00_2 = LV_HSL00_2 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00 = LV_HSL00 - LV_HSL00_2.

*&->start add on 20160323 by ABAP30. req by fi_ljj

*&->end add.

*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING      现金流入小计   29 LV_DMBTR  经营性应收项目的减少(增加以“-”号填列)  72  LV_HSL00.

*18   购建固定资产、无形资产和其他长期资产所支付的现金          30  原因代码240汇总  /经营性应付项目的增加(减少以“-”号填列)73 经营活动产生的现金流量净额-以上项目加总金额
*&->add by rainy on 20151125  req by fi_wxq
*经营性应付项目的增加(减少以“-”号填列)73  (2202*+2203*+2201*+2211*+2221*+2241*)余额加总乘以-1
*&->end add.

  CLEAR:LV_DMBTR,LV_HSL00,
        LV_HSL00_1.
  READ TABLE GT_BSEG WITH KEY RSTGR = 240.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.
  " ADD BY ABAP20
*  MOVE LT_BKPF[] TO LT_BKPF_C[].
*  DELETE LT_BKPF_C[] WHERE BLART neZP.
*  IF LT_BKPF_C[] IS NOT   INITIAL .
*
*    SELECT REGUP~VBLNR
*    REGUP~BUKRS
*    REGUP~BELNR
*    REGUP~GJAHR
*    REGUP~BUZEI FROM REGUP
*     INTO CORRESPONDING FIELDS OF TABLE GT_REGUP  FOR ALL ENTRIES IN LT_BKPF_C
*    WHERE  XVORL = ‘‘  AND GJAHR = LT_BKPF_C-GJAHR AND VBLNR = LT_BKPF_C-BELNR
*    AND  BUKRS = LT_BKPF_C-BUKRS.
**    BELNR = LT_BKPF-VBLNR AND
**  GJAHR = LT_BKPF-GJAHR.
*    .
*     SELECT BUKRS
*    BELNR
*    BUZEI
*    GJAHR
*    RSTGR
*    HKONT
*    SHKZG
*    DMBTR
*    INTO TABLE LT_BSEG_C
** INTO CORRESPONDING FIELDS OF TABLE LT_BSEG
*    FROM BSEG
*    FOR ALL ENTRIES IN GT_REGUP
*    WHERE BUKRS EQ GT_REGUP-BUKRS
*    AND BELNR EQ GT_REGUP-BELNR
*    AND GJAHR EQ GT_REGUP-GJAHR.


  IF P_3000 EQ X.
    CLEAR:R_HKONT,R_HKONT[].
    DEFINE MCR_RANGE .
      R_HKONT(3) = ICP.
      R_HKONT-LOW  = &1.
* R_HKONT-HIGH = &2.
      APPEND R_HKONT.
    END-OF-DEFINITION.
    MCR_RANGE:2202*.
    MCR_RANGE:2203*.
    MCR_RANGE:2201*.
    MCR_RANGE:2211*.
    MCR_RANGE:2221*.
    MCR_RANGE:2241*.
    LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
      LV_HSL00 = LV_HSL00 + LT_BSEG_BC-DMBTR.
    ENDLOOP.
    LV_HSL00 = 0 - LV_HSL00.
  ELSE.
*&BC->经营活动产生的现金流量净额-以上项目加总金额
    READ TABLE GT_DATA WITH KEY LINE_XM = 21.
    LV_HSL00 = GT_DATA-DMBTR.

    LOOP AT GT_DATA.
      AT LAST.
        SUM.
        LV_HSL00_1 = GT_DATA-HSL00.
      ENDAT.
    ENDLOOP.
    LV_HSL00 = LV_HSL00 - LV_HSL00_1.
  ENDIF.
*  LV_HSL00 = 3.

**&->注释 on 20160324.
*  IF LV_VAL16 NE  0.
*    LV_DMBTR = LV_DMBTR + LV_VAL16.
*  ENDIF.
*BREAK ABAP30.
*&->add by ABAP30 on 20160324. +LV_140_240
  IF LV_140_240 NE 0.
    LV_DMBTR = LV_DMBTR + LV_140_240.
  ENDIF.
*&->end add.
  PERFORM FRM_APPEND_DATA USING 购建固定资产、无形资产和其他长期资产所支付的现金   30 LV_DMBTR  经营性应付项目的增加(减少以“-”号填列) 73  LV_HSL00.

*19   投资所支付的现金          31  原因代码241汇总  -    / 其他            74
*&->add by rainy on 20151125 req by fi_wxq.
*&其他   74   经营活动产生的现金流量净额-以上项目加总金额
*&->end add.
*BREAK ABAP30.

  CLEAR:LV_DMBTR,LV_HSL00,LV_HSL00_1.
  READ TABLE GT_BSEG WITH KEY RSTGR = 241.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
*&add * -1.
  LV_DMBTR = LV_DMBTR * -1.

  IF P_3000 EQ X.
*&BC->经营活动产生的现金流量净额-以上项目加总金额
    READ TABLE GT_DATA WITH KEY LINE_XM = 21.
    LV_HSL00 = GT_DATA-DMBTR.

    LOOP AT GT_DATA.
      AT LAST.
        SUM.
        LV_HSL00_1 = GT_DATA-HSL00.
      ENDAT.
    ENDLOOP.
    LV_HSL00 = LV_HSL00 - LV_HSL00_1.

  ENDIF.
*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 投资所支付的现金   31 LV_DMBTR  其他   74  LV_HSL00.

*20   支付的其他与投资活动有关的现金 35  原因代码242汇总  /
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 242.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
*  LV_DMBTR = LV_DMBTR + LV_VAL17." ADD 采购订单的值
  LV_DMBTR = LV_DMBTR * -1.

*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 支付的其他与投资活动有关的现金   35 LV_DMBTR   ‘‘ ‘‘  LV_HSL00.

*21   现金流出小计          36  240~242金额加总           /
  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:R_RSTGR,R_RSTGR[].

*&->start change by ABAP30 on 20160325.
*&现金流出小计 = line 30+31+35
  READ TABLE GT_DATA WITH KEY LINE_XM = 30.
  IF SY-SUBRC = 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.

  READ TABLE GT_DATA WITH KEY LINE_XM = 31.
  IF SY-SUBRC = 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.

  READ TABLE GT_DATA WITH KEY LINE_XM = 35.
  IF SY-SUBRC = 0.
    LV_DMBTR = LV_DMBTR + GT_DATA-DMBTR.
  ENDIF.
*&->end change

*& 240~242、
  R_RSTGR(3) = IBT.
  R_RSTGR-LOW  = 240.
  R_RSTGR-HIGH = 242.
  APPEND R_RSTGR.
  CLEAR R_RSTGR.
**&计算240~242金额加总
*  LOOP AT GT_BSEG WHERE RSTGR IN R_RSTGR.
*    LV_DMBTR = GT_BSEG-DMBTR + LV_DMBTR.
*  ENDLOOP.
*  LV_DMBTR = LV_DMBTR * -1.
*  IF LV_VAL16 NE  0.
*    LV_DMBTR = LV_DMBTR + LV_VAL16.
*  ENDIF.
*LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING      现金流出小计   36 LV_DMBTR   ‘‘ ‘‘  LV_HSL00.

*22   投资活动产生的现金流量净额         37  现金流入-现金流出  /经营活动产生的现金流量净额 75  以上项目汇总
  DATA:LV_DMBTR_29 LIKE BSEG-DMBTR,
       LV_DMBTR_36 LIKE BSEG-DMBTR.

  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:LV_DMBTR_29,LV_DMBTR_36.
*&金额 = 现金流入-现金流出
*&现金流入
  READ TABLE GT_DATA WITH KEY LINE_XM = 29.
  LV_DMBTR_29 = GT_DATA-DMBTR.
*&现金流出
  READ TABLE GT_DATA WITH KEY LINE_XM = 36.
  LV_DMBTR_36 = GT_DATA-DMBTR.

  LV_DMBTR = LV_DMBTR_29 - LV_DMBTR_36.

*BC->sum
  LOOP AT GT_DATA.
    AT LAST.
      SUM.
      LV_HSL00 = GT_DATA-HSL00.
    ENDAT.
  ENDLOOP.
*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 投资活动产生的现金流量净额   37 LV_DMBTR   经营活动产生的现金流量净额 75  LV_HSL00.

*23 三、  筹资活动产生的现金流量                                /2、  不涉及现金收支的投资和筹资活动
  CLEAR:LV_DMBTR,LV_HSL00.

  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 三、筹资活动产生的现金流量   ‘‘ LV_DMBTR   2、  不涉及现金收支的投资和筹资活动 ‘‘  ‘‘.

*24   吸收投资所收到的现金          38  原因代码301汇总  9,336,182.00     /债务转为资本 76
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 301.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 吸收投资所收到的现金   38 LV_DMBTR   债务转为资本 76  ‘‘.

*25   借款所收到的现金          40  原因代码302汇总  -                    /一年内到期的可转换公司债券 77
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 302.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 借款所收到的现金   40 LV_DMBTR   一年内到期的可转换公司债券 77  ‘‘.

*26   收到的其他与筹资活动有关的现金         43  原因代码303汇总          /融资租入固定资产 78
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 303.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING 收到的其他与筹资活动有关的现金   43 LV_DMBTR   融资租入固定资产 78  ‘‘.

*27   现金流入小计          44  301~303金额汇总                           /
  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:R_RSTGR,R_RSTGR[].

  R_RSTGR(3) = IBT.
  R_RSTGR-LOW  = 301.
  R_RSTGR-HIGH = 303.
  APPEND R_RSTGR.
  CLEAR R_RSTGR.

  LOOP AT GT_BSEG WHERE RSTGR IN R_RSTGR.
    LV_DMBTR = GT_BSEG-DMBTR + LV_DMBTR.
  ENDLOOP.
*&delete.
*LV_DMBTR = LV_DMBTR * -1.


  LV_HSL00 = 3.

  PERFORM FRM_APPEND_DATA USING      现金流入小计   44 LV_DMBTR   ‘‘ ‘‘  ‘‘.

*28   偿还债务所支付的现金          45  原因代码340汇总  -                /
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 340.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
*&add_lxq * -1
  LV_DMBTR = LV_DMBTR * -1.

  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 偿还债务所支付的现金   45 LV_DMBTR   ‘‘ ‘‘  ‘‘.

*29   分配股利、利润或偿付利息所支付的现金          46  原因代码341汇总  -/3、   现金及现金等价物净增加情况
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 341.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.

*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 分配股利、利润或偿付利息所支付的现金   46 LV_DMBTR   3、   现金及现金等价物净增加情况 ‘‘  ‘‘.

*30   支付的其他与筹资活动有关的现金         52  原因代码342汇总          /现金的期末余额           79  现金的期末余额=资产负债表“货币资金”期末余额(N?)
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 342.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.
  LV_DMBTR = LV_DMBTR * -1.



*&BC-30 1001*+1002*期末余额
  CLEAR:R_HKONT,R_HKONT[].
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001001*.
  APPEND R_HKONT.
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001002*.
  APPEND R_HKONT.
*&->start add by ABAP30 on 20160420 REQ BY fi_LJJ (期末余额/期末余额 添加银行清算科目: 1022*)
  R_HKONT(3) = ICP.
  R_HKONT-LOW = 001022*.
  APPEND R_HKONT.
*&->end add.

  DATA: L_NAME  TYPE CHAR13,
        L_NAME2 TYPE CHAR13,
        L_NAME_QC  TYPE CHAR13,
        L_NAME2_QC TYPE CHAR13.

*BREAK ABAP30.
  DATA:LV_QC LIKE FAGLFLEXT-HSL01,
       LV_QM LIKE FAGLFLEXT-HSL01.
  DATA:LT_FAGT_QC LIKE TABLE OF GT_FAGT WITH HEADER LINE,
       LT_FAGT_QM LIKE TABLE OF GT_FAGT WITH HEADER LINE.
*  DATA:LT_10021702 LIKE TABLE OF GT_FAGT WITH HEADER LINE,
*       LT_10021901 LIKE TABLE OF GT_FAGT WITH HEADER LINE.
  DATA:L_1_QC LIKE P_MONAT,
       L_1    LIKE P_MONAT.

  CLEAR:GT_FAGT[],LT_FAGT_QC[],LT_FAGT_QM[].
*&add_lxq FAGLFLEXT表中取现金的期末余额和期初余额
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE GT_FAGT
    FROM FAGLFLEXT
   WHERE RBUKRS EQ P_BUKRS
      AND RACCT IN R_HKONT
      AND RYEAR = P_GJAHR
      AND RRCTY = 0.

  IF SY-SUBRC EQ 0.

    DELETE GT_FAGT WHERE RACCT EQ 0010021702.
    DELETE GT_FAGT WHERE RACCT EQ 0010021901.

    CLEAR:L_NAME,L_NAME_QC.
    L_1_QC = S_MONAT-LOW - 1.
    CONCATENATE GT_FAGT-HSL S_MONAT-HIGH INTO L_NAME.

* IF L_1_QC = 00.
*   L_NAME_QC =  GT_FAGT-HSLVT.
* ELSE.
    CONCATENATE GT_FAGT-HSL L_1_QC INTO L_NAME_QC.
* ENDIF.

* BREAK ABAP30.
    BREAK TEST_13.
*&减:现金的期初余额
*& bug-fix by ABAP30 on 20160419 (期初余额取数错误【指针问题】)
    CLEAR:LV_QC,LV_QM.
    LOOP AT GT_FAGT.
      L_1_QC = S_MONAT-LOW - 1.
*&期初取选择的最小值
      ASSIGN (L_NAME_QC) TO <FN2_QC>.
      IF SY-SUBRC EQ 0.
      DO L_1_QC TIMES.
        IF L_1_QC GT 1.
*&->change by ABAP30 on 20160422 (期初余额 (当年的第一月期间到选择的前一个期间的金额合计))
*& 按月往前推(取期初不用推)-【需要按月汇总】
          L_1_QC = L_1_QC - 1.
          CONCATENATE GT_FAGT-HSL L_1_QC INTO L_NAME2_QC.
          ASSIGN (L_NAME2_QC) TO <FN1_QC>.
          <FN2_QC> = <FN2_QC> + <FN1_QC>.
        ENDIF.
      ENDDO.
        LT_FAGT_QC-HSLVT = <FN2_QC> + GT_FAGT-HSLVT.
      ELSE.
        LT_FAGT_QC-HSLVT = GT_FAGT-HSLVT.
      ENDIF.
      APPEND LT_FAGT_QC.
      CLEAR:LT_FAGT_QC,GT_FAGT.
    ENDLOOP.

    LOOP AT GT_FAGT.
*&期末取选择的最大值
      L_1 = S_MONAT-HIGH.
      ASSIGN (L_NAME) TO <FN2>.
      DO  S_MONAT-HIGH TIMES.
        IF L_1 GT 1.
          L_1 = L_1 - 1.
          CONCATENATE GT_FAGT-HSL L_1 INTO L_NAME2.
          ASSIGN (L_NAME2) TO <FN1>.
          <FN2> = <FN2> + <FN1>.
        ENDIF.
      ENDDO.
*&期末 = 余额结转 + 到当月
      LT_FAGT_QM-HSLVT = <FN2> + GT_FAGT-HSLVT.
      APPEND LT_FAGT_QM.
      CLEAR:LT_FAGT_QM,GT_FAGT.

    ENDLOOP.

  ENDIF.

  CLEAR:LV_QM,LV_QC.
*&20151110-期末余额
  LOOP AT LT_FAGT_QM.
    AT LAST.
      SUM.
      LV_QM = LT_FAGT_QM-HSLVT.
    ENDAT.
  ENDLOOP.
*&20151110-期初余额
  LOOP AT LT_FAGT_QC.
    AT LAST.
      SUM.
      LV_QC = LT_FAGT_QC-HSLVT.
    ENDAT.
  ENDLOOP.

  LV_HSL00 = LV_QM.
**& add on 20151108 排除 10021702&10021901
*  CLEAR:LV_HSL00_1,LV_HSL00_2.
*  READ TABLE LT_BSEG_BC WITH KEY HKONT = 10021702.
*  IF SY-SUBRC EQ 0.
*    LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*  ENDIF.
*  READ TABLE LT_BSEG_BC WITH KEY HKONT = 10021901.
*  IF SY-SUBRC EQ 0.
*    LV_HSL00 = LV_HSL00 - LT_BSEG_BC-DMBTR.
*  ENDIF.

* LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 支付的其他与筹资活动有关的现金   52 LV_DMBTR   现金的期末余额 79  LV_HSL00.

*31   现金流出小计   53  301~303金额汇总  -  /减:现金的期初余额       80 现金的期初余额=资产负债表“货币资金”期初余额(N?)
  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:R_RSTGR,R_RSTGR[].

*&add_lxq 340~342 的汇总
  R_RSTGR(3) = IBT.
  R_RSTGR-LOW = 340.
  R_RSTGR-HIGH = 342.
  APPEND R_RSTGR.

  LOOP AT GT_BSEG WHERE RSTGR IN R_RSTGR.
    LV_DMBTR = GT_BSEG-DMBTR + LV_DMBTR.
  ENDLOOP.
  LV_DMBTR = LV_DMBTR * -1.

  LV_HSL00 = LV_QC.
**&BC-31 1001*+1002*期初余额
*  CLEAR:R_HKONT,R_HKONT[].
*  R_HKONT(3) = ICP.
*  R_HKONT-LOW = 1001*.
*  APPEND R_HKONT.
*  R_HKONT(3) = ICP.
*  R_HKONT-LOW = 1002*.
*  APPEND R_HKONT.
*  LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
*    LV_HSL00 = LT_BSEG_BC-DMBTR + LV_HSL00.
*  ENDLOOP.
*  LV_HSL00 = 0 - LV_HSL00.
*&-> add on 20151108 期初的也不好取。
*LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING      现金流出小计   53 LV_DMBTR   减:现金的期初余额 80  LV_HSL00.

*32   筹资活动产生的现金流量净额         54  现金流入-现金流出            /加:现金等价物的期末余额 81
  DATA:LV_DMBTR_44 LIKE BSEG-DMBTR,
       LV_DMBTR_53 LIKE BSEG-DMBTR.

  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:LV_DMBTR_44,LV_DMBTR_53.

*&金额 = 现金流入-现金流出 (44-53)
  READ TABLE GT_DATA WITH KEY LINE_XM = 44.
  IF SY-SUBRC EQ 0.
    LV_DMBTR_44  = GT_DATA-DMBTR.
  ENDIF.
  READ TABLE GT_DATA WITH KEY LINE_XM = 53.
  IF SY-SUBRC EQ 0.
    LV_DMBTR_53  = GT_DATA-DMBTR.
  ENDIF.
*&->20151125加:现金等价物的期末余额 = 现金流入 - 现金流出.
  LV_DMBTR = LV_DMBTR_44 - LV_DMBTR_53.
*  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 筹资活动产生的现金流量净额   54 LV_DMBTR   加:现金等价物的期末余额 81  ‘‘.

*33 四、  汇率变动对现金流量的影响          55  原因代码400汇总           /减:现金等价物的期初余额 82
  CLEAR:LV_DMBTR,LV_HSL00.
  READ TABLE GT_BSEG WITH KEY RSTGR = 400.
  IF SY-SUBRC EQ 0.
    LV_DMBTR  = GT_BSEG-DMBTR.
  ENDIF.

  LV_HSL00 = 3.
  PERFORM FRM_APPEND_DATA USING 四、  汇率变动对现金流量的影响   55 LV_DMBTR   减:现金等价物的期初余额 82  ‘‘.

*34 五、  现金及现金等价物净增加额          56  净额类加总                /现金及现金等价物净增加额 83 现金的期末余额-现金的期初余额
  DATA:LV_DMBTR_21 LIKE BSEG-DMBTR,
       LV_DMBTR_37 LIKE BSEG-DMBTR,
       LV_DMBTR_54 LIKE BSEG-DMBTR,
       LV_DMBTR_55 LIKE BSEG-DMBTR.

  CLEAR:LV_DMBTR,LV_HSL00.
  CLEAR:LV_DMBTR_21,LV_DMBTR_37,LV_DMBTR_54,LV_DMBTR_55.

  READ TABLE GT_DATA WITH KEY LINE_XM = 21.
  LV_DMBTR_21 = GT_DATA-DMBTR.

  READ TABLE GT_DATA WITH KEY LINE_XM = 37.
  LV_DMBTR_37 = GT_DATA-DMBTR.

  READ TABLE GT_DATA WITH KEY LINE_XM = 54.
  LV_DMBTR_54 = GT_DATA-DMBTR.

  READ TABLE GT_DATA WITH KEY LINE_XM = 55.
  LV_DMBTR_55 = GT_DATA-DMBTR.
  LV_DMBTR  = LV_DMBTR_21 + LV_DMBTR_37 + LV_DMBTR_54 + LV_DMBTR_55.

*  CLEAR:LV_HSL00_1,LV_HSL00_2.
*  READ TABLE GT_DATA WITH KEY LINE_BC = 79.
*  LV_HSL00 = GT_DATA-HSL00.
*  READ TABLE GT_DATA WITH KEY LINE_BC = 80.
*  LV_HSL00 = LV_HSL00 - GT_DATA-HSL00.
  LV_HSL00 = LV_QM - LV_QC.

  PERFORM FRM_APPEND_DATA USING 五、  现金及现金等价物净增加额    56 LV_DMBTR   现金及现金等价物净增加额 83 LV_HSL00.

*&add备注:其他=经营性应付项目的增加-(2202*+2203*+2201*+2211*+2221*+2241*)(期末数-期间数)
  CLEAR:GV_BZ_HSL00.
  READ TABLE GT_DATA WITH KEY LINE_BC = 73.
  GV_BZ_HSL00 = GT_DATA-HSL00.

  CLEAR:R_HKONT,R_HKONT[],
        LV_HSL00_1.
  DEFINE MCR_RANGE .
    R_HKONT(3) = ICP.
    R_HKONT-LOW  = &1.
* R_HKONT-HIGH = &2.
    APPEND R_HKONT.
  END-OF-DEFINITION.

  MCR_RANGE:2202*.
  MCR_RANGE:2203*.
  MCR_RANGE:2201*.
  MCR_RANGE:2211*.
  MCR_RANGE:2221*.
  MCR_RANGE:2241*.

  LOOP AT LT_BSEG_BC WHERE HKONT IN R_HKONT.
    LV_HSL00_1 = LV_HSL00_1 + LT_BSEG_BC-DMBTR.
  ENDLOOP.
  LV_HSL00_1 = LV_HSL00_1 * -1.
  GV_BZ_HSL00 = GV_BZ_HSL00 - LV_HSL00_1.

*&条目数
  G_LEN = LINES( GT_DATA ).
  IF G_LEN EQ 0.
    MESSAGE I003 WITH 没有找到符合条件的数据!.
    STOP.
  ELSE.
    MESSAGE S003 WITH 找到数据条目数: G_LEN.
  ENDIF.

ENDFORM.                    " FRM_GET_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ALV_OUTPUT .
  DATA:LV_COL        TYPE I.
  DATA:LV_LINES      TYPE I.
  DATA:LV_GRID_TITLE TYPE LVC_TITLE.
  DATA:LW_DATA LIKE GT_DATA.

  DEFINE MAR_ADD_FIELDCAT0.
    CLEAR WA_FIELDCAT.
    LV_COL = LV_COL + 1.
    WA_FIELDCAT-FIELDNAME    =  &1.
    WA_FIELDCAT-SELTEXT_L    =  &2.
    WA_FIELDCAT-COL_POS      =  LV_COL.
    WA_FIELDCAT-KEY          =  &3.
    WA_FIELDCAT-JUST         =  &4.
    WA_FIELDCAT-OUTPUTLEN    =  &5.
    WA_FIELDCAT-NO_OUT       =  &6.
    WA_FIELDCAT-EDIT         =  &7.
    WA_FIELDCAT-NO_ZERO      =  &8.
    WA_FIELDCAT-EMPHASIZE    =  &9.
*    WA_FIELDCAT-EDIT_MASK = &9.
*WA_FIELDCAT-DO_SUM       =  &8.
*WA_FIELDCAT-NO_ZERO      =  &9.
*WA_FIELDCAT-EDIT_MASK    =  &10.
*WA_FIELDCAT-EMPHASIZE    =  &10.
    APPEND WA_FIELDCAT TO GT_FIELDCAT.
  END-OF-DEFINITION.

*BREAK ABAP30.
*&->start add by ABAP30 on 20160414 现金流量表 项目栏与补充资料最后一个项目不等时报错-B315
  LOOP AT GT_DATA WHERE LINE_XM = 56.
    READ TABLE GT_DATA INTO LW_DATA WITH KEY LINE_BC = 83.
    IF GT_DATA-DMBTR NE LW_DATA-HSL00.
      MESSAGE I003 WITH 报表不平!.
*      CONTINUE.
    ENDIF.
  ENDLOOP.
*&->end add.

*&设定输出格式:
  CLEAR GS_LAYOUT.
  MOVE:  X   TO  GS_LAYOUT-ZEBRA,
         X   TO  GS_LAYOUT-COLWIDTH_OPTIMIZE,
         X   TO  GS_LAYOUT-DETAIL_POPUP.
  GS_LAYOUT-BOX_FIELDNAME    = SEL.
  GS_LAYOUT-INFO_FIELDNAME   = ROWCOLOR.
*GS_LAYOUT-LIGHTS_FIELDNAME = ICON.

  CLEAR:WA_FIELDCAT,GT_FIELDCAT[].

  MAR_ADD_FIELDCAT0 :"LIN     序号           ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ C110 ,

  TEXT_XM 项目      ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ,
  LINE_XM 行次      ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ,
  DMBTR   金额      ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘,
  TEXT_BC 补充资料  ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ,
  LINE_BC 行次      ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ,
  HSL00   金额      ‘‘  ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ ‘‘ .

  CALL FUNCTION REUSE_ALV_GRID_DISPLAY
    EXPORTING
      I_CALLBACK_PROGRAM          = SY-CPROG
      I_CALLBACK_PF_STATUS_SET    = SET_PF_STATUS "设定菜单栏
      I_CALLBACK_USER_COMMAND     = USER_COMMAND "设定对应菜单项及相应事件功能:如双击、保存等
      I_SAVE                      = A
      IS_LAYOUT                   = GS_LAYOUT           "输出布局设置
      IT_FIELDCAT                 = GT_FIELDCAT         "输出字段列信息内表
      I_CALLBACK_HTML_TOP_OF_PAGE = HTML_TOP_OF_PAGE
*     I_CALLBACK_HTML_END_OF_LIST = HTML_END_OF_PAGE
      I_HTML_HEIGHT_TOP           = 26
      I_HTML_HEIGHT_END           = 8
    TABLES
      T_OUTTAB                    = GT_DATA.               "需显示的数据内表

*  IF P_3000 NE X.
*    CALL FUNCTION REUSE_ALV_LIST_DISPLAY
*      EXPORTING
*        I_CALLBACK_PROGRAM          = SY-CPROG" SY-REPID
*        I_CALLBACK_PF_STATUS_SET    = SET_PF_STATUS
*        I_CALLBACK_USER_COMMAND     = USER_COMMAND
*        I_SAVE                      = A
*        IS_LAYOUT                   = GS_LAYOUT        "输出布局设置
*        IT_FIELDCAT                 = GT_FIELDCAT      "输出字段列信息内表
**       I_SCREEN_START_COLUMN       = Report
*        I_SCREEN_END_COLUMN         = 0
*        I_SCREEN_START_LINE         = 0
**       I_SCREEN_END_LINE           = 10000
**       IR_SALV_LIST_ADAPTER        = TEST
**       I_CALLBACK_HTML_TOP_OF_PAGE = ALV_TOP_OF_PAGE "list ->没有这个参数
**       I_HTML_HEIGHT_TOP           = 20
*      TABLES
*        T_OUTTAB                    = GT_DATA.         "需显示的数据内表
*  ELSE.
*  ENDIF.

ENDFORM.                    " FRM_ALV_OUTPUT
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM  USER_COMMAND  USING  R_UCOMM  LIKE  SY-UCOMM
      RS_SELFIELD  TYPE  SLIS_SELFIELD  .
  DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID,
        MYINDEX TYPE SY-TABIX.
*  CALL FUNCTION GET_GLOBALS_FROM_SLVC_FULLSCR
*    IMPORTING
*      E_GRID = LR_GRID.
*  CALL METHOD LR_GRID->CHECK_CHANGED_DATA.
*  RS_SELFIELD-REFRESH = X.

  CASE  R_UCOMM.
    WHEN &PRSO.
      PERFORM PRINTDATA.
  ENDCASE.
  CLEAR R_UCOMM.


ENDFORM.                    "alv_user_command
*&---------------------------------------------------------------------*
*&      Form  SET_PF_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->EXTAB      text
*----------------------------------------------------------------------*
FORM  SET_PF_STATUS  USING    EXTAB  TYPE  SLIS_T_EXTAB.
  SET  PF-STATUS  Z_F103_01.
ENDFORM.                    "SET_PF
*&---------------------------------------------------------------------*
*&      Form  html_top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->DOCUMENT   text
*----------------------------------------------------------------------*
FORM HTML_TOP_OF_PAGE USING DOCUMENT TYPE REF TO CL_DD_DOCUMENT.
  DATA: TEXT TYPE SDYDO_TEXT_ELEMENT.
  DATA: S_CONTENTS TYPE STRING.
  DATA: POSITION TYPE I.
  DATA: C_MONTH TYPE CHAR3.

  SEARCH DOCUMENT->HTML_TABLE FOR DOCUMENT->CURSOR.
  IF SY-SUBRC EQ 0.
    POSITION = SY-TABIX.
*&H1.东莞添威电子制品有限公司
    TEXT = 东莞添威电子制品有限公司.
    CONCATENATE <span align="center" style=" font-weight:bold;"><H3>‘ TEXT ‘</H3></span> </DIV>‘ INTO S_CONTENTS.
    CALL METHOD DOCUMENT->HTML_INSERT
      EXPORTING
        CONTENTS = <div class=MsoNormal align=center style="text-align:center"> 
      CHANGING
        POSITION = POSITION.
    CALL METHOD DOCUMENT->HTML_INSERT
      EXPORTING
        CONTENTS = S_CONTENTS
      CHANGING
        POSITION = POSITION.
  ENDIF.

  CALL METHOD DOCUMENT->NEW_LINE.

*&H2.现金流量表
  TEXT = 现金流量表     会企03表.
  CONCATENATE <span align="center" style=" font-weight:bold;"><H4> TEXT </H4></span> </DIV> INTO S_CONTENTS.
  CALL METHOD DOCUMENT->HTML_INSERT
    EXPORTING
      CONTENTS = <div class=MsoNormal align=center style="text-align:center"> 
    CHANGING
      POSITION = POSITION.
  CALL METHOD DOCUMENT->HTML_INSERT
    EXPORTING
      CONTENTS = S_CONTENTS
    CHANGING
      POSITION = POSITION.

*&H3.P_GJAHR年度
  CONCATENATE P_GJAHR 年度  S_MONAT-LOW 月- S_MONAT-HIGH 月  单位:元 INTO TEXT.
  CONCATENATE <span align="center" style=" font-weight:bold;"><H5> TEXT </H5></span> </DIV> INTO S_CONTENTS.
  CALL METHOD DOCUMENT->HTML_INSERT
    EXPORTING
      CONTENTS = <div class=MsoNormal align=center style="text-align:center"> 
    CHANGING
      POSITION = POSITION.
  CALL METHOD DOCUMENT->HTML_INSERT
    EXPORTING
      CONTENTS = S_CONTENTS
    CHANGING
      POSITION = POSITION.

**&H3.年度
*  CALL METHOD DOCUMENT->ADD_GAP
*    EXPORTING
*      WIDTH = 30.
*  CONCATENATE P_GJAHR ‘年度‘ INTO TEXT.
*  CALL METHOD DOCUMENT->ADD_TEXT
*    EXPORTING
*      TEXT         = TEXT
*      SAP_EMPHASIS = ‘Strong‘.
*
*  CALL METHOD DOCUMENT->ADD_GAP
*    EXPORTING
*      WIDTH = 30.
*  TEXT = ‘单位:元‘.
*  CALL METHOD DOCUMENT->ADD_TEXT
*    EXPORTING
*      TEXT         = TEXT
*      SAP_EMPHASIS = ‘Strong‘.

*  CONCATENATE P_GJAHR ‘年‘ C_MONTH ‘月‘ INTO TEXT.
*  CALL METHOD DOCUMENT->ADD_TEXT
*    EXPORTING
*      TEXT         = TEXT
*      SAP_EMPHASIS = ‘Strong‘.
*
*  CALL METHOD DOCUMENT->ADD_GAP
*    EXPORTING
*      WIDTH = 13.
*
*  TEXT = ‘单位:元‘.
*  CALL METHOD DOCUMENT->ADD_TEXT
*    EXPORTING
*      TEXT         = TEXT
*      SAP_EMPHASIS = ‘‘.
*
*  CALL METHOD DOCUMENT->UNDERLINE.   "Draw  an underLine
ENDFORM.                    "HTML_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*&      Form  html_top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->DOCUMENT   text
*----------------------------------------------------------------------*
FORM HTML_END_OF_PAGE USING DOCUMENT TYPE REF TO CL_DD_DOCUMENT.
  DATA: TEXT   TYPE SDYDO_TEXT_ELEMENT,
        TEXT_1 TYPE SDYDO_TEXT_ELEMENT.
  DATA: S_CONTENTS TYPE STRING.
  DATA: POSITION TYPE I.
  DATA: LV_BZ_HSL00 LIKE FAGLFLEXT-HSL01.
  DATA: LV_JINE TYPE STRING.

*BREAK ABAP30.
  CLEAR:LV_JINE.
  LV_JINE = GV_BZ_HSL00.
  IF LV_JINE IS NOT INITIAL.
    TEXT_1 = LV_JINE.
  ELSE.
    TEXT_1 = 0.00.
  ENDIF.

  IF TEXT_1 CS -.
    CALL FUNCTION CLOI_PUT_SIGN_IN_FRONT
      CHANGING
        VALUE  = TEXT_1
      EXCEPTIONS
        OTHERS = 1.
  ENDIF.

  CONCATENATE 备注:其他 =  TEXT INTO TEXT SEPARATED BY SPACE.
* TEXT = ‘备注:其他=经营性应付项目的增加-(2202*+2203*+2201*+2211*+2221*+2241*)(期末数-期间数)‘.
  CALL METHOD DOCUMENT->ADD_TEXT
    EXPORTING
      TEXT         = TEXT
      SAP_EMPHASIS = ‘‘.

  CALL METHOD DOCUMENT->ADD_TEXT
    EXPORTING
      TEXT         = TEXT_1
      SAP_EMPHASIS = ‘‘.

ENDFORM.                    "HTML_END_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  FRM_INIT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_INIT_DATA .


ENDFORM.                    " FRM_INIT_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_APPEND_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0399   text
*      -->P_0400   text
*      -->P_0401   text
*      -->P_0402   text
*      -->P_0403   text
*      -->P_0404   text
*  GT_DATA-TEXT_XM = ‘一、经营活动产生的现金流量:‘.
*  GT_DATA-LINE_XM = ‘‘.
*  GT_DATA-DMBTR   = ‘‘.
*  GT_DATA-TEXT_BC = ‘1、将净利润调节为经营活动现金流量  ‘.
*  GT_DATA-LINE_BC = ‘‘.
*  GT_DATA-HSL00   = ‘‘.
*----------------------------------------------------------------------*
FORM FRM_APPEND_DATA  USING    VALUE(TEXT_XM)
                               VALUE(LINE_XM)
                               VALUE(DMBTR)
                               VALUE(TEXT_BC)
                               VALUE(LINE_BC)
                               VALUE(HSL00).

  GT_DATA-TEXT_XM = TEXT_XM.
  GT_DATA-LINE_XM = LINE_XM.
  GT_DATA-DMBTR   = DMBTR.
  GT_DATA-TEXT_BC = TEXT_BC.
  GT_DATA-LINE_BC = LINE_BC.
  GT_DATA-HSL00   = HSL00.
  APPEND GT_DATA.
  CLEAR:GT_DATA.

ENDFORM.                    " FRM_APPEND_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_1000
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_1000 .
*&取1000公司代码数据 FAGLFLEXT
  DATA: L_NAME  TYPE CHAR13,
        L_NAME2 TYPE CHAR13,
        L_YEAR  TYPE CHAR13,
        L_YEAR2 TYPE CHAR13,
  L_1 LIKE P_MONAT,
  L_2 LIKE P_MONAT.
  DATA: LT_ZFI030 LIKE ZFI030 OCCURS 0 WITH HEADER LINE.

  DATA: BEGIN OF LT_ITAC OCCURS 0,
         ZZSUM  LIKE ZFI030-ZZSUM,
         ZZNUMB LIKE ZFI030-ZZNUMB,
         DMBTR LIKE FAGLFLEXT-HSLVT,
        END OF LT_ITAC.
  DATA: LT_TAB1 LIKE LT_ITAC OCCURS 0 WITH HEADER LINE,
        LT_TAB2 LIKE LT_ITAC OCCURS 0 WITH HEADER LINE,
        LT_TAB3 LIKE LT_ITAC OCCURS 0 WITH HEADER LINE,
        LT_TAB4 LIKE LT_ITAC OCCURS 0 WITH HEADER LINE.
  DATA: L_DMBTR1 LIKE FAGLFLEXT-HSLVT,
        L_DMBTR2 LIKE FAGLFLEXT-HSLVT,
        L_DMBTR3 LIKE FAGLFLEXT-HSLVT.
  DATA: L_WRBTR  LIKE FAGLFLEXT-HSLVT.
  DATA: L_DMBTR(15) TYPE P DECIMALS 5.
  DATA: FLD_NAME TYPE CHAR20.
  FIELD-SYMBOLS: <FLD_VALUE> TYPE ANY.
  FIELD-SYMBOLS: <FLD_VALUE_S> TYPE ANY.
  FIELD-SYMBOLS: <FLD_VALUE_H> TYPE ANY.
  DATA:LT_C1_002 LIKE TABLE OF GT_TAB WITH HEADER LINE,
       LT_C5_002 LIKE TABLE OF GT_TAB WITH HEADER LINE,
       LT_C5_003 LIKE TABLE OF GT_TAB WITH HEADER LINE.

  DATA:LT_ZFIT103 LIKE TABLE OF ZFIT103 WITH HEADER LINE.
  DATA:BEGIN OF LT_BSIS OCCURS 0,
          BUKRS LIKE BSIS-BUKRS,
          BELNR LIKE BSIS-BELNR,
          GJAHR LIKE BSIS-GJAHR,
          BUZEI LIKE BSIS-BUZEI,
          HKONT LIKE BSIS-HKONT,
          MONAT LIKE BSIS-MONAT,
         SHKZG LIKE BSIS-SHKZG,"借贷方(S(+) H(-))
         DMBTR LIKE BSIS-DMBTR,"项目金额-BSEG
        END OF LT_BSIS.
  DATA:BEGIN OF LT_BSIS_S OCCURS 0,
         MONAT LIKE BSIS-MONAT,
         SHKZG LIKE BSIS-SHKZG,"借贷方(S(+) H(-))
         DMBTR LIKE BSIS-DMBTR,"项目金额-BSEG
      END OF LT_BSIS_S.
  DATA:LT_BSIS_L LIKE TABLE OF LT_BSIS_S WITH HEADER LINE.
  DATA:BEGIN OF LT_BSEG OCCURS 0,
         BUKRS LIKE BSEG-BUKRS,
         BELNR LIKE BSEG-BELNR,
         BUZEI LIKE BSEG-BUZEI,
         GJAHR LIKE BSEG-GJAHR,"会计年度
         RSTGR LIKE BSEG-RSTGR,"原因代码
         HKONT LIKE BSEG-HKONT,"科目
         SHKZG LIKE BSEG-SHKZG,"借贷方(S(+) H(-))
         DMBTR LIKE BSEG-DMBTR,"项目金额-BSEG
       END OF LT_BSEG.
  RANGES:R_KUNNR FOR KNA1-KUNNR.
  RANGES:R_LIFNR FOR LFA1-LIFNR.
  RANGES:R_HKONT1 FOR BSEG-HKONT,
         R_HKONT2 FOR BSEG-HKONT,
         R_HKONT3 FOR BSEG-HKONT,
         R_HKONT4 FOR BSEG-HKONT.

  CLEAR:R_HKONT1,R_HKONT1[].
  R_HKONT1(3) = IBT.
  R_HKONT1-LOW = 0060000000.
  R_HKONT1-HIGH = 0069999999.
  APPEND R_HKONT1.

  CLEAR:R_HKONT2,R_HKONT2[].
  R_HKONT2(3) = IBT.
  R_HKONT2-LOW = 0068010000.
  R_HKONT2-HIGH = 0068019999.
  APPEND R_HKONT2.

*BREAK ABAP30.
*&S1.取1000版本数据 GT_1000
  SELECT ZZNUMB ZZTEXT ZZSUM ZZTXPE
    FROM ZFI030_TEXT
    INTO TABLE GT_1000
   WHERE ZZTYPE = C.
  SORT GT_1000 BY ZZNUMB.

*&S2.取现金流量表对应科目(ZFI030)
  SELECT *
    FROM ZFI030
    INTO CORRESPONDING FIELDS OF TABLE LT_ZFI030
   WHERE ZZTYPE = C.

*&B1.不可删除重复
*  SORT LT_ZFI030 BY HKONT.
*  DELETE ADJACENT DUPLICATES FROM LT_ZFI030 COMPARING HKONT.
  IF LT_ZFI030[] IS NOT INITIAL.
*&取T表所有数据
    SELECT *
      INTO CORRESPONDING FIELDS OF TABLE GT_FAGT
      FROM FAGLFLEXT
     WHERE RBUKRS = P_BUKRS
       AND RYEAR = P_GJAHR
       AND RRCTY = 0.
    SORT GT_FAGT BY RACCT.
  ENDIF.

  DATA:LT_C7_001 LIKE TABLE OF GT_TAB WITH HEADER LINE,
       LT_C7_001_SUM LIKE TABLE OF GT_TAB WITH HEADER LINE.
  DATA:LV_GJAHR LIKE P_GJAHR.
*&A13.C7-001 期初余额,本年累计的期初余额为上年期末余额
*& 取HSL01 为上年12月的值
  LV_GJAHR = P_GJAHR."change by baiyuzhuang
  CLEAR:LT_C7_001, LT_C7_001[].
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE LT_C7_001
    FROM FAGLFLEXT AS A
    JOIN ZFI030 AS B
      ON A~RACCT EQ B~HKONT
   WHERE RBUKRS = P_BUKRS
     AND RYEAR = LV_GJAHR
     AND RRCTY = 0
    AND ZZNUMB = C7-001."add by baiyuzhuang
  IF SY-SUBRC EQ 0.
    LOOP AT LT_C7_001.
      MOVE-CORRESPONDING LT_C7_001 TO LT_C7_001_SUM.
      LT_C7_001_SUM-ZZNUMB = C7-001.
      CLEAR : LT_C7_001_SUM-HKONT.
      COLLECT LT_C7_001_SUM.
      CLEAR LT_C7_001_SUM.
    ENDLOOP.
  ENDIF.
  LV_GJAHR = P_GJAHR - 1.

*&S4.得到 1-12期间的余额,
  LOOP AT GT_FAGT.
*&A1.C1-002【Profit before income tax expense】取数逻辑:(60000000到69999999加总)-(68010000到68019999的加总)
*& 计算 C1-002 栏位的值,
    IF GT_FAGT-RACCT IN R_HKONT1.
      IF GT_FAGT-RACCT IN R_HKONT2.
*&排除科目(68010000到68019999的加总)
      ELSE.
        MOVE-CORRESPONDING GT_FAGT TO LT_C1_002.
        LT_C1_002-HSL01_Y = LT_C1_002-HSL01 + LT_C1_002-HSL02 + LT_C1_002-HSL03 + LT_C1_002-HSL04
                          + LT_C1_002-HSL05 + LT_C1_002-HSL06 + LT_C1_002-HSL07 + LT_C1_002-HSL08
                          + LT_C1_002-HSL09 + LT_C1_002-HSL10 + LT_C1_002-HSL11 + LT_C1_002-HSL12.
        CLEAR:LT_C1_002-ZZSUM,LT_C1_002-ZZNUMB,LT_C1_002-HKONT.
        LT_C1_002-ZZNUMB = C1-002.
        COLLECT LT_C1_002.
        CLEAR LT_C1_002.
      ENDIF.
    ENDIF.

*&E7.C5-002 增加借款(贷方金额)2501*    ‘H’条目汇总
*& 20151117‘H’贷方金额且贷方金额为正,要(*-1)
    IF GT_FAGT-RACCT(6) = 002501 AND GT_FAGT-DRCRK = H.
      MOVE-CORRESPONDING GT_FAGT TO LT_C5_002.
      LT_C5_002-ZZNUMB = C5-002.
      LT_C5_002-HSL01_Y = GT_FAGT-HSL01 + GT_FAGT-HSL02 + GT_FAGT-HSL03 + GT_FAGT-HSL04
                        + GT_FAGT-HSL05 + GT_FAGT-HSL06 + GT_FAGT-HSL07 + GT_FAGT-HSL08
                        + GT_FAGT-HSL09 + GT_FAGT-HSL10 + GT_FAGT-HSL11 + GT_FAGT-HSL12.
      COLLECT LT_C5_002.
      CLEAR LT_C5_002.
    ENDIF.
*&>E8.C5-003 -还款金额(借方金额)2501*    ‘S’条目汇总
    IF GT_FAGT-RACCT(6) = 002501 AND GT_FAGT-DRCRK = S.
      MOVE-CORRESPONDING GT_FAGT TO LT_C5_003.
      LT_C5_003-ZZNUMB = C5-003.
      LT_C5_003-HSL01_Y = GT_FAGT-HSL01 + GT_FAGT-HSL02 + GT_FAGT-HSL03 + GT_FAGT-HSL04
                        + GT_FAGT-HSL05 + GT_FAGT-HSL06 + GT_FAGT-HSL07 + GT_FAGT-HSL08
                        + GT_FAGT-HSL09 + GT_FAGT-HSL10 + GT_FAGT-HSL11 + GT_FAGT-HSL12.
      COLLECT LT_C5_003.
      CLEAR LT_C5_003.
    ENDIF.

*&S4.1读取科目对应的余额,/期初结转/当年累积/分月余额,
    LOOP AT LT_ZFI030 WHERE HKONT = GT_FAGT-RACCT AND ZZNUMB NE C5-003.
*READ TABLE LT_ZFI030 WITH KEY HKONT = GT_FAGT-RACCT.
*    IF SY-SUBRC EQ 0.
      GT_TAB-ZZSUM  = LT_ZFI030-ZZSUM. "汇总栏位
      GT_TAB-ZZNUMB = LT_ZFI030-ZZNUMB."栏位编号
      GT_TAB-HKONT  = GT_FAGT-RACCT.   "总账科目
*&S4.2本年累计
      GT_TAB-HSL01_Y = GT_FAGT-HSL01 + GT_FAGT-HSL02 + GT_FAGT-HSL03 + GT_FAGT-HSL04
                     + GT_FAGT-HSL05 + GT_FAGT-HSL06 + GT_FAGT-HSL07 + GT_FAGT-HSL08
                     + GT_FAGT-HSL09 + GT_FAGT-HSL10 + GT_FAGT-HSL11 + GT_FAGT-HSL12.
*&S4.3用本币计算的结转余额
      GT_TAB-HSLVT = GT_FAGT-HSLVT.
      GT_TAB-HSL01 = GT_FAGT-HSL01.
      GT_TAB-HSL02 = GT_FAGT-HSL02.
      GT_TAB-HSL03 = GT_FAGT-HSL03.
      GT_TAB-HSL04 = GT_FAGT-HSL04.
      GT_TAB-HSL05 = GT_FAGT-HSL05.
      GT_TAB-HSL06 = GT_FAGT-HSL06.
      GT_TAB-HSL07 = GT_FAGT-HSL07.
      GT_TAB-HSL08 = GT_FAGT-HSL08.
      GT_TAB-HSL09 = GT_FAGT-HSL09.
      GT_TAB-HSL10 = GT_FAGT-HSL10.
      GT_TAB-HSL11 = GT_FAGT-HSL11.
      GT_TAB-HSL12 = GT_FAGT-HSL12.
*    ELSE.
*      MOVE-CORRESPONDING GT_FAGT TO GT_TAB.
*      GT_TAB-HKONT  = GT_FAGT-RACCT.   "总账科目
*      GT_TAB-HSL01_Y = GT_FAGT-HSL01 + GT_FAGT-HSL02 + GT_FAGT-HSL03 + GT_FAGT-HSL04
*                     + GT_FAGT-HSL05 + GT_FAGT-HSL06 + GT_FAGT-HSL07 + GT_FAGT-HSL08
*                     + GT_FAGT-HSL09 + GT_FAGT-HSL10 + GT_FAGT-HSL11 + GT_FAGT-HSL12.
      COLLECT GT_TAB.
      CLEAR:GT_TAB,LT_ZFI030.
*    ENDIF
      .
    ENDLOOP.
    CLEAR:GT_FAGT.
  ENDLOOP.
  SORT GT_TAB BY ZZSUM ZZNUMB.

  CLEAR:GT_SUM_C,GT_SUM_C[],
        GT_SUM_S,GT_SUM_S[].
*&change on 2015119 更改汇总方式
*&S5.根据栏位编码汇总金额
  LOOP AT GT_TAB.

    MOVE-CORRESPONDING GT_TAB TO GT_SUM_C.
    "add by abap20 20151120

    CLEAR:GT_SUM_C-ZZSUM, GT_SUM_C-HKONT.
    COLLECT GT_SUM_C.
    CLEAR GT_SUM_C.

    MOVE-CORRESPONDING GT_TAB TO GT_SUM_S.
    "add by abap20 20151120
    IF  GT_SUM_S-ZZNUMB = C1-006OR GT_SUM_S-ZZNUMB = C1-007OR GT_SUM_S-ZZNUMB = C4-004
    OR GT_SUM_S-ZZNUMB = C2-001 OR GT_SUM_S-ZZNUMB = C2-003 OR GT_SUM_S-ZZNUMB = C2-006
    OR GT_SUM_S-ZZNUMB = C3-001 OR GT_SUM_S-ZZNUMB = C3-002
    OR GT_SUM_S-ZZNUMB = C4-002
    OR GT_SUM_S-ZZNUMB = C5-005
      .
      GT_SUM_S-HSL01_Y = GT_SUM_S-HSL01_Y * -1.
      GT_SUM_S-HSLVT = GT_SUM_S-HSLVT * -1.
      GT_SUM_S-HSL01 = GT_SUM_S-HSL01  * -1.
      GT_SUM_S-HSL02 = GT_SUM_S-HSL02  * -1.
      GT_SUM_S-HSL03 = GT_SUM_S-HSL03  * -1.
      GT_SUM_S-HSL04 = GT_SUM_S-HSL04  * -1.
      GT_SUM_S-HSL05 = GT_SUM_S-HSL05  * -1.
      GT_SUM_S-HSL06 = GT_SUM_S-HSL06  * -1.
      GT_SUM_S-HSL07 = GT_SUM_S-HSL07  * -1.
      GT_SUM_S-HSL08 = GT_SUM_S-HSL08  * -1.
      GT_SUM_S-HSL09 = GT_SUM_S-HSL09  * -1.
      GT_SUM_S-HSL10 = GT_SUM_S-HSL10  * -1.
      GT_SUM_S-HSL11 = GT_SUM_S-HSL11  * -1.
      GT_SUM_S-HSL12 = GT_SUM_S-HSL12  * -1.
    ENDIF.
    "end add
    CLEAR:GT_SUM_S-ZZNUMB, GT_SUM_S-HKONT.
    COLLECT GT_SUM_S.
    CLEAR GT_SUM_S.

**&A1.C1-002【Profit before income tax expense】取数逻辑:(60000000到69999999加总)-(68010000到68019999的加总)
**& 计算 C1-002 栏位的值,
*    IF GT_TAB-HKONT IN R_HKONT1.
*      IF GT_TAB-HKONT IN R_HKONT2.
**&排除科目(68010000到68019999的加总)
*      ELSE.
*        MOVE-CORRESPONDING GT_TAB TO LT_C1_002.
*        CLEAR:LT_C1_002-ZZSUM,LT_C1_002-ZZNUMB,LT_C1_002-HKONT.
*        LT_C1_002-ZZNUMB = ‘C1-002‘.
*        COLLECT LT_C1_002.
*        CLEAR LT_C1_002.
*      ENDIF.
*    ENDIF.
  ENDLOOP.

*BREAK ABAP30.
**&A.C2-004  1122*(针对部分客户)* (-1)
**&计算C2-004 栏位值
  CLEAR:LT_ZFIT103,LT_ZFIT103[].
  SELECT *
    INTO TABLE LT_ZFIT103
    FROM ZFIT103.

  IF SY-SUBRC EQ 0.
    LOOP AT LT_ZFIT103 WHERE ZZNUMB EQ C2-004.
      R_KUNNR(3) = IEQ.
      R_KUNNR-LOW = LT_ZFIT103-KUNNR.
      APPEND R_KUNNR.
      CLEAR R_KUNNR.
    ENDLOOP.
**&通过BSIS 索引找BSEG
*    CLEAR:LT_BSIS,LT_BSIS[].
*    SELECT  BUKRS BELNR
*            GJAHR BUZEI
*            HKONT MONAT
*            SHKZG DMBTR
*      INTO TABLE LT_BSIS
*      FROM BSIS
**       FOR ALL ENTRIES IN LT_ZFIT103
*     WHERE BUKRS EQ P_BUKRS
*       AND HKONT LIKE ‘001122%‘
*       AND GJAHR EQ P_GJAHR.
*    "ADD BY ABAP20 20151120  已请未清都取
*    SELECT  BUKRS BELNR
*    GJAHR BUZEI
*    HKONT MONAT
*    SHKZG DMBTR
*    APPENDING TABLE LT_BSIS
*    FROM BSAD
**       FOR ALL ENTRIES IN LT_ZFIT103
*    WHERE BUKRS EQ P_BUKRS
*    AND HKONT LIKE ‘001122%‘
*    AND GJAHR EQ P_GJAHR.
*    "ADD BY ABAP20 20151120
*    SORT LT_BSIS BY BUKRS BELNR GJAHR.
*    DELETE ADJACENT DUPLICATES FROM LT_BSIS COMPARING BUKRS BELNR GJAHR.
*
*    IF SY-SUBRC EQ 0.
*      CLEAR:LT_BSEG,LT_BSEG[].
*      SELECT BUKRS BELNR
*             BUZEI GJAHR
*             RSTGR HKONT
*             SHKZG DMBTR
*        INTO TABLE LT_BSEG
*        FROM BSEG
*         FOR ALL ENTRIES IN LT_BSIS
*       WHERE BUKRS = LT_BSIS-BUKRS
*         AND BELNR = LT_BSIS-BELNR
*         AND GJAHR = LT_BSIS-GJAHR
*         AND KUNNR IN R_KUNNR.
*      SORT LT_BSEG BY BUKRS GJAHR BELNR.
*
*      LOOP AT LT_BSIS.
*        READ TABLE LT_BSEG WITH KEY BUKRS = LT_BSIS-BUKRS
*                                    GJAHR = LT_BSIS-GJAHR
*                                    BELNR = LT_BSIS-BELNR BINARY SEARCH.
*        IF SY-SUBRC <> 0.
*          DELETE LT_BSIS.
*          CONTINUE.
*        ENDIF.
*      ENDLOOP.
*    ENDIF.
*  ENDIF.
**& 按期间汇总 BSIS 金额
*  CLEAR:LT_BSIS_S,LT_BSIS_S[].
*  LOOP AT LT_BSIS.
*    LT_BSIS_S-MONAT = LT_BSIS-MONAT.
*    IF LT_BSIS-SHKZG = ‘H‘.
*      LT_BSIS_S-DMBTR = LT_BSIS-DMBTR * -1.
*    ELSE.
*      LT_BSIS_S-DMBTR = LT_BSIS-DMBTR.
*    ENDIF.
*    COLLECT LT_BSIS_S.
*    CLEAR LT_BSIS_S.
*  ENDLOOP.
    "ADD BY ABAP20
    DATA :LT_KNC1 TYPE TABLE OF KNC1 WITH HEADER LINE.
    DATA :LT_KNC1_S TYPE TABLE OF KNC1 WITH HEADER LINE.
    SELECT * FROM KNC1 INTO TABLE LT_KNC1 WHERE KUNNR IN R_KUNNR AND GJAHR EQ P_GJAHR AND BUKRS = P_BUKRS.
    LOOP AT LT_KNC1.
      MOVE  LT_KNC1 TO LT_KNC1_S.
      LT_KNC1_S-KUNNR = ‘‘.
      LT_KNC1_S-ERDAT =  ‘‘.
      LT_KNC1_S-USNAM =  ‘‘.
      COLLECT LT_KNC1_S.
      CLEAR LT_KNC1_S.
    ENDLOOP.
  ENDIF.
  "END ADD BY ABAP20
*& A6.C2-007 加 2202* (针对部分供应商)【(Decrease)/increase in amounts due to related  companies on trade accounts】
*& 计算C2-007 栏位值
  DATA:LT_USE LIKE TABLE OF LT_BSIS WITH HEADER LINE.
  DATA:L_LAST TYPE C,
       L_COUNT TYPE I,
       L_NMAX TYPE I.

  LOOP AT LT_ZFIT103 WHERE ZZNUMB EQ C2-007.
    R_LIFNR(3) = IEQ.
    R_LIFNR-LOW = LT_ZFIT103-LIFNR.
    APPEND R_LIFNR.
    CLEAR R_LIFNR.
  ENDLOOP.
  LOOP AT LT_ZFI030 WHERE ZZNUMB EQ C2-007.
    R_HKONT3(3) = IEQ.
    R_HKONT3-LOW = LT_ZFI030-HKONT.
    APPEND R_HKONT3.
    CLEAR R_HKONT3.
  ENDLOOP.
  LOOP AT LT_ZFI030 WHERE ZZNUMB EQ C2-002.
    R_HKONT4(3) = IEQ.
    R_HKONT4-LOW = LT_ZFI030-HKONT.
    APPEND R_HKONT4.
    CLEAR R_HKONT4.
  ENDLOOP.
  "ADD BY ABAP20
  DATA :LT_LFC1 TYPE TABLE OF LFC1 WITH HEADER LINE.
  DATA :LT_LFC1_S TYPE TABLE OF LFC1 WITH HEADER LINE.
  SELECT * FROM LFC1 INTO TABLE LT_LFC1 WHERE LIFNR IN R_LIFNR AND GJAHR EQ P_GJAHR AND BUKRS = P_BUKRS.
  LOOP AT LT_LFC1.
    MOVE  LT_LFC1 TO LT_LFC1_S.
    LT_LFC1_S-LIFNR = ‘‘.
    LT_LFC1_S-ERDAT =  ‘‘.
    LT_LFC1_S-USNAM =  ‘‘.
    COLLECT LT_LFC1_S.
    CLEAR LT_LFC1_S.
  ENDLOOP.

*
*  CLEAR:LT_BSIS,LT_BSIS[].
*  SELECT  BUKRS BELNR
*          GJAHR BUZEI
*          HKONT MONAT
*          SHKZG DMBTR
*    INTO TABLE LT_BSIS
*    FROM BSIS
*   WHERE BUKRS EQ P_BUKRS
*     AND HKONT LIKE ‘002202%‘
*     AND GJAHR EQ P_GJAHR.
*  " ADD BY ABAP20 20151120
*  SELECT  BUKRS BELNR
*  GJAHR BUZEI
*  HKONT MONAT
*  SHKZG DMBTR
*  INTO TABLE LT_BSIS
*  FROM BSAD
*  WHERE BUKRS EQ P_BUKRS
*  AND HKONT LIKE ‘002202%‘
*  AND GJAHR EQ P_GJAHR.
*  " ADD BY ABAP20 20151120
*  SORT LT_BSIS BY BUKRS BELNR GJAHR.
*  DELETE ADJACENT DUPLICATES FROM LT_BSIS COMPARING BUKRS BELNR GJAHR.
*
*  CLEAR:LT_USE[],LT_USE.
*  CLEAR:LT_BSEG,LT_BSEG[].
**  LT_USE[] = LT_BSIS[].
*  LOOP AT LT_BSIS.
*    CLEAR L_LAST.
*    AT LAST.
*      L_LAST = ‘X‘.
*    ENDAT.
*
*    APPEND LT_BSIS TO LT_USE.
*    ADD 1 TO L_COUNT.
**&for all entries 后条目数限制,5000(10000也可以取)
*    IF L_COUNT = 5000 OR L_LAST = ‘X‘.
*      SELECT BUKRS BELNR
*             BUZEI GJAHR
*             RSTGR HKONT
*             SHKZG DMBTR
*   APPENDING TABLE LT_BSEG
*        FROM BSEG
*        FOR ALL ENTRIES IN LT_BSIS
*      WHERE BUKRS EQ LT_BSIS-BUKRS
*        AND BELNR EQ LT_BSIS-BELNR
*        AND GJAHR EQ LT_BSIS-GJAHR
*        AND LIFNR IN R_LIFNR.
*      REFRESH LT_USE.
*      CLEAR L_COUNT.
*    ENDIF.
*  ENDLOOP.
*  SORT LT_BSEG BY BUKRS GJAHR BELNR.
*
*  LOOP AT LT_BSIS.
*    READ TABLE LT_BSEG WITH KEY BUKRS = LT_BSIS-BUKRS
*                                GJAHR = LT_BSIS-GJAHR
*                                BELNR = LT_BSIS-BELNR  BINARY SEARCH.
*    IF SY-SUBRC <> 0.
*      DELETE LT_BSIS.
*      CONTINUE.
*    ENDIF.
*  ENDLOOP.
*
**& 按期间汇总供应商条件下的科目
*  CLEAR:LT_BSIS_L,LT_BSIS_L[].
*  LOOP AT LT_BSIS.
*    LT_BSIS_L-MONAT = LT_BSIS-MONAT.
*    IF LT_BSIS-SHKZG = ‘H‘.
*      LT_BSIS_L-DMBTR = LT_BSIS-DMBTR * -1.
*    ELSE.
*      LT_BSIS_L-DMBTR = LT_BSIS-DMBTR.
*    ENDIF.
*    COLLECT LT_BSIS_L.
*    CLEAR LT_BSIS_L.
*  ENDLOOP.

*BREAK ABAP30.
*&S6.读取对应栏位汇总值到显示内表
  LOOP AT GT_1000.
    GT_1000-LIN = SY-TABIX.
*&读取编号栏位金额
    IF GT_1000-ZZNUMB IS NOT INITIAL AND  GT_1000-ZZSUM NE C2-002.
      READ TABLE GT_SUM_C WITH KEY ZZNUMB = GT_1000-ZZNUMB.
      IF SY-SUBRC EQ 0.
        MOVE-CORRESPONDING GT_SUM_C TO GT_1000.
      ENDIF.
    ENDIF.
*&读取汇总栏位金额
    IF GT_1000-ZZSUM IS NOT INITIAL .
      READ TABLE GT_SUM_S WITH KEY ZZSUM = GT_1000-ZZSUM.
      IF SY-SUBRC EQ 0.

*        MOVE-CORRESPONDING GT_SUM_S TO GT_1000.
        GT_1000-HSL01_Y = GT_SUM_S-HSL01_Y .
        GT_1000-HSLVT = GT_SUM_S-HSLVT.
        GT_1000-HSL01 = GT_SUM_S-HSL01.
        GT_1000-HSL02 = GT_SUM_S-HSL02.
        GT_1000-HSL03 = GT_SUM_S-HSL03.
        GT_1000-HSL04 = GT_SUM_S-HSL04.
        GT_1000-HSL05 = GT_SUM_S-HSL05.
        GT_1000-HSL06 = GT_SUM_S-HSL06.
        GT_1000-HSL07 = GT_SUM_S-HSL07.
        GT_1000-HSL08 = GT_SUM_S-HSL08.
        GT_1000-HSL09 = GT_SUM_S-HSL09.
        GT_1000-HSL10 = GT_SUM_S-HSL10.
        GT_1000-HSL11 = GT_SUM_S-HSL11.
        GT_1000-HSL12 = GT_SUM_S-HSL12.
        IF   GT_1000-ZZSUM = C2.


          READ TABLE GT_SUM_C WITH KEY ZZNUMB = C2-002.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y - GT_SUM_C-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT - GT_SUM_C-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 - GT_SUM_C-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 - GT_SUM_C-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 -  GT_SUM_C-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 - GT_SUM_C-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 -  GT_SUM_C-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  - GT_SUM_C-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 - GT_SUM_C-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 - GT_SUM_C-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 - GT_SUM_C-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 - GT_SUM_C-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 - GT_SUM_C-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 - GT_SUM_C-HSL12.
*          MOVE-CORRESPONDING GT_SUM_C TO GT_1000.
          ENDIF.
          READ TABLE GT_SUM_C WITH KEY ZZNUMB = C2-005.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y - GT_SUM_C-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT - GT_SUM_C-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 - GT_SUM_C-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 - GT_SUM_C-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 -  GT_SUM_C-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 - GT_SUM_C-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 -  GT_SUM_C-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  - GT_SUM_C-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 - GT_SUM_C-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 - GT_SUM_C-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 - GT_SUM_C-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 - GT_SUM_C-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 - GT_SUM_C-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 - GT_SUM_C-HSL12.
*          MOVE-CORRESPONDING GT_SUM_C TO GT_1000.
          ENDIF.
*          READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = ‘C2-002‘.
*          IF SY-SUBRC EQ 0.
*            GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y .
*            GT_1000-HSLVT =  GT_1000-HSLVT + WA_1000-HSLVT.
*            GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
*            GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
*            GT_1000-HSL03 = GT_1000-HSL03 +  WA_1000-HSL03.
*            GT_1000-HSL04 =  GT_1000-HSL04 + WA_1000-HSL04.
*            GT_1000-HSL05 = GT_1000-HSL05 +  WA_1000-HSL05.
*            GT_1000-HSL06 =  GT_1000-HSL06  + WA_1000-HSL06.
*            GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
*            GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
*            GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
*            GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
*            GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
*            GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
*          ENDIF.
          READ TABLE GT_SUM_C WITH KEY ZZNUMB = C2-004.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y - GT_SUM_C-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT - GT_SUM_C-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 - GT_SUM_C-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 - GT_SUM_C-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 -  GT_SUM_C-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 - GT_SUM_C-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 -  GT_SUM_C-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  - GT_SUM_C-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 - GT_SUM_C-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 - GT_SUM_C-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 - GT_SUM_C-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 - GT_SUM_C-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 - GT_SUM_C-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 - GT_SUM_C-HSL12.
*          MOVE-CORRESPONDING GT_SUM_C TO GT_1000.
          ENDIF.
          READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-004.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT + WA_1000-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 +  WA_1000-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 + WA_1000-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 +  WA_1000-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  + WA_1000-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          ENDIF.
          READ TABLE GT_SUM_C WITH KEY ZZNUMB = C2-007.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y - GT_SUM_C-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT - GT_SUM_C-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 - GT_SUM_C-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 - GT_SUM_C-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 -  GT_SUM_C-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 - GT_SUM_C-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 -  GT_SUM_C-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  - GT_SUM_C-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 - GT_SUM_C-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 - GT_SUM_C-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 - GT_SUM_C-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 - GT_SUM_C-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 - GT_SUM_C-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 - GT_SUM_C-HSL12.
*          MOVE-CORRESPONDING GT_SUM_C TO GT_1000.
          ENDIF.
          READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-007.
          IF SY-SUBRC EQ 0.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y .
            GT_1000-HSLVT =  GT_1000-HSLVT + WA_1000-HSLVT.
            GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
            GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
            GT_1000-HSL03 = GT_1000-HSL03 +  WA_1000-HSL03.
            GT_1000-HSL04 =  GT_1000-HSL04 + WA_1000-HSL04.
            GT_1000-HSL05 = GT_1000-HSL05 +  WA_1000-HSL05.
            GT_1000-HSL06 =  GT_1000-HSL06  + WA_1000-HSL06.
            GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
            GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
            GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
            GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
            GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
            GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
*&>A1.C1-002 (006*加总-6801*)*-1 【Profit before income tax expense】
    CASE GT_1000-ZZNUMB.
      WHEN C1-002.
        READ TABLE LT_C1_002 WITH KEY ZZNUMB = C1-002.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = LT_C1_002-HSL01_Y * -1.
          GT_1000-HSLVT = LT_C1_002-HSLVT * -1.
          GT_1000-HSL01 = LT_C1_002-HSL01 * -1.
          GT_1000-HSL02 = LT_C1_002-HSL02 * -1.
          GT_1000-HSL03 = LT_C1_002-HSL03 * -1.
          GT_1000-HSL04 = LT_C1_002-HSL04 * -1.
          GT_1000-HSL05 = LT_C1_002-HSL05 * -1.
          GT_1000-HSL06 = LT_C1_002-HSL06 * -1.
          GT_1000-HSL07 = LT_C1_002-HSL07 * -1.
          GT_1000-HSL08 = LT_C1_002-HSL08 * -1.
          GT_1000-HSL09 = LT_C1_002-HSL09 * -1.
          GT_1000-HSL10 = LT_C1_002-HSL10 * -1.
          GT_1000-HSL11 = LT_C1_002-HSL11 * -1.
          GT_1000-HSL12 = LT_C1_002-HSL12 * -1.

          CLEAR LT_C1_002.
        ENDIF.

*&>A3.C2-002 科目汇总结果*(-1)-C2-004【 Decrease/(increase) in trade receivables】
*& 需要后面单独处理
      WHEN C2-002.
*        GT_1000-HSL01_Y = GT_1000-HSL01_Y * -1.
*        GT_1000-HSLVT = GT_1000-HSLVT * -1.
*        GT_1000-HSL01 = GT_1000-HSL01 * -1.
*        GT_1000-HSL02 = GT_1000-HSL02 * -1.
*        GT_1000-HSL03 = GT_1000-HSL03 * -1.
*        GT_1000-HSL04 = GT_1000-HSL04 * -1.
*        GT_1000-HSL05 = GT_1000-HSL05 * -1.
*        GT_1000-HSL06 = GT_1000-HSL06 * -1.
*        GT_1000-HSL07 = GT_1000-HSL07 * -1.
*        GT_1000-HSL08 = GT_1000-HSL08 * -1.
*        GT_1000-HSL09 = GT_1000-HSL09 * -1.
*        GT_1000-HSL10 = GT_1000-HSL10 * -1.
*        GT_1000-HSL11 = GT_1000-HSL11 * -1.
*        GT_1000-HSL12 = GT_1000-HSL12 * -1.
        GT_1000-HSL01_Y = 0.
        GT_1000-HSLVT  = 0.
        GT_1000-HSL01  = 0.
        GT_1000-HSL02  = 0.
        GT_1000-HSL03  = 0.
        GT_1000-HSL04 = 0.
        GT_1000-HSL05 = 0.
        GT_1000-HSL06 = 0.
        GT_1000-HSL07  = 0.
        GT_1000-HSL08  = 0.
        GT_1000-HSL09  = 0.
        GT_1000-HSL10  = 0.
        GT_1000-HSL11  = 0.
        GT_1000-HSL12  = 0.
*        GT_1000-HSLVT = 0.
*        GT_1000-HSL01_Y = 0 .
        LOOP AT GT_FAGT WHERE RACCT IN R_HKONT4.
          LT_BSIS_S-MONAT = 0.
          GT_1000-HSLVT = GT_FAGT-HSLVT   + GT_1000-HSLVT.
          DO 12 TIMES.
            LT_BSIS_S-MONAT = LT_BSIS_S-MONAT + 1.
            CONCATENATE HSL LT_BSIS_S-MONAT  INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_FAGT TO <FLD_VALUE_S>.
*          CONCATENATE ‘UM‘ LT_BSIS_S-MONAT ‘H‘ INTO FLD_NAME.
*          ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_LFC1_S TO <FLD_VALUE_H>.
            CONCATENATE HSL LT_BSIS_S-MONAT INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME   OF STRUCTURE GT_1000 TO <FLD_VALUE>.
            IF SY-SUBRC = 0.
              <FLD_VALUE> = <FLD_VALUE> + <FLD_VALUE_S> .
            ELSE.
              STOP.
            ENDIF.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y +   <FLD_VALUE_S>.
          ENDDO.
*          GT_1000-HSL01 = GT_1000-HSL01 + GT_FAGT-HSL01.
        ENDLOOP.
*        BREAK ABAP20.
*&>A4.C2-004  1122*(针对部分客户)* (-1)【Decrease/(increase) in amounts due from related  companies on trade accounts】
*& 针对部分客户,如何处理?
      WHEN C2-004.

        "MOD BY BAIYUZHUANG
*        LOOP AT LT_BSIS_S.
*&<FS> 赋值
*          CONCATENATE ‘HSL‘ LT_BSIS_S-MONAT INTO FLD_NAME.
*          ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_1000 TO <FLD_VALUE>.
*          IF SY-SUBRC = 0.
*            <FLD_VALUE> = LT_BSIS_S-DMBTR.
*          ENDIF.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y + LT_BSIS_S-DMBTR.
*          CLEAR LT_BSIS_S.
        READ TABLE LT_KNC1_S INDEX 1.
        IF SY-SUBRC = 0 .
          LT_BSIS_S-MONAT = 0.
          DO 12 TIMES.

            LT_BSIS_S-MONAT = LT_BSIS_S-MONAT + 1.
            CONCATENATE UM LT_BSIS_S-MONAT S INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_KNC1_S TO <FLD_VALUE_S>.
            CONCATENATE UM LT_BSIS_S-MONAT H INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_KNC1_S TO <FLD_VALUE_H>.
            CONCATENATE HSL LT_BSIS_S-MONAT INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_1000 TO <FLD_VALUE>.
            IF SY-SUBRC = 0.
              <FLD_VALUE> = <FLD_VALUE_H> - <FLD_VALUE_S> .
            ENDIF.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y +   <FLD_VALUE>.
*          CLEAR LT_BSIS_S.
          ENDDO.
        ENDIF.

        "END BY BAIYUZHUANG
*        ENDLOOP.

*&>A6.C2-007 加 2202* (针对部分供应商)【(Decrease)/increase in amounts due to related  companies on trade accounts】
      WHEN C2-007.
        "BEGIN MOD BY ABAP20
*        LOOP AT LT_BSIS_L.
**&<FS> 赋值
*          CONCATENATE ‘HSL‘ LT_BSIS_L-MONAT INTO FLD_NAME.
*          ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_1000 TO <FLD_VALUE>.
*          IF SY-SUBRC = 0.
*            <FLD_VALUE> = LT_BSIS_L-DMBTR.
*          ENDIF.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y + LT_BSIS_L-DMBTR.
*          CLEAR LT_BSIS_S.
*        ENDLOOP.

        READ TABLE LT_LFC1_S INDEX 1.
        IF SY-SUBRC = 0 .
          LT_BSIS_S-MONAT = 0.
          DO 12 TIMES.

            LT_BSIS_S-MONAT = LT_BSIS_S-MONAT + 1.
            CONCATENATE UM LT_BSIS_S-MONAT S INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_LFC1_S TO <FLD_VALUE_S>.
            CONCATENATE UM LT_BSIS_S-MONAT H INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_LFC1_S TO <FLD_VALUE_H>.
            CONCATENATE HSL LT_BSIS_S-MONAT INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_1000 TO <FLD_VALUE>.
            IF SY-SUBRC = 0.
              <FLD_VALUE> = <FLD_VALUE_H> - <FLD_VALUE_S> .
            ENDIF.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y +   <FLD_VALUE>.
*          CLEAR LT_BSIS_S.
          ENDDO.
        ENDIF.
*          READ TABLE     GT_FAGT WITH  KEY
        LOOP AT GT_FAGT WHERE RACCT IN R_HKONT3.
          LT_BSIS_S-MONAT = 0.
          DO 12 TIMES.
            LT_BSIS_S-MONAT = LT_BSIS_S-MONAT + 1.
            CONCATENATE HSL LT_BSIS_S-MONAT  INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_FAGT TO <FLD_VALUE_S>.
*          CONCATENATE ‘UM‘ LT_BSIS_S-MONAT ‘H‘ INTO FLD_NAME.
*          ASSIGN COMPONENT FLD_NAME OF STRUCTURE LT_LFC1_S TO <FLD_VALUE_H>.
            CONCATENATE HSL LT_BSIS_S-MONAT INTO FLD_NAME.
            ASSIGN COMPONENT FLD_NAME OF STRUCTURE GT_1000 TO <FLD_VALUE>.
            IF SY-SUBRC = 0.
              <FLD_VALUE> = <FLD_VALUE> + <FLD_VALUE_S> .
            ENDIF.
            GT_1000-HSL01_Y = GT_1000-HSL01_Y +   <FLD_VALUE_S>.
          ENDDO.
        ENDLOOP.
*& C2-007本年累计
        CLEAR:GT_1000-HSL01_Y.
        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.
        "END BY BAIYUZHUANG
*&>9.C5-002 增加借款(贷方金额)2501*    FAG*A 表 借贷为‘H’
      WHEN C5-002.
        READ TABLE LT_C5_002 WITH KEY ZZNUMB = C5-002.
        IF SY-SUBRC EQ 0.
          MOVE-CORRESPONDING LT_C5_002 TO GT_1000.
          CLEAR LT_C5_002.
        ENDIF.
*&>10.C5-003 -还款金额(借方金额)2501*    FAG*A 表 借贷为‘S’
      WHEN C5-003.
        READ TABLE LT_C5_003 WITH KEY ZZNUMB = C5-003.
        IF SY-SUBRC EQ 0.
          MOVE-CORRESPONDING LT_C5_003 TO GT_1000.
          CLEAR LT_C5_003.
        ENDIF.

*&A13.C7-001 期初余额,本年累计的期初余额为上年期末余额
*&HSL01 为上年12月的值-期末结转值
      WHEN C7-001.
        READ TABLE GT_SUM_C WITH KEY ZZNUMB = GT_1000-ZZNUMB.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_SUM_C-HSLVT.
          READ TABLE LT_C7_001_SUM WITH KEY ZZNUMB = GT_1000-ZZNUMB.
          IF SY-SUBRC EQ 0.
*            GT_1000-HSL01 = LT_C7_001_SUM-HSL12.
            GT_1000-HSL01 =  LT_C7_001_SUM-HSLVT.
          ENDIF.
          GT_1000-HSL02 = GT_SUM_C-HSL01 + GT_1000-HSL01.
          GT_1000-HSL03 = GT_SUM_C-HSL02 + GT_1000-HSL02.
          GT_1000-HSL04 = GT_SUM_C-HSL03 + GT_1000-HSL03.
          GT_1000-HSL05 = GT_SUM_C-HSL04 + GT_1000-HSL04.
          GT_1000-HSL06 = GT_SUM_C-HSL05 + GT_1000-HSL05.
          GT_1000-HSL07 = GT_SUM_C-HSL06 + GT_1000-HSL06.
          GT_1000-HSL08 = GT_SUM_C-HSL07 + GT_1000-HSL07.
          GT_1000-HSL09 = GT_SUM_C-HSL08 + GT_1000-HSL08.
          GT_1000-HSL10 = GT_SUM_C-HSL09 + GT_1000-HSL09.
          GT_1000-HSL11 = GT_SUM_C-HSL10 + GT_1000-HSL10.
          GT_1000-HSL12 = GT_SUM_C-HSL11 + GT_1000-HSL11.
          GT_1000-HSL01_Y = GT_SUM_C-HSLVT.
          CLEAR GT_SUM_C.
        ENDIF.
*&C7-001本年累计
*        CLEAR:GT_1000-HSL01_Y.
*        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
*                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
*                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

*&栏位相加 汇总项……………………………………
*&>11.C5-007 C5系列加总


      WHEN OTHERS.
    ENDCASE.

**& * -1 处理
**&>A2.C1-004 *(-1)
*IF GT_1000-ZZNUMB = ‘C1-004‘ OR GT_1000-ZZNUMB = ‘C1-006‘ OR GT_1000-ZZNUMB = ‘C1-007‘.
    "MOD BY BAIYUZHUANG
    IF GT_1000-ZZNUMB = C1-006OR GT_1000-ZZNUMB = C1-007"OR GT_1000-ZZNUMB = ‘C1-004‘
    OR GT_1000-ZZNUMB = C2-001 OR GT_1000-ZZNUMB = C2-003 OR GT_1000-ZZNUMB = C2-006
    OR GT_1000-ZZNUMB = C3-001 OR GT_1000-ZZNUMB = C3-002
    OR GT_1000-ZZNUMB = C4-002
    OR GT_1000-ZZNUMB = C5-005.
      GT_1000-HSL01_Y = GT_1000-HSL01_Y * -1.
      GT_1000-HSLVT = GT_1000-HSLVT * -1.
      GT_1000-HSL01 = GT_1000-HSL01 * -1.
      GT_1000-HSL02 = GT_1000-HSL02 * -1.
      GT_1000-HSL03 = GT_1000-HSL03 * -1.
      GT_1000-HSL04 = GT_1000-HSL04 * -1.
      GT_1000-HSL05 = GT_1000-HSL05 * -1.
      GT_1000-HSL06 = GT_1000-HSL06 * -1.
      GT_1000-HSL07 = GT_1000-HSL07 * -1.
      GT_1000-HSL08 = GT_1000-HSL08 * -1.
      GT_1000-HSL09 = GT_1000-HSL09 * -1.
      GT_1000-HSL10 = GT_1000-HSL10 * -1.
      GT_1000-HSL11 = GT_1000-HSL11 * -1.
      GT_1000-HSL12 = GT_1000-HSL12 * -1.
    ENDIF.

    MODIFY GT_1000.
    CLEAR GT_1000.
  ENDLOOP.

*BREAK ABAP30.
*&>add on 20151116
*&*&S7.特殊栏位处理-需要相加项目的处理:
  LOOP AT GT_1000.
*&>A3.C2-002 科目汇总结果*-1-C2-004【 Decrease/(increase) in trade receivables】
    CASE GT_1000-ZZNUMB.

*&营运资金变动前的经验利润  C1-011 = 原始汇总 + C1-002.
      WHEN C1-011.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C1-002.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.

*&-C2-004 (相减操作) 【科目汇总结果*-1-C2-004】
      WHEN C2-002.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-004.
        IF SY-SUBRC EQ 0.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y - WA_1000-HSL01_Y.
          GT_1000-HSLVT =  GT_1000-HSLVT * -1 - WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 * -1 - WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 * -1 - WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 * -1 - WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 * -1 - WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 * -1 - WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 * -1 - WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 * -1 - WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 * -1 - WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 * -1 - WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 * -1 - WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 * -1 - WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 * -1 - WA_1000-HSL12.
          CLEAR:GT_1000-HSL01_Y.
          GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                          + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                          + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

          CLEAR WA_1000.
        ENDIF.


*&>A5.C2-005 科目汇总结果*-1-C2-007    【(Decrease)/increase in trade payables】
      WHEN C2-005.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-007.
        IF SY-SUBRC EQ 0.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y * -1 - WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT * -1 - WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 * -1 - WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 * -1 - WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 * -1 - WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 * -1 - WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 * -1 - WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 * -1 - WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 * -1 - WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 * -1 - WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 * -1 - WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 * -1 - WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 * -1 - WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 * -1 - WA_1000-HSL12.
          CLEAR:GT_1000-HSL01_Y.
          GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                          + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                          + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.

*&>A7.C2-009 原汇总基础上 + 第15项目(C1-011)    【Cash generated from operations】
      WHEN C2-009.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-002.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-005.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C1-011.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        CLEAR:GT_1000-HSL01_Y.
        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

*&A 20151119 - C3-001 = C1-005 * -1.
      WHEN C3-001.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C1-005.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = WA_1000-HSL01_Y * -1.
          GT_1000-HSLVT = WA_1000-HSLVT * -1.
          GT_1000-HSL01 = WA_1000-HSL01 * -1.
          GT_1000-HSL02 = WA_1000-HSL02 * -1.
          GT_1000-HSL03 = WA_1000-HSL03 * -1.
          GT_1000-HSL04 = WA_1000-HSL04 * -1.
          GT_1000-HSL05 = WA_1000-HSL05 * -1.
          GT_1000-HSL06 = WA_1000-HSL06 * -1.
          GT_1000-HSL07 = WA_1000-HSL07 * -1.
          GT_1000-HSL08 = WA_1000-HSL08 * -1.
          GT_1000-HSL09 = WA_1000-HSL09 * -1.
          GT_1000-HSL10 = WA_1000-HSL10 * -1.
          GT_1000-HSL11 = WA_1000-HSL11 * -1.
          GT_1000-HSL12 = WA_1000-HSL12 * -1.
          CLEAR WA_1000.
        ENDIF.

*&A 20151119 - C4-001 = C1-004 * -1.
      WHEN C4-004.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C1-004.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = WA_1000-HSL01_Y * -1.
          GT_1000-HSLVT = WA_1000-HSLVT * -1.
          GT_1000-HSL01 = WA_1000-HSL01 * -1.
          GT_1000-HSL02 = WA_1000-HSL02 * -1.
          GT_1000-HSL03 = WA_1000-HSL03 * -1.
          GT_1000-HSL04 = WA_1000-HSL04 * -1.
          GT_1000-HSL05 = WA_1000-HSL05 * -1.
          GT_1000-HSL06 = WA_1000-HSL06 * -1.
          GT_1000-HSL07 = WA_1000-HSL07 * -1.
          GT_1000-HSL08 = WA_1000-HSL08 * -1.
          GT_1000-HSL09 = WA_1000-HSL09 * -1.
          GT_1000-HSL10 = WA_1000-HSL10 * -1.
          GT_1000-HSL11 = WA_1000-HSL11 * -1.
          GT_1000-HSL12 = WA_1000-HSL12 * -1.
          CLEAR WA_1000.
        ENDIF.
*&A 20151119 - C4-007 = C4-004 * c4-007.
      WHEN C4-007.
*        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = ‘C4-004‘.
*        IF SY-SUBRC EQ 0.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
*          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
*          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
*          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
*          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
*          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
*          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
*          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
*          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
*          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
*          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
*          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
*          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
*          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
*          CLEAR WA_1000.
*        ENDIF.
*&>A8.C3-004  原汇总基础上+第24行(C2-009) 【Net cash flows from/(used in) operating activities】
      WHEN C3-004.
        "ADD BY ABAP20 没有汇总C3-001
*        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = ‘C3-001‘.
*        IF SY-SUBRC EQ 0.
*          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
*          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
*          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
*          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
*          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
*          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
*          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
*          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
*          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
*          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
*          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
*          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
*          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
*          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
*          CLEAR WA_1000.
*        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C2-009.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
*&C3004本年累计
        CLEAR:GT_1000-HSL01_Y.
        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

*&>12.C6-001 28+36+44 (C3-004+C4-007+C5-007)
      WHEN C6-001.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C3-004.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C4-007.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C5-007.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
*&C6-001本年累计
        CLEAR:GT_1000-HSL01_Y.
        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

*&>14.C9-001 46+48+50 (C6-001+C7-001+C8-001)
      WHEN C9-001.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C6-001.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C7-001.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
        READ TABLE GT_1000 INTO WA_1000 WITH KEY ZZNUMB = C8-001.
        IF SY-SUBRC EQ 0.
          GT_1000-HSL01_Y = GT_1000-HSL01_Y + WA_1000-HSL01_Y.
          GT_1000-HSLVT = GT_1000-HSLVT + WA_1000-HSLVT.
          GT_1000-HSL01 = GT_1000-HSL01 + WA_1000-HSL01.
          GT_1000-HSL02 = GT_1000-HSL02 + WA_1000-HSL02.
          GT_1000-HSL03 = GT_1000-HSL03 + WA_1000-HSL03.
          GT_1000-HSL04 = GT_1000-HSL04 + WA_1000-HSL04.
          GT_1000-HSL05 = GT_1000-HSL05 + WA_1000-HSL05.
          GT_1000-HSL06 = GT_1000-HSL06 + WA_1000-HSL06.
          GT_1000-HSL07 = GT_1000-HSL07 + WA_1000-HSL07.
          GT_1000-HSL08 = GT_1000-HSL08 + WA_1000-HSL08.
          GT_1000-HSL09 = GT_1000-HSL09 + WA_1000-HSL09.
          GT_1000-HSL10 = GT_1000-HSL10 + WA_1000-HSL10.
          GT_1000-HSL11 = GT_1000-HSL11 + WA_1000-HSL11.
          GT_1000-HSL12 = GT_1000-HSL12 + WA_1000-HSL12.
          CLEAR WA_1000.
        ENDIF.
*&C9-001本年累计
*        CLEAR:GT_1000-HSL01_Y.
*        GT_1000-HSL01_Y = GT_1000-HSL01 + GT_1000-HSL02 + GT_1000-HSL03 + GT_1000-HSL04
*                        + GT_1000-HSL05 + GT_1000-HSL06 + GT_1000-HSL07 + GT_1000-HSL08
*                        + GT_1000-HSL09 + GT_1000-HSL10 + GT_1000-HSL11 + GT_1000-HSL12.

      WHEN OTHERS.
    ENDCASE.

    MODIFY GT_1000.
    CLEAR GT_1000.
  ENDLOOP.

*&条目数
  G_LEN = LINES( GT_1000[] ).
  IF G_LEN EQ 0.
    MESSAGE I003 WITH 没有找到符合条件的数据!.
    STOP.
  ELSE.
    MESSAGE S003 WITH 找到数据条目数: G_LEN.
  ENDIF.

ENDFORM.                    " FRM_GET_1000
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_OUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_OUT.
*DATA:

  LOOP AT GT_1000.
*&1.文本
    IF GT_1000-ZZTXPE EQ X.
      PERFORM FRM_WRITE_TEXT.
    ENDIF.
*&2.科目栏位
    IF GT_1000-ZZSUM EQ ‘‘ AND GT_1000-ZZTXPE EQ ‘‘.
      PERFORM FRM_WRITE_ITEM.
    ENDIF.

    IF  GT_1000-ZZSUM CS C AND GT_1000-ZZTXPE IS INITIAL.
* IF GT_1000-ZZSUM EQ ‘C1‘ OR GT_1000-ZZSUM EQ ‘C2‘ OR GT_1000-ZZSUM EQ ‘C3‘
*  OR GT_1000-ZZSUM EQ ‘C4‘ OR GT_1000-ZZSUM EQ ‘C5‘.
      PERFORM FRM_WRITE_SUM.
    ENDIF.

  ENDLOOP.

ENDFORM.                    " FRM_WRITE_OUT
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_TEXT.

  WRITE AT:/(80) GT_1000-ZZTEXT LEFT-JUSTIFIED.

ENDFORM.                    " FRM_WRITE_TEXT
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_ITEM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_ITEM.

  WRITE AT:/3(80) GT_1000-ZZTEXT LEFT-JUSTIFIED,
             (3) ‘‘,
             (15) GT_1000-HSL01 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL02 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL03 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL04 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL05 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL06 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL07 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL08 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL09 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL10 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL11 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL12 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL01_Y RIGHT-JUSTIFIED.

ENDFORM.                    " FRM_WRITE_ITEM
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_SUM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_SUM .

  WRITE AT:/87(192) SY-ULINE,(15) SY-ULINE. "(15)SY-ULINE, (15)SY-ULINE, (10) SY-ULINE.
  WRITE AT:/3(80) GT_1000-ZZTEXT LEFT-JUSTIFIED,
             (3) ‘‘,
             (15) GT_1000-HSL01 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL02 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL03 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL04 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL05 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL06 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL07 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL08 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL09 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL10 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL11 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL12 RIGHT-JUSTIFIED,
             (15) GT_1000-HSL01_Y RIGHT-JUSTIFIED.
  WRITE AT:/87(192) SY-ULINE,(15) SY-ULINE. "(15)SY-ULINE, (15)SY-ULINE, (10) SY-ULINE.


ENDFORM.                    " FRM_WRITE_SUM
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_TOTAL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_TOTAL .
*  WRITE AT:/3(30) GT_1000-ZZTEXT LEFT-JUSTIFIED,
*             (3) ‘‘,
*             (17) GT_1000-HSL01_Y RIGHT-JUSTIFIED,
*             (17) GT_1000-HSL01_N RIGHT-JUSTIFIED.
**  (17) ITAB-DMBTR1 RIGHT-JUSTIFIED,
**  (17) ITAB-DMBTR2 RIGHT-JUSTIFIED,
**  (17) ITAB-DMBTR3 RIGHT-JUSTIFIED,
**  (10) ITAB-DMBTR4 RIGHT-JUSTIFIED.
*  WRITE AT:/37(17) ‘=================‘,
*              (17) ‘=================‘,
*              (17) ‘=================‘,
*              (10) ‘=================‘.
ENDFORM.                    " FRM_WRITE_TOTAL
*&---------------------------------------------------------------------*
*&      Form  FRM_WRITE_OTHER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_WRITE_OTHER .
*  WRITE AT:/37(17) SY-ULINE, (17) SY-ULINE, (17) SY-ULINE, (10) SY-ULINE.
*  WRITE AT:/3(30) GT_1000-ZZTEXT LEFT-JUSTIFIED,
*             (3) ‘‘,
*             (17) GT_1000-HSL01_Y RIGHT-JUSTIFIED,
*             (17) GT_1000-HSL01_N RIGHT-JUSTIFIED.
**  (17) ITAB-DMBTR1 RIGHT-JUSTIFIED,
**  (17) ITAB-DMBTR2 RIGHT-JUSTIFIED,
**  (17) ITAB-DMBTR3 RIGHT-JUSTIFIED,
**  (10) ITAB-DMBTR4 RIGHT-JUSTIFIED.
*  WRITE AT:/37(17) ‘=================‘,
*              (17) ‘=================‘,
*              (17) ‘=================‘,
*              (10) ‘=================‘.
ENDFORM.                    " FRM_WRITE_OTHER
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_HEADER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_HEADER .
  DATA:LV_TEXT TYPE STRING.
  DATA: L_TEXT TYPE CHAR80.
  DATA: L_YEAR01 TYPE CHAR7,
        L_YEAR02 TYPE CHAR7,
        L_YEAR03 TYPE CHAR7,
        L_YEAR04 TYPE CHAR7,
        L_YEAR05 TYPE CHAR7,
        L_YEAR06 TYPE CHAR7,
        L_YEAR07 TYPE CHAR7,
        L_YEAR08 TYPE CHAR7,
        L_YEAR09 TYPE CHAR7,
        L_YEAR10 TYPE CHAR7,
        L_YEAR11 TYPE CHAR7,
        L_YEAR12 TYPE CHAR7.

  CONCATENATE P_GJAHR / 01 INTO L_YEAR01.
  CONCATENATE P_GJAHR / 02 INTO L_YEAR02.
  CONCATENATE P_GJAHR / 03 INTO L_YEAR03.
  CONCATENATE P_GJAHR / 04 INTO L_YEAR04.
  CONCATENATE P_GJAHR / 05 INTO L_YEAR05.
  CONCATENATE P_GJAHR / 06 INTO L_YEAR06.
  CONCATENATE P_GJAHR / 07 INTO L_YEAR07.
  CONCATENATE P_GJAHR / 08 INTO L_YEAR08.
  CONCATENATE P_GJAHR / 09 INTO L_YEAR09.
  CONCATENATE P_GJAHR / 10 INTO L_YEAR10.
  CONCATENATE P_GJAHR / 11 INTO L_YEAR11.
  CONCATENATE P_GJAHR / 12 INTO L_YEAR12.


  SELECT SINGLE * FROM T001 WHERE BUKRS = P_BUKRS.

  CONCATENATE From 1st Jan P_GJAHR to Current Month INTO LV_TEXT.
  WRITE AT:/1(20) TEAMWISE LIMITED,
           /1(16) Cash flows -, (20)T001-BUTXT LEFT-JUSTIFIED,
           /1(80)  LV_TEXT.

  CLEAR L_TEXT.
* CONCATENATE ‘Y-T-D‘ P_GJAHR INTO L_TEXT SEPARATED BY SPACE.
  L_TEXT = Y-T-D&& P_GJAHR .
  WRITE AT:/80(3) T001-WAERS,
             (15) L_YEAR01 RIGHT-JUSTIFIED,
             (15) L_YEAR02 RIGHT-JUSTIFIED,
             (15) L_YEAR03 RIGHT-JUSTIFIED,
             (15) L_YEAR04 RIGHT-JUSTIFIED,
             (15) L_YEAR05 RIGHT-JUSTIFIED,
             (15) L_YEAR06 RIGHT-JUSTIFIED,
             (15) L_YEAR07 RIGHT-JUSTIFIED,
             (15) L_YEAR08 RIGHT-JUSTIFIED,
             (15) L_YEAR09 RIGHT-JUSTIFIED,
             (15) L_YEAR10 RIGHT-JUSTIFIED,
             (15) L_YEAR11 RIGHT-JUSTIFIED,
             (15) L_YEAR12 RIGHT-JUSTIFIED,
             (15) L_TEXT RIGHT-JUSTIFIED.
*             (15) ‘Last Year‘ right-justified,
*             (15) ‘Diff‘ right-justified,
*             (10) ‘%‘ right-justified.
  WRITE AT:/1(297) SY-ULINE.

ENDFORM.                    " DISPLAY_HEADER
*&---------------------------------------------------------------------*
*&      Form  PRINTDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM PRINTDATA .
  DATA: F_INDEX LIKE SY-TABIX.
  DATA: LINES_LEN TYPE I.
  DATA: LS_CONTROL_PARAMETERS  TYPE SSFCTRLOP.
  DATA: LS_OUTPUT_OPTIONS      TYPE SSFCOMPOP.
  DATA: L_SMF_NAME             TYPE RS38L_FNAM.
  DATA GT_OUT TYPE TABLE OF ZST_F103_3000 WITH HEADER LINE.
  DATA GT_PRINT TYPE TABLE OF ZST_F103_3000.
*MOVE-CORRESPONDING GT_DATA[] TO GT_OUT[].
  LOOP AT GT_DATA.
    MOVE-CORRESPONDING GT_DATA TO GT_OUT.
    APPEND GT_OUT TO GT_PRINT.
  ENDLOOP.
  LS_CONTROL_PARAMETERS-NO_CLOSE = ‘‘.
  LS_CONTROL_PARAMETERS-NO_DIALOG = ‘‘.
  LS_CONTROL_PARAMETERS-PREVIEW   = X.
  LS_OUTPUT_OPTIONS-TDDEST        = LP01.
  LS_OUTPUT_OPTIONS-TDIMMED       = X.
  LS_OUTPUT_OPTIONS-TDDELETE      = X.

  CALL FUNCTION SSF_FUNCTION_MODULE_NAME     "这个函数主要用来取你要调用的FUNCTION MODULE
  EXPORTING
    FORMNAME = ZFI103_1000_3000       "将SMARTFORM赋值给FORMNAME
  IMPORTING
    FM_NAME  = L_SMF_NAME.


  LS_CONTROL_PARAMETERS-NO_CLOSE = SPACE.
  CALL FUNCTION L_SMF_NAME     "调用SMARTFORM,这里是以FUNCTION的方式和SMARTFORM交互
  EXPORTING
    CONTROL_PARAMETERS = LS_CONTROL_PARAMETERS
    OUTPUT_OPTIONS     = LS_OUTPUT_OPTIONS
    USER_SETTINGS      = X
    FLAG               = X
    P_GJAHR                = P_GJAHR
   MONATL   = S_MONAT-LOW
MONATH   = S_MONAT-HIGH
  TABLES
    GT_DATA        = GT_PRINT

  EXCEPTIONS
    FORMATTING_ERROR   = 1
    INTERNAL_ERROR     = 2
    SEND_ERROR         = 3
    USER_CANCELED      = 4
    OTHERS             = 5.


  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " PRINTDATA
*&---------------------------------------------------------------------*
*&      Form  FRM_PRINT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_PRINT_DATA .
  DATA: F_INDEX LIKE SY-TABIX.
  DATA: LINES_LEN TYPE I.
  DATA: LS_CONTROL_PARAMETERS  TYPE SSFCTRLOP.
  DATA: LS_OUTPUT_OPTIONS      TYPE SSFCOMPOP.
  DATA: L_SMF_NAME             TYPE RS38L_FNAM.
  DATA GT_OUT TYPE TABLE OF ZST_1000 WITH HEADER LINE.
  DATA GT_PRINT TYPE TABLE OF ZST_1000.
*MOVE-CORRESPONDING GT_DATA[] TO GT_OUT[].
  LOOP AT GT_1000.

    MOVE-CORRESPONDING GT_1000 TO GT_OUT.
*    IF GT_1000-ZZNUMB  = ‘C1-011‘.

    APPEND GT_OUT TO GT_PRINT.
    CLEAR GT_OUT.
    IF GT_1000-ZZNUMB  = C1-011 OR  GT_1000-ZZNUMB  = C2-009 .

*      GT_OUT-ZZTEXT = ‘X‘.
      APPEND GT_OUT TO GT_PRINT.
    ENDIF.
  ENDLOOP.
  LS_CONTROL_PARAMETERS-NO_CLOSE = ‘‘.
  LS_CONTROL_PARAMETERS-NO_DIALOG = ‘‘.
  LS_CONTROL_PARAMETERS-PREVIEW   = X.
  LS_OUTPUT_OPTIONS-TDDEST        = LP01.
  LS_OUTPUT_OPTIONS-TDIMMED       = X.
  LS_OUTPUT_OPTIONS-TDDELETE      = X.

  CALL FUNCTION SSF_FUNCTION_MODULE_NAME     "这个函数主要用来取你要调用的FUNCTION MODULE
  EXPORTING
    FORMNAME = ZFI103_TH       "将SMARTFORM赋值给FORMNAME
  IMPORTING
    FM_NAME  = L_SMF_NAME.


  LS_CONTROL_PARAMETERS-NO_CLOSE = SPACE.
  CALL FUNCTION L_SMF_NAME     "调用SMARTFORM,这里是以FUNCTION的方式和SMARTFORM交互
  EXPORTING
    CONTROL_PARAMETERS = LS_CONTROL_PARAMETERS
    OUTPUT_OPTIONS     = LS_OUTPUT_OPTIONS
    USER_SETTINGS      = X
*    FLAG               = P_3000
    P_GJAHR                = P_GJAHR
  TABLES
    GT_DATA        = GT_PRINT

  EXCEPTIONS
    FORMATTING_ERROR   = 1
    INTERNAL_ERROR     = 2
    SEND_ERROR         = 3
    USER_CANCELED      = 4
    OTHERS             = 5.


  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " FRM_PRINT_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_EXCEL_OUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FRM_EXCEL_OUT .

  INCLUDE OLE2INCL.
*定义OLE变量
  DATA:EXCEL TYPE OLE2_OBJECT,
        SHEET TYPE OLE2_OBJECT,
        CELL TYPE OLE2_OBJECT,
        WORKBOOK TYPE OLE2_OBJECT.
  FIELD-SYMBOLS :<FS_01> TYPE ANY .
  DATA:VAL1(20) TYPE C.
  DATA:VAL2(80) TYPE C.
  DATA: R1 TYPE I,
        R2 TYPE I.
  DATA P_MONTH TYPE  T54C6-SMONT .
*输入文件名参数
*

*启动excel
  CREATE OBJECT EXCEL EXCEL.APPLICATION.

  IF SY-SUBRC NE 0 .
    WRITE: / ‘‘.
    STOP.
  ENDIF.

  CALL METHOD OF
      EXCEL
      WORKBOOKS = WORKBOOK.
*使excel 可视
  SET PROPERTY OF EXCEL VISIBLE = 1.

*建立worksheet
  SET PROPERTY OF EXCEL SHEETSINNEWWORKBOOK = 1.          "如果是读取excel文件中的内容 则是直接打开工作簿第一页
  CALL METHOD OF WORKBOOK ADD.                             " 例如:CALL METHOD OF EXCEL ‘WORKSHEETS‘  = SHEET  EXPORTING #1 = 1.
*写前1行1列
  CALL METHOD OF
      EXCEL
      CELLS = CELL
    EXPORTING
      #1      = 1
      #2      = 1.
  SET PROPERTY OF CELL VALUE = SY-DATUM.
  CALL METHOD OF
      EXCEL
      CELLS = CELL
    EXPORTING
      #1      = 2
      #2      = 1.
  SET PROPERTY OF CELL VALUE = TEAMWISE LIMITED.
  VAL2 = Cash flows - && T001-BUTXT.
  CALL METHOD OF
      EXCEL
      CELLS = CELL
    EXPORTING
      #1      = 3
      #2      = 1.
  SET PROPERTY OF CELL VALUE = VAL2.
  VAL2 = From 1st Jan&& P_GJAHR &&to Current Month.
  CALL METHOD OF
      EXCEL
      CELLS = CELL
    EXPORTING
      #1      = 4
      #2      = 1.
  SET PROPERTY OF CELL VALUE = VAL2.
  CALL METHOD OF
      EXCEL
      CELLS = CELL
    EXPORTING
      #1      = 5
      #2      = 1.
  SET PROPERTY OF CELL VALUE = HKD.
  DO 14 TIMES.
    R1 = SY-INDEX.
    IF R1 = 1.
      VAL1 = HKD.
    ELSEIF R1 = 14.
      VAL1 = Y-T-D && P_GJAHR.
    ELSE.
      P_MONTH = R1 - 1.
      VAL1 = P_GJAHR && /  && P_MONTH.
    ENDIF.
    CALL METHOD OF
        EXCEL
        CELLS = CELL
      EXPORTING
        #1      = 5
        #2      = R1.
    SET PROPERTY OF CELL VALUE = VAL1.
  ENDDO.
  CLEAR : R1,R2.
  LOOP AT GT_1000.
    R1 = SY-TABIX + 6.
    DO 14 TIMES.
      R2 = SY-INDEX.
      IF  GT_1000-ZZTEXT IS NOT INITIAL.
        CASE R2.
          WHEN 1.
            VAL2 =  GT_1000-ZZTEXT.
          WHEN 2.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL01 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL01.
          WHEN 3.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL02 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL02.
          WHEN 4.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL03 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL03.
          WHEN 5.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL04 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL04.
          WHEN 6.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL05 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL05.
          WHEN 7.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL06 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL06.
          WHEN 8.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL07 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL07.
          WHEN 9.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL08 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL08.
          WHEN 10.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL09 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL09.
          WHEN 11.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL10 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL10.
          WHEN 12.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL11 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL11.
          WHEN 13.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL12 CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL12.
          WHEN 14.
            PERFORM FRM_CHANGE_DATA USING GT_1000-HSL01_Y CHANGING VAL1 .
*          VAL1 =  GT_1000-HSL01_Y .
          WHEN OTHERS.
        ENDCASE.
      ELSE.
        VAL1 = ‘‘.
        VAL2 = ‘‘.
      ENDIF.

*指定单元格,并写入值
      IF R2 = 1.
        CONDENSE VAL2.
        CALL METHOD OF
            EXCEL
            CELLS = CELL
          EXPORTING
            #1      = R1
            #2      = R2.
        SET PROPERTY OF CELL VALUE = VAL2.
      ELSE.
        CONDENSE VAL1.
        CALL METHOD OF
            EXCEL
            CELLS = CELL
          EXPORTING
            #1      = R1
            #2      = R2.
        SET PROPERTY OF CELL VALUE = VAL1.
      ENDIF.

    ENDDO.
  ENDLOOP.





*存入文件
  GET PROPERTY OF EXCEL ACTIVESHEET = SHEET.      "激活工作簿
  GET PROPERTY OF EXCEL ACTIVEWORKBOOK = WORKBOOK.   "激活工作区
  CALL METHOD OF
      WORKBOOK
      SAVEAS

    EXPORTING
      #1       = FN1
      #2       = 1.    "将excel文件保存为 FN1  路径
  CALL METHOD OF WORKBOOK CLOSE.           "关闭工作区
  CALL METHOD OF EXCEL QUIT.               " 退出excel
  WRITE DONE.                              "退出成功,输出done

  FREE OBJECT SHEET.                      "释放操作
  FREE OBJECT WORKBOOK.
  FREE OBJECT EXCEL.
ENDFORM.                    " FRM_EXCEL_OUT
*&---------------------------------------------------------------------*
*&      Form  GET_PC_FILENAME
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_PC_FILENAME .
  IF P_EXCEL = X.
*    CALL FUNCTION ‘F4_FILENAME‘ "取得文件路徑
*    EXPORTING
*      FIELD_NAME = ‘FN1‘
*    IMPORTING
*      FILE_NAME = FN1.
    CALL FUNCTION WS_FILENAME_GET
      EXPORTING
        DEF_FILENAME     = *.*
        DEF_PATH         = C:\‘
        MASK             = ,*.*.
        MODE             = O
        TITLE            = Choose File(002)
      IMPORTING
        FILENAME         = FN1
      EXCEPTIONS
        INV_WINSYS       = 1
        NO_BATCH         = 2
        SELECTION_CANCEL = 3
        SELECTION_ERROR  = 4
        OTHERS           = 5.
  ENDIF.
ENDFORM.                    " GET_PC_FILENAME
*&---------------------------------------------------------------------*
*&      Form  FRM_CHANGE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PV_DATA    text
*      -->LV_CHAR    text
*----------------------------------------------------------------------*
FORM FRM_CHANGE_DATA USING PV_DATA TYPE HSLVT12 CHANGING  LV_CHAR TYPE CHAR20.

  DATA :
        L_AMT(17),
        L_INT(10),
        L_CHAR(17),
        L_FAC(2),
        L_LEN TYPE I,
        L_COUNT TYPE I,
        L_POS TYPE I,
        L_REST TYPE I,
        L_TIME TYPE I.
  DATA L_NUM  TYPE DMBTR.
  DATA L_RESULT TYPE CHAR30.
  L_NUM = PV_DATA.

  CONSTANTS: C_TAB VALUE ,,
  C_POT VALUE ..

  CLEAR L_AMT.
  IF L_NUM > 0.
    L_AMT = ABS( L_NUM ).
    CONDENSE L_AMT.
    SPLIT L_AMT AT C_POT INTO L_INT L_FAC.
    L_LEN = STRLEN( L_INT ).
    L_COUNT = L_LEN.
    L_REST = L_LEN MOD 3.
    IF L_REST = 0.
      L_TIME = L_LEN DIV 3.
    ELSE.
      L_TIME = L_LEN DIV 3 + 1.
    ENDIF.
    DO L_TIME TIMES.
      L_COUNT = L_COUNT - 3.
      IF L_COUNT > 0.
        CONCATENATE C_TAB L_INT+L_COUNT(3) L_CHAR INTO L_CHAR.
      ELSEIF L_COUNT <= 0.
        L_COUNT = L_COUNT + 3.
        CONCATENATE L_INT+0(L_COUNT) L_CHAR INTO L_CHAR.
        EXIT.
      ENDIF.
    ENDDO.
    CLEAR L_LEN.
    L_LEN = STRLEN( L_FAC ).
    IF L_FAC IS INITIAL.
      CONCATENATE L_CHAR .00 INTO L_RESULT.
    ELSEIF L_LEN = 1.
      CONCATENATE L_CHAR . L_FAC 0 INTO L_RESULT.
    ELSEIF L_LEN = 2.
      CONCATENATE L_CHAR . L_FAC INTO L_RESULT.
    ENDIF.
    CONDENSE L_RESULT.
  ELSEIF L_NUM < 0.

    L_AMT = ABS( L_NUM ).
    CONDENSE L_AMT.
    SPLIT L_AMT AT C_POT INTO L_INT L_FAC.
    L_LEN = STRLEN( L_INT ).
    L_COUNT = L_LEN.
    L_REST = L_LEN MOD 3.
    IF L_REST = 0.
      L_TIME = L_LEN DIV 3.
    ELSE.
      L_TIME = L_LEN DIV 3 + 1.
    ENDIF.
    DO L_TIME TIMES.
      L_COUNT = L_COUNT - 3.
      IF L_COUNT > 0.
        CONCATENATE C_TAB L_INT+L_COUNT(3) L_CHAR INTO L_CHAR.
      ELSEIF L_COUNT <= 0.
        L_COUNT = L_COUNT + 3.
        CONCATENATE L_INT+0(L_COUNT) L_CHAR INTO L_CHAR.
        EXIT.
      ENDIF.
    ENDDO.
    CLEAR L_LEN.
    L_LEN = STRLEN( L_FAC ).
    IF L_FAC IS INITIAL.
      CONCATENATE - L_CHAR .00 INTO L_RESULT.
    ELSEIF L_LEN = 1.
      CONCATENATE - L_CHAR . L_FAC 0 INTO L_RESULT.
    ELSEIF L_LEN = 2.
      CONCATENATE - L_CHAR . L_FAC INTO L_RESULT.
    ENDIF.
    CONDENSE L_RESULT.
  ELSE.
    L_RESULT = 0.00.
  ENDIF.
  LV_CHAR = L_RESULT.
*  ENDIF.
*LV_CHAR = LS_DATA-DMBTR.
*CONDENSE LV_CHAR.
*data lv_num type i.
*lv_num = STRLEN( LV_CHAR ).
*lv_num = lv_num - 1.
*IF LV_CHAR+lv_num(1) = -.
*LV_CHAR+lv_num(1) = ‘‘.
*LV_CHAR =  - && LV_CHAR.
*ENDIF.
*CONDENSE LV_CHAR.
*CONDENSE LV_CHAR.
ENDFORM.                    "FRM_CHANGE_DATA

 

ZFIR054-现金流量表