码迷,mamicode.com
首页 > 其他好文 > 详细

责任成本汇总表

时间:2017-08-04 13:55:59      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:percent   业务   inpu   cos   not   min   symbols   www   interval   

**=====================================================================*
*& Report ZCO_RP_11
**=====================================================================*
REPORT zco_rp_11.

**=====================================================================*
*  Program ID             :  ZCO_RP_11
*  Program Description    :  责任成本汇总表



*======================================================================*
*                             Tables
*======================================================================*
TABLES: bkpf,mseg,aufk.

*======================================================================*
*                             Constants
*======================================================================*

*======================================================================*
*                             Types
*======================================================================*
TYPES: BEGIN OF gty_s_bukrs,
         bukrs TYPE t001-bukrs,
         butxt TYPE t001-butxt,
       END OF gty_s_bukrs.

TYPES: BEGIN OF gty_s_comp,
         bukrs TYPE t001-bukrs,
         bys   TYPE char5,
         byljs TYPE char7,
         bl    TYPE char5,
       END OF gty_s_comp.
DATA: gt_comp TYPE STANDARD TABLE OF gty_s_comp.

DATA: BEGIN OF gt_tab OCCURS 0,
        ym         TYPE char6,
        curdate    TYPE char40,
        tagvalue   TYPE char20,
        pid        TYPE i,
        wplantname TYPE char30,
        tagname    TYPE char30,
        medid      TYPE char18,
      END OF gt_tab.

DATA: BEGIN OF gt_werks OCCURS 0,
        pid   TYPE i,
        werks TYPE t001w-werks,
      END OF gt_werks.
*======================================================================*
*                     Internal Tables/work areas
*======================================================================*
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <dyn_wa>.
FIELD-SYMBOLS: <dyn_field>,<dyn_fieldt>.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: dy_table TYPE REF TO data,
      dy_line  TYPE REF TO data.
DATA: gt_bukrs TYPE STANDARD TABLE OF gty_s_bukrs.
*======================================================================*
*                      Data declarations
*======================================================================*
DATA: p_filename TYPE string.
DATA: l_filename TYPE string.
DATA: gv_pid TYPE i.

DATA: g_excel  TYPE ole2_object. "excel object
DATA: g_books  TYPE ole2_object.
DATA: g_book   TYPE ole2_object.
DATA: g_sheet  TYPE ole2_object.
DATA: g_cells  TYPE ole2_object.
DATA: g_cells1 TYPE ole2_object,
      g_cells2 TYPE ole2_object.

*======================================================================*
*                       Range declarations
*======================================================================*

*======================================================================*
*                      Input Selection Screen
*======================================================================*
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_bukrs FOR bkpf-bukrs OBLIGATORY,
               s_werks FOR mseg-werks OBLIGATORY,
               s_aufnr FOR aufk-aufnr OBLIGATORY.
PARAMETERS:p_gjahr LIKE bkpf-gjahr OBLIGATORY,
           p_monat LIKE bkpf-monat OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK b1.


*======================================================================*
*                        AT SELECTION-SCREEN ON VALUE-REQUEST
*======================================================================*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_aufnr-low.
  PERFORM frm_f4_for_aufnr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_aufnr-high.
  PERFORM frm_f4_for_aufnr.

*======================================================================*
*                        Start of Selection
*======================================================================*
START-OF-SELECTION.
  PERFORM frm_connect_db.
  PERFORM frm_create_dynmic_table.
  PERFORM frm_get_data.

*======================================================================*
*                        End of Selection
*======================================================================*
END-OF-SELECTION.
  PERFORM frm_down_excel.


*&---------------------------------------------------------------------*
*&      Form  FRM_CONNECT_DB
*&---------------------------------------------------------------------*
*       连接SQL Server数据库
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_connect_db .

  DATA: dbs TYPE dbcon-con_name VALUEINTWATERKDCONTEXT2.
  DATA: conn_ref TYPE REF TO cx_sy_native_sql_error.
  DATA: exec_err TYPE REF TO cx_sy_native_sql_error.
  DATA: error_text(100) TYPE c.
  DATA: lv_pid TYPE i.
  DATA: lv_begda TYPE char10.
  DATA: lv_endda TYPE char10.
  DATA: BEGIN OF lt_t001w OCCURS 0,
          werks TYPE t001w-werks,
        END OF lt_t001w.
  DATA: lv_year TYPE char6.

  CONCATENATE p_gjahr ‘%‘ INTO lv_year.
  CONDENSE lv_year NO-GAPS.
  SELECT werks
    FROM t001w
    INTO CORRESPONDING FIELDS OF TABLE lt_t001w
   WHERE werks IN s_werks[].
  TRY .
      EXEC SQL.
        CONNECT TO :DBS
      ENDEXEC.
    CATCH cx_sy_native_sql_error INTO conn_ref.
      error_text = conn_ref->get_text( ).
      MESSAGE error_text TYPE ‘I‘.
      EXIT.
  ENDTRY.

  LOOP AT lt_t001w.

    TRY .
        EXEC SQL.
          SELECT PId
            INTO :lv_pid
            FROM WaterPlants
           WHERE PlantNickName = :lt_t001w-werks
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO conn_ref.
        error_text = conn_ref->get_text( ).
        MESSAGE error_text TYPE ‘I‘.
        EXIT.
    ENDTRY.

    TRY .
        EXEC SQL PERFORMING process_sql2.
          SELECT PId,
                 PlantNickName
            INTO :gt_werks-pid,
                 :gt_werks-werks
            FROM WaterPlants
           WHERE PlantNickName = :lt_t001w-werks
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO conn_ref.
        error_text = conn_ref->get_text( ).
        MESSAGE error_text TYPE ‘I‘.
        EXIT.
    ENDTRY.

    TRY .
        EXEC SQL PERFORMING process_sql.
          SELECT ym,
                 CurDate,
                 TagValue,
                 PId,
                 WPlantName,
                 TagName,
                 MedID
            INTO :gt_tab-ym,
                 :gt_tab-CurDate,
                 :gt_tab-TagValue,
                 :gt_tab-PId,
                 :gt_tab-WPlantName,
                 :gt_tab-TagName,
                 :gt_tab-MedID
            FROM ERP_1
           WHERE PId = :lv_pid
             AND ym LIKE :lv_year
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO conn_ref.
        error_text = conn_ref->get_text( ).
        MESSAGE error_text TYPE ‘I‘.
        EXIT.
    ENDTRY.

  ENDLOOP.

ENDFORM.

FORM process_sql.
  APPEND gt_tab.
ENDFORM.
FORM process_sql2.
  APPEND gt_werks.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FRM_CREATE_DYNMIC_TABLE
*&---------------------------------------------------------------------*
*       创建动态内表
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_create_dynmic_table .

*创建动态结构
  PERFORM frm_frm_create_structure.
*创建动态内表
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = gt_fieldcat
    IMPORTING
      ep_table                  = dy_table
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.
  ASSIGN dy_table->* TO <dyn_table>.
  CREATE DATA dy_line LIKE LINE OF <dyn_table>.
  ASSIGN dy_line->* TO <dyn_wa>.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       查询数据
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_get_data .
  DATA: lt_range TYPE RANGE OF cosr-objnr.
  DATA: ls_range LIKE LINE OF lt_range.
  DATA: lt_range1 TYPE RANGE OF cosr-objnr.
  DATA: ls_range1 LIKE LINE OF lt_range1.
  DATA: ls_comp TYPE gty_s_comp.
  TYPES: BEGIN OF lty_s_faglflext,
           rbukrs TYPE bukrs,
           hsl01 TYPE hslxx12,
           hsl02 TYPE hslxx12,
           hsl03 TYPE hslxx12,
           hsl04 TYPE hslxx12,
           hsl05 TYPE hslxx12,
           hsl06 TYPE hslxx12,
           hsl07 TYPE hslxx12,
           hsl08 TYPE hslxx12,
           hsl09 TYPE hslxx12,
           hsl10 TYPE hslxx12,
           hsl11 TYPE hslxx12,
           hsl12 TYPE hslxx12,
         END OF lty_s_faglflext.
  DATA: ls_faglflext  TYPE lty_s_faglflext.
  DATA: lt_faglflext1 TYPE STANDARD TABLE OF lty_s_faglflext.
  DATA: ls_faglflext1 TYPE lty_s_faglflext."收入

  TYPES: BEGIN OF lty_s_cosr,
           objnr  TYPE j_objnr,
           sme001 TYPE smexxx,
           sme002 TYPE smexxx,
           sme003 TYPE smexxx,
           sme004 TYPE smexxx,
           sme005 TYPE smexxx,
           sme006 TYPE smexxx,
           sme007 TYPE smexxx,
           sme008 TYPE smexxx,
           sme009 TYPE smexxx,
           sme010 TYPE smexxx,
           sme011 TYPE smexxx,
           sme012 TYPE smexxx,
         END OF lty_s_cosr.
  DATA: ls_cosr  TYPE lty_s_cosr.
  DATA: lt_cosr1 TYPE STANDARD TABLE OF lty_s_cosr.
  DATA: ls_cosr1 TYPE lty_s_cosr."收费污水处理量
  DATA: lt_cosr2 TYPE STANDARD TABLE OF lty_s_cosr.
  DATA: ls_cosr2 TYPE lty_s_cosr."实际污水处理量
  DATA: lt_cosr3 TYPE STANDARD TABLE OF lty_s_cosr.
  DATA: ls_cosr3 TYPE lty_s_cosr."电度电量
  DATA: lt_cosr4 TYPE STANDARD TABLE OF lty_s_cosr.
  DATA: ls_cosr4 TYPE lty_s_cosr."基本负荷

  TYPES: BEGIN OF lty_s_coep,
           objnr  TYPE coep-objnr,
           perio  TYPE coep-perio,
           wogbtr TYPE coep-wogbtr,
           beknz  TYPE coep-beknz,
         END OF lty_s_coep.
  DATA: lt_coep1 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep1 TYPE lty_s_coep."工资
  DATA: lt_coep2 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep2 TYPE lty_s_coep."福利
  DATA: lt_coep3 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep3 TYPE lty_s_coep."社会保险
  DATA: lt_coep4 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep4 TYPE lty_s_coep."电度电费
  DATA: lt_coep5 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep5 TYPE lty_s_coep."基本电费
  DATA: lt_coep6 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep6 TYPE lty_s_coep."水费
  DATA: lt_coep7 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep7 TYPE lty_s_coep."药剂费小计
  DATA: lt_coep8 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep8 TYPE lty_s_coep."日常维护费
  DATA: lt_coep9 TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coep9 TYPE lty_s_coep."污泥外运及处置费
  DATA: lt_coepa TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepa TYPE lty_s_coep."化验费
  DATA: lt_coepb TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepb TYPE lty_s_coep."监測费
  DATA: lt_coepc TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepc TYPE lty_s_coep."管理费小计
  DATA: lt_coepd TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepd TYPE lty_s_coep."办公费
  DATA: lt_coepe TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepe TYPE lty_s_coep."差旅费
  DATA: lt_coepf TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepf TYPE lty_s_coep."通讯费
  DATA: lt_coepg TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepg TYPE lty_s_coep."车辆使用费
  DATA: lt_coeph TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coeph TYPE lty_s_coep."劳动保护费
  DATA: lt_coepi TYPE STANDARD TABLE OF lty_s_coep.
  DATA: ls_coepi TYPE lty_s_coep."业务费

  TYPES: BEGIN OF lty_s_t001k,
           bwkey TYPE t001k-bwkey,
           bukrs TYPE t001k-bukrs,
         END OF lty_s_t001k.
  DATA: lt_t001k TYPE STANDARD TABLE OF lty_s_t001k.
  DATA: ls_t001k TYPE lty_s_t001k.
  TYPES: BEGIN OF lty_s_setleaf,
           valsign   TYPE setleaf-valsign,
           valoption TYPE setleaf-valoption,
           valfrom   TYPE setleaf-valfrom,
           valto     TYPE setleaf-valto,
         END OF lty_s_setleaf.
  DATA: lt_setleaf TYPE STANDARD TABLE OF lty_s_setleaf.
  DATA: ls_setleaf TYPE lty_s_setleaf.
  DATA: lr_kstar TYPE RANGE OF coep-kstar.
  DATA: ls_kstar LIKE LINE OF lr_kstar.

  TYPES: BEGIN OF lty_s_zco010,
           bukrs TYPE zco010-bukrs,
           monat TYPE zco010-monat,
           zzrcb TYPE zco010-zzrcb,
         END OF lty_s_zco010.
  DATA: lt_zco010 TYPE STANDARD TABLE OF lty_s_zco010.
  DATA: ls_zco010 TYPE lty_s_zco010.

  TYPES: BEGIN OF lty_s_month,
           bukrs TYPE t001-bukrs,
           month TYPE smexxx,
           year  TYPE smexxx,
         END OF lty_s_month.
  DATA: ls_month TYPE lty_s_month.

  TYPES: BEGIN OF lty_s_bpej,
           objnr TYPE bpej-objnr,
           wtjhr TYPE bpej-wtjhr,
         END OF lty_s_bpej.
  DATA: lt_bpej TYPE STANDARD TABLE OF lty_s_bpej.
  DATA: ls_bpej TYPE lty_s_bpej.
  DATA: lv_hjbys TYPE smexxx.
  DATA: lv_hjbyljs TYPE smexxx.
  DATA: lv_day   TYPE bpej-wtjhr.
  DATA: lv_danjia TYPE p DECIMALS 3.
  DATA: lv_total TYPE bpej-wtjhr.
  DATA: lv_begda TYPE sy-datum.
  DATA: lv_endda TYPE sy-datum.
  DATA: lv_days  TYPE i.
  DATA: lv_fbdays  TYPE i.

  DATA: lv_year  TYPE char15,
        lv_month TYPE char15.
  DATA: lv_no       TYPE i.
  DATA: lv_field1   TYPE char10.
  DATA: lv_field2   TYPE char10.
  DATA: lv_matnr    TYPE char18.
  DATA: lv_matnr1   TYPE char18.

  FIELD-SYMBOLS:<dyn_wa1>,<dyn_wa2>,<dyn_wa3>,<dyn_wa4>,
                <dyn_wa5>,<dyn_wa6>,<dyn_wa7>,<dyn_wa8>.
  FIELD-SYMBOLS:<dyn_field1>,<dyn_field2>,<dyn_field3>,<dyn_field4>,
                <dyn_field5>,<dyn_field6>,<dyn_field7>,<dyn_field8>.
  FIELD-SYMBOLS:<dyn_field1t>,<dyn_field2t>,<dyn_field3t>.
  FIELD-SYMBOLS:<dy_field1>,<dy_field2>,<dy_field3>,<dy_field4>,
                <dy_field5>,<dy_field6>,<dy_field7>,<dy_field8>.
  FIELD-SYMBOLS:<dn_field1>,<dn_field2>,<dn_field3>,<dn_field4>,
                <dn_field5>,<dn_field6>,<dn_field7>,<dn_field8>.
  DATA: lv_field TYPE p DECIMALS 3.
  DATA: BEGIN OF lt_aufk OCCURS 0,
          aufnr TYPE aufk-aufnr,
        END OF lt_aufk.
DATA:BEGIN OF lt_aufnr OCCURS 0,
           bukrs TYPE coep-bukrs,
           objnr TYPE coep-objnr,
  END OF lt_aufnr.
DATA:BEGIN OF lt_aufnr1 OCCURS 0,
           bukrs TYPE coep-bukrs,
           objnr TYPE coep-objnr,
  END OF lt_aufnr1.
  DATA: ls_aufnr LIKE lt_aufnr.
  DATA: ls_aufnr1 LIKE lt_aufnr1.
  DATA: lv_length TYPE i.
  DATA: lv_beknz TYPE coep-beknz.
  DATA: lr_beknz TYPE RANGE OF coep-beknz.
  DATA: ls_beknz LIKE LINE OF lr_beknz.

  FIELD-SYMBOLS:<dy_field>.

  DATA: ls_line     TYPE REF TO data.
  DATA: ls_line1    TYPE REF TO data.
  DATA: ls_line2    TYPE REF TO data.
  DATA: ls_line3    TYPE REF TO data.
  DATA: ls_line4    TYPE REF TO data.
  DATA: ls_line5    TYPE REF TO data.
  DATA: ls_line6    TYPE REF TO data.
  DATA: ls_line7    TYPE REF TO data.
  DATA: ls_line8    TYPE REF TO data.

  CREATE DATA ls_line LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line1 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line2 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line3 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line4 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line5 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line6 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line7 LIKE LINE OF <dyn_table>.
  CREATE DATA ls_line8 LIKE LINE OF <dyn_table>.
* 用<dyn_wa>指针指向该结构
  ASSIGN ls_line->* TO <dyn_wa>.
  ASSIGN ls_line1->* TO <dyn_wa1>.
  ASSIGN ls_line2->* TO <dyn_wa2>.
  ASSIGN ls_line3->* TO <dyn_wa3>.
  ASSIGN ls_line4->* TO <dyn_wa4>.
  ASSIGN ls_line5->* TO <dyn_wa5>.
  ASSIGN ls_line6->* TO <dyn_wa6>.
  ASSIGN ls_line7->* TO <dyn_wa7>.
  ASSIGN ls_line8->* TO <dyn_wa8>.

*收入
  SELECT rbukrs
         hsl01
         hsl02
         hsl03
         hsl04
         hsl05
         hsl06
         hsl07
         hsl08
         hsl09
         hsl10
         hsl11
         hsl12
    FROM faglflext
    INTO CORRESPONDING FIELDS OF TABLE lt_faglflext1
   WHERE racct = ‘6001000000‘
     AND rbukrs IN s_bukrs
     AND ryear = p_gjahr.
  SORT lt_faglflext1 BY rbukrs.
  LOOP AT lt_faglflext1 INTO ls_faglflext.
    CASE p_monat.
      WHEN 1.
        ls_month-month = ls_month-month + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
      WHEN 2.
        ls_month-month = ls_month-month + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
      WHEN 3.
        ls_month-month = ls_month-month + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
      WHEN 4.
        ls_month-month = ls_month-month + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
      WHEN 5.
        ls_month-month = ls_month-month + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
      WHEN 6.
        ls_month-month = ls_month-month + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
      WHEN 7.
        ls_month-month = ls_month-month + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
      WHEN 8.
        ls_month-month = ls_month-month + ls_faglflext-hsl08.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl08.
      WHEN 9.
        ls_month-month = ls_month-month + ls_faglflext-hsl09.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl08.
        ls_month-year = ls_month-year + ls_faglflext-hsl09.
      WHEN 10.
        ls_month-month = ls_month-month + ls_faglflext-hsl10.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl08.
        ls_month-year = ls_month-year + ls_faglflext-hsl09.
        ls_month-year = ls_month-year + ls_faglflext-hsl10.
      WHEN 11.
        ls_month-month = ls_month-month + ls_faglflext-hsl11.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl08.
        ls_month-year = ls_month-year + ls_faglflext-hsl09.
        ls_month-year = ls_month-year + ls_faglflext-hsl10.
        ls_month-year = ls_month-year + ls_faglflext-hsl11.
      WHEN 12.
        ls_month-month = ls_month-month + ls_faglflext-hsl12.
        ls_month-year = ls_month-year + ls_faglflext-hsl01.
        ls_month-year = ls_month-year + ls_faglflext-hsl02.
        ls_month-year = ls_month-year + ls_faglflext-hsl03.
        ls_month-year = ls_month-year + ls_faglflext-hsl04.
        ls_month-year = ls_month-year + ls_faglflext-hsl05.
        ls_month-year = ls_month-year + ls_faglflext-hsl06.
        ls_month-year = ls_month-year + ls_faglflext-hsl07.
        ls_month-year = ls_month-year + ls_faglflext-hsl08.
        ls_month-year = ls_month-year + ls_faglflext-hsl09.
        ls_month-year = ls_month-year + ls_faglflext-hsl10.
        ls_month-year = ls_month-year + ls_faglflext-hsl11.
        ls_month-year = ls_month-year + ls_faglflext-hsl12.
      WHEN OTHERS.
    ENDCASE.
    AT END OF rbukrs.
      READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_faglflext-rbukrs.
      ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      lv_month = ls_month-month.
      SPLIT lv_month AT ‘-‘ INTO <dyn_field1> lv_month.

      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
      lv_year = ls_month-year.
      SPLIT lv_year AT ‘-‘ INTO <dyn_field2> lv_year.

      lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
      lv_hjbys = lv_hjbys + <dyn_field1>.
      CLEAR: ls_month.
    ENDAT.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.



*收费污水处理量

  SELECT aufnr
    FROM aufk
    INTO CORRESPONDING FIELDS OF TABLE lt_aufk
   WHERE aufnr IN s_aufnr[].
  LOOP AT lt_aufk.
    ls_range-sign = ‘I‘.
    ls_range-option = ‘EQ‘.
  lv_length = strlen( lt_aufk-aufnr ) - 1.
  lt_aufk-aufnr = lt_aufk-aufnr+0(lv_length).
  CONCATENATE lt_aufk-aufnr ‘1‘ INTO lt_aufk-aufnr.
    CONCATENATE ‘OR‘ lt_aufk-aufnr INTO ls_range-low.
    APPEND ls_range TO lt_range.
    CLEAR:ls_range,lt_aufk.
  ENDLOOP.
  LOOP AT lt_aufk.
    ls_range1-sign = ‘I‘.
    ls_range1-option = ‘EQ‘.
    CONCATENATE ‘OR‘ lt_aufk-aufnr INTO ls_range1-low.
    APPEND ls_range1 TO lt_range1.
    CLEAR:ls_range1,lt_aufk.
  ENDLOOP.
  SELECT bukrs
         objnr
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_aufnr
   WHERE objnr IN lt_range[]
     AND gjahr = p_gjahr
     AND bukrs IN s_bukrs[].
  SELECT bukrs
         objnr
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_aufnr1
   WHERE objnr IN lt_range1[]
     AND gjahr = p_gjahr
     AND bukrs IN s_bukrs[].
  IF sy-subrc <> 0.
    " EXIT.
  ENDIF.
  IF sy-subrc = 0.
    SORT lt_aufnr BY bukrs objnr.
    DELETE ADJACENT DUPLICATES FROM lt_aufnr COMPARING ALL FIELDS.
  IF lt_aufnr[] IS NOT INITIAL.
  SELECT objnr
         sme001
         sme002
         sme003
         sme004
         sme005
         sme006
         sme007
         sme008
         sme009
         sme010
         sme011
         sme012
    FROM cosr"coejr
    INTO CORRESPONDING FIELDS OF TABLE lt_cosr1
    FOR ALL ENTRIES IN lt_aufnr
   WHERE objnr = lt_aufnr-objnr
     AND gjahr = p_gjahr
     AND stagr = ‘S001‘
     AND wrttp = ‘01‘.
  ENDIF.

    LOOP AT lt_aufnr INTO ls_aufnr.
      READ TABLE lt_cosr1 INTO ls_cosr1 WITH KEY objnr = ls_aufnr-objnr.
    CASE p_monat.
      WHEN 1.
        ls_month-month = ls_month-month + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
      WHEN 2.
        ls_month-month = ls_month-month + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
      WHEN 3.
        ls_month-month = ls_month-month + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
      WHEN 4.
        ls_month-month = ls_month-month + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
      WHEN 5.
        ls_month-month = ls_month-month + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
      WHEN 6.
        ls_month-month = ls_month-month + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
      WHEN 7.
        ls_month-month = ls_month-month + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
      WHEN 8.
        ls_month-month = ls_month-month + ls_cosr1-sme008.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme008.
      WHEN 9.
        ls_month-month = ls_month-month + ls_cosr1-sme009.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme008.
        ls_month-year = ls_month-year + ls_cosr1-sme009.
      WHEN 10.
        ls_month-month = ls_month-month + ls_cosr1-sme010.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme008.
        ls_month-year = ls_month-year + ls_cosr1-sme009.
        ls_month-year = ls_month-year + ls_cosr1-sme010.
      WHEN 11.
        ls_month-month = ls_month-month + ls_cosr1-sme011.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme008.
        ls_month-year = ls_month-year + ls_cosr1-sme009.
        ls_month-year = ls_month-year + ls_cosr1-sme010.
        ls_month-year = ls_month-year + ls_cosr1-sme011.
      WHEN 12.
        ls_month-month = ls_month-month + ls_cosr1-sme012.
        ls_month-year = ls_month-year + ls_cosr1-sme001.
        ls_month-year = ls_month-year + ls_cosr1-sme002.
        ls_month-year = ls_month-year + ls_cosr1-sme003.
        ls_month-year = ls_month-year + ls_cosr1-sme004.
        ls_month-year = ls_month-year + ls_cosr1-sme005.
        ls_month-year = ls_month-year + ls_cosr1-sme006.
        ls_month-year = ls_month-year + ls_cosr1-sme007.
        ls_month-year = ls_month-year + ls_cosr1-sme008.
        ls_month-year = ls_month-year + ls_cosr1-sme009.
        ls_month-year = ls_month-year + ls_cosr1-sme010.
        ls_month-year = ls_month-year + ls_cosr1-sme011.
        ls_month-year = ls_month-year + ls_cosr1-sme012.
      WHEN OTHERS.
    ENDCASE.
      ls_month-bukrs = ls_aufnr-bukrs.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.


*实际污水处理量
IF lt_aufnr[] IS NOT INITIAL.
  SELECT objnr
         sme001
         sme002
         sme003
         sme004
         sme005
         sme006
         sme007
         sme008
         sme009
         sme010
         sme011
         sme012
    FROM cosr"coejr
    INTO CORRESPONDING FIELDS OF TABLE lt_cosr2
    FOR ALL ENTRIES IN lt_aufnr
   WHERE objnr = lt_aufnr-objnr
     AND gjahr = p_gjahr
     AND stagr = ‘S001‘
     AND wrttp = ‘04‘.
ENDIF.

    LOOP AT lt_aufnr INTO ls_aufnr.
      READ TABLE lt_cosr2 INTO ls_cosr2 WITH KEY objnr = ls_aufnr-objnr.
    CASE p_monat.
      WHEN 1.
        ls_month-month = ls_month-month + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
      WHEN 2.
        ls_month-month = ls_month-month + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
      WHEN 3.
        ls_month-month = ls_month-month + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
      WHEN 4.
        ls_month-month = ls_month-month + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
      WHEN 5.
        ls_month-month = ls_month-month + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
      WHEN 6.
        ls_month-month = ls_month-month + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
      WHEN 7.
        ls_month-month = ls_month-month + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
      WHEN 8.
        ls_month-month = ls_month-month + ls_cosr2-sme008.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme008.
      WHEN 9.
        ls_month-month = ls_month-month + ls_cosr2-sme009.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme008.
        ls_month-year = ls_month-year + ls_cosr2-sme009.
      WHEN 10.
        ls_month-month = ls_month-month + ls_cosr2-sme010.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme008.
        ls_month-year = ls_month-year + ls_cosr2-sme009.
        ls_month-year = ls_month-year + ls_cosr2-sme010.
      WHEN 11.
        ls_month-month = ls_month-month + ls_cosr2-sme011.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme008.
        ls_month-year = ls_month-year + ls_cosr2-sme009.
        ls_month-year = ls_month-year + ls_cosr2-sme010.
        ls_month-year = ls_month-year + ls_cosr2-sme011.
      WHEN 12.
        ls_month-month = ls_month-month + ls_cosr2-sme012.
        ls_month-year = ls_month-year + ls_cosr2-sme001.
        ls_month-year = ls_month-year + ls_cosr2-sme002.
        ls_month-year = ls_month-year + ls_cosr2-sme003.
        ls_month-year = ls_month-year + ls_cosr2-sme004.
        ls_month-year = ls_month-year + ls_cosr2-sme005.
        ls_month-year = ls_month-year + ls_cosr2-sme006.
        ls_month-year = ls_month-year + ls_cosr2-sme007.
        ls_month-year = ls_month-year + ls_cosr2-sme008.
        ls_month-year = ls_month-year + ls_cosr2-sme009.
        ls_month-year = ls_month-year + ls_cosr2-sme010.
        ls_month-year = ls_month-year + ls_cosr2-sme011.
        ls_month-year = ls_month-year + ls_cosr2-sme012.
      WHEN OTHERS.
    ENDCASE.
      ls_month-bukrs = ls_aufnr-bukrs.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.


*收费单位价格
    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 1.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 2.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*人工费小计
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR <dyn_wa>.

*工资
  ls_beknz-option = ‘EQ‘.
  ls_beknz-sign = ‘I‘.
  ls_beknz-low = ‘C‘.
  APPEND ls_beknz TO lr_beknz.
  ls_beknz-option = ‘EQ‘.
  ls_beknz-sign = ‘I‘.
  ls_beknz-high = ‘D‘.
  APPEND ls_beknz TO lr_beknz.
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep1
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001030100‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
ENDIF.
    SORT lt_coep1 BY objnr perio.
        LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep1 INTO ls_coep1 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep1-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep1-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep1-perio = 1.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5 OR ls_coep1-perio = 6.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5
              OR ls_coep1-perio = 6 OR ls_coep1-perio = 7.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5
              OR ls_coep1-perio = 6 OR ls_coep1-perio = 7 OR ls_coep1-perio = 8.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5
              OR ls_coep1-perio = 6 OR ls_coep1-perio = 7 OR ls_coep1-perio = 8 OR ls_coep1-perio = 9.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep1-perio = 1 OR ls_coep1-perio = 2 OR ls_coep1-perio = 3 OR ls_coep1-perio = 4 OR ls_coep1-perio = 5
              OR ls_coep1-perio = 6 OR ls_coep1-perio = 7 OR ls_coep1-perio = 8 OR ls_coep1-perio = 9 OR ls_coep1-perio = 10.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep1-perio < 12.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep1-perio < 13.
              ls_month-year = ls_month-year + ls_coep1-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*福利
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep2
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001030200‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep2 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep2 INTO ls_coep2 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep2-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep2-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep2-perio = 1.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5 OR ls_coep2-perio = 6.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5
              OR ls_coep2-perio = 6 OR ls_coep2-perio = 7.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5
              OR ls_coep2-perio = 6 OR ls_coep2-perio = 7 OR ls_coep2-perio = 8.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5
              OR ls_coep2-perio = 6 OR ls_coep2-perio = 7 OR ls_coep2-perio = 8 OR ls_coep2-perio = 9.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep2-perio = 1 OR ls_coep2-perio = 2 OR ls_coep2-perio = 3 OR ls_coep2-perio = 4 OR ls_coep2-perio = 5
              OR ls_coep2-perio = 6 OR ls_coep2-perio = 7 OR ls_coep2-perio = 8 OR ls_coep2-perio = 9 OR ls_coep2-perio = 10.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep2-perio < 12.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep2-perio < 13.
              ls_month-year = ls_month-year + ls_coep2-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*社会保险
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep3
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001030300‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep3 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep3 INTO ls_coep3 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep3-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep3-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep3-perio = 1.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5 OR ls_coep3-perio = 6.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5
              OR ls_coep3-perio = 6 OR ls_coep3-perio = 7.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5
              OR ls_coep3-perio = 6 OR ls_coep3-perio = 7 OR ls_coep3-perio = 8.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5
              OR ls_coep3-perio = 6 OR ls_coep3-perio = 7 OR ls_coep3-perio = 8 OR ls_coep3-perio = 9.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep3-perio = 1 OR ls_coep3-perio = 2 OR ls_coep3-perio = 3 OR ls_coep3-perio = 4 OR ls_coep3-perio = 5
              OR ls_coep3-perio = 6 OR ls_coep3-perio = 7 OR ls_coep3-perio = 8 OR ls_coep3-perio = 9 OR ls_coep3-perio = 10.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep3-perio < 12.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep3-perio < 13.
              ls_month-year = ls_month-year + ls_coep3-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*更新人工费
*  lv_month = s_monat-low.
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 6.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 7.
  READ TABLE <dyn_table> INTO <dyn_wa3> INDEX 8.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa3> TO <dy_field3>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa3> TO <dn_field3>.

      <dyn_field1> = <dy_field1> + <dy_field2> + <dy_field3>.
      <dyn_field2> = <dn_field1> + <dn_field2> + <dn_field3>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.

  MODIFY <dyn_table> FROM <dyn_wa> INDEX 5.
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.

*电费小计
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR <dyn_wa>.

*电度电费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep4
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001020100‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep4 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep4 INTO ls_coep4 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep4-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep4-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep4-perio = 1.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5 OR ls_coep4-perio = 6.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5
              OR ls_coep4-perio = 6 OR ls_coep4-perio = 7.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5
              OR ls_coep4-perio = 6 OR ls_coep4-perio = 7 OR ls_coep4-perio = 8.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5
              OR ls_coep4-perio = 6 OR ls_coep4-perio = 7 OR ls_coep4-perio = 8 OR ls_coep4-perio = 9.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep4-perio = 1 OR ls_coep4-perio = 2 OR ls_coep4-perio = 3 OR ls_coep4-perio = 4 OR ls_coep4-perio = 5
              OR ls_coep4-perio = 6 OR ls_coep4-perio = 7 OR ls_coep4-perio = 8 OR ls_coep4-perio = 9 OR ls_coep4-perio = 10.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep4-perio < 12.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep4-perio < 13.
              ls_month-year = ls_month-year + ls_coep4-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.
*单位电耗
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: <dyn_wa>.

*电度电量
IF lt_aufnr[] IS NOT INITIAL.
  SELECT objnr
         sme001
         sme002
         sme003
         sme004
         sme005
         sme006
         sme007
         sme008
         sme009
         sme010
         sme011
         sme012
    FROM cosr"coejr
    INTO CORRESPONDING FIELDS OF TABLE lt_cosr3
    FOR ALL ENTRIES IN lt_aufnr
   WHERE objnr = lt_aufnr-objnr
     AND gjahr = p_gjahr
     AND stagr = ‘S003‘
     AND wrttp = ‘04‘.
ENDIF.

    LOOP AT lt_aufnr INTO ls_aufnr.
      READ TABLE lt_cosr3 INTO ls_cosr3 WITH KEY objnr = ls_aufnr-objnr.
    CASE p_monat.
      WHEN 1.
        ls_month-month = ls_month-month + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
      WHEN 2.
        ls_month-month = ls_month-month + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
      WHEN 3.
        ls_month-month = ls_month-month + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
      WHEN 4.
        ls_month-month = ls_month-month + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
      WHEN 5.
        ls_month-month = ls_month-month + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
      WHEN 6.
        ls_month-month = ls_month-month + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
      WHEN 7.
        ls_month-month = ls_month-month + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
      WHEN 8.
        ls_month-month = ls_month-month + ls_cosr3-sme008.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme008.
      WHEN 9.
        ls_month-month = ls_month-month + ls_cosr3-sme009.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme008.
        ls_month-year = ls_month-year + ls_cosr3-sme009.
      WHEN 10.
        ls_month-month = ls_month-month + ls_cosr3-sme010.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme008.
        ls_month-year = ls_month-year + ls_cosr3-sme009.
        ls_month-year = ls_month-year + ls_cosr3-sme010.
      WHEN 11.
        ls_month-month = ls_month-month + ls_cosr3-sme011.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme008.
        ls_month-year = ls_month-year + ls_cosr3-sme009.
        ls_month-year = ls_month-year + ls_cosr3-sme010.
        ls_month-year = ls_month-year + ls_cosr3-sme011.
      WHEN 12.
        ls_month-month = ls_month-month + ls_cosr3-sme012.
        ls_month-year = ls_month-year + ls_cosr3-sme001.
        ls_month-year = ls_month-year + ls_cosr3-sme002.
        ls_month-year = ls_month-year + ls_cosr3-sme003.
        ls_month-year = ls_month-year + ls_cosr3-sme004.
        ls_month-year = ls_month-year + ls_cosr3-sme005.
        ls_month-year = ls_month-year + ls_cosr3-sme006.
        ls_month-year = ls_month-year + ls_cosr3-sme007.
        ls_month-year = ls_month-year + ls_cosr3-sme008.
        ls_month-year = ls_month-year + ls_cosr3-sme009.
        ls_month-year = ls_month-year + ls_cosr3-sme010.
        ls_month-year = ls_month-year + ls_cosr3-sme011.
        ls_month-year = ls_month-year + ls_cosr3-sme012.
      WHEN OTHERS.
    ENDCASE.
      ls_month-bukrs = ls_aufnr-bukrs.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*电度单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 10.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 12.
  CLEAR:lv_danjia.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*基本电费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep5
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001020200‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep5 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep5 INTO ls_coep5 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep5-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep5-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep5-perio = 1.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5 OR ls_coep5-perio = 6.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5
              OR ls_coep5-perio = 6 OR ls_coep5-perio = 7.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5
              OR ls_coep5-perio = 6 OR ls_coep5-perio = 7 OR ls_coep5-perio = 8.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5
              OR ls_coep5-perio = 6 OR ls_coep5-perio = 7 OR ls_coep5-perio = 8 OR ls_coep5-perio = 9.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep5-perio = 1 OR ls_coep5-perio = 2 OR ls_coep5-perio = 3 OR ls_coep5-perio = 4 OR ls_coep5-perio = 5
              OR ls_coep5-perio = 6 OR ls_coep5-perio = 7 OR ls_coep5-perio = 8 OR ls_coep5-perio = 9 OR ls_coep5-perio = 10.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep5-perio < 12.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep5-perio < 13.
              ls_month-year = ls_month-year + ls_coep5-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*基本负荷
IF lt_aufnr[] IS NOT INITIAL.
  SELECT objnr
         sme001
         sme002
         sme003
         sme004
         sme005
         sme006
         sme007
         sme008
         sme009
         sme010
         sme011
         sme012
    FROM cosr"coejr
    INTO CORRESPONDING FIELDS OF TABLE lt_cosr4
    FOR ALL ENTRIES IN lt_aufnr
   WHERE objnr = lt_aufnr-objnr
     AND gjahr = p_gjahr
     AND stagr = ‘S005‘
     AND wrttp = ‘04‘.
ENDIF.
    LOOP AT lt_aufnr INTO ls_aufnr.
      READ TABLE lt_cosr4 INTO ls_cosr4 WITH KEY objnr = ls_aufnr-objnr.
    CASE p_monat.
      WHEN 1.
        ls_month-month = ls_month-month + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
      WHEN 2.
        ls_month-month = ls_month-month + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
      WHEN 3.
        ls_month-month = ls_month-month + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
      WHEN 4.
        ls_month-month = ls_month-month + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
      WHEN 5.
        ls_month-month = ls_month-month + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
      WHEN 6.
        ls_month-month = ls_month-month + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
      WHEN 7.
        ls_month-month = ls_month-month + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
      WHEN 8.
        ls_month-month = ls_month-month + ls_cosr4-sme008.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme008.
      WHEN 9.
        ls_month-month = ls_month-month + ls_cosr4-sme009.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme008.
        ls_month-year = ls_month-year + ls_cosr4-sme009.
      WHEN 10.
        ls_month-month = ls_month-month + ls_cosr4-sme010.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme008.
        ls_month-year = ls_month-year + ls_cosr4-sme009.
        ls_month-year = ls_month-year + ls_cosr4-sme010.
      WHEN 11.
        ls_month-month = ls_month-month + ls_cosr4-sme011.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme008.
        ls_month-year = ls_month-year + ls_cosr4-sme009.
        ls_month-year = ls_month-year + ls_cosr4-sme010.
        ls_month-year = ls_month-year + ls_cosr4-sme011.
      WHEN 12.
        ls_month-month = ls_month-month + ls_cosr4-sme012.
        ls_month-year = ls_month-year + ls_cosr4-sme001.
        ls_month-year = ls_month-year + ls_cosr4-sme002.
        ls_month-year = ls_month-year + ls_cosr4-sme003.
        ls_month-year = ls_month-year + ls_cosr4-sme004.
        ls_month-year = ls_month-year + ls_cosr4-sme005.
        ls_month-year = ls_month-year + ls_cosr4-sme006.
        ls_month-year = ls_month-year + ls_cosr4-sme007.
        ls_month-year = ls_month-year + ls_cosr4-sme008.
        ls_month-year = ls_month-year + ls_cosr4-sme009.
        ls_month-year = ls_month-year + ls_cosr4-sme010.
        ls_month-year = ls_month-year + ls_cosr4-sme011.
        ls_month-year = ls_month-year + ls_cosr4-sme012.
      WHEN OTHERS.
    ENDCASE.
      ls_month-bukrs = ls_aufnr-bukrs.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*基本负荷单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 14.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 15.

    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*更新电费小计
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 10.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 14.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      <dyn_field1> = <dy_field1> + <dy_field2>.
      <dyn_field2> = <dn_field1> + <dn_field2>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.

  MODIFY <dyn_table> FROM <dyn_wa> INDEX 9.
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
*水费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep6
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001020300‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep6 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep6 INTO ls_coep6 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep6-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep6-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep6-perio = 1.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5 OR ls_coep6-perio = 6.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5
              OR ls_coep6-perio = 6 OR ls_coep6-perio = 7.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5
              OR ls_coep6-perio = 6 OR ls_coep6-perio = 7 OR ls_coep6-perio = 8.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5
              OR ls_coep6-perio = 6 OR ls_coep6-perio = 7 OR ls_coep6-perio = 8 OR ls_coep6-perio = 9.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep6-perio = 1 OR ls_coep6-perio = 2 OR ls_coep6-perio = 3 OR ls_coep6-perio = 4 OR ls_coep6-perio = 5
              OR ls_coep6-perio = 6 OR ls_coep6-perio = 7 OR ls_coep6-perio = 8 OR ls_coep6-perio = 9 OR ls_coep6-perio = 10.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep6-perio < 12.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep6-perio < 13.
              ls_month-year = ls_month-year + ls_coep6-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*药剂费小计
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep7
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001010001‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep7 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep7 INTO ls_coep7 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep7-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep7-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep7-perio = 1.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5 OR ls_coep7-perio = 6.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5
              OR ls_coep7-perio = 6 OR ls_coep7-perio = 7.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5
              OR ls_coep7-perio = 6 OR ls_coep7-perio = 7 OR ls_coep7-perio = 8.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5
              OR ls_coep7-perio = 6 OR ls_coep7-perio = 7 OR ls_coep7-perio = 8 OR ls_coep7-perio = 9.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep7-perio = 1 OR ls_coep7-perio = 2 OR ls_coep7-perio = 3 OR ls_coep7-perio = 4 OR ls_coep7-perio = 5
              OR ls_coep7-perio = 6 OR ls_coep7-perio = 7 OR ls_coep7-perio = 8 OR ls_coep7-perio = 9 OR ls_coep7-perio = 10.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep7-perio < 12.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep7-perio < 13.
              ls_month-year = ls_month-year + ls_coep7-wogbtr.
          ENDIF..
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.
*工厂公司相应关系
    IF gt_werks IS NOT INITIAL.
      SELECT bwkey
             bukrs
        FROM t001k
        INTO CORRESPONDING FIELDS OF TABLE lt_t001k
         FOR ALL ENTRIES IN gt_werks
       WHERE bwkey = gt_werks-werks.
    ENDIF.
*阴离子聚丙烯酰胺
  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000002‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阴离子聚丙烯酰胺&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 19.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阴离子聚丙烯酰胺*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000002‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阴离子聚丙烯酰胺&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 19.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 21.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阳离子聚丙烯酰胺

  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000001‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.
*阳离子聚丙烯酰胺&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 23.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阳离子聚丙烯酰胺*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000001‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
            ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*阳离子聚丙烯酰胺&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 23.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 25.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合硫酸铁

  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND ( zkwbm = ‘10000003‘ OR zkwbm = ‘10000004‘ ).
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.
*聚合硫酸铁&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 27.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合硫酸铁*用量

  CLEAR: lv_matnr,lv_matnr1.
  lv_matnr = ‘10000003‘.lv_matnr1 = ‘10000004‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND ( medid = ‘10000003‘ OR medid = ‘10000004‘).
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合硫酸铁&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 27.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 29.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合氯化铝
  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND ( zkwbm = ‘10000005‘ OR zkwbm = ‘10000006‘ ).
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合氯化铝&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 31.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合氯化铝*用量

    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND  ( medid = ‘10000005‘ OR medid = ‘10000006‘ ).
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*聚合氯化铝&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 31.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 33.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*活性炭
  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000019‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*活性炭&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 35.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*活性炭*用量

    CLEAR: lv_matnr.
      lv_matnr = ‘10000019‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*活性炭&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 35.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 37.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*乙酸钠
  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000009‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*乙酸钠&单耗

    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 39.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*乙酸钠*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000009‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.
      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*乙酸钠&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 39.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 41.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*液氧
  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000024‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*液氧&单耗
    READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 43.
    READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*液氧*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000024‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.

      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*液氧&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 43.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 45.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*消毒药剂
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: <dyn_wa>,lv_month.

*盐酸

  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000023‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*盐酸*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000023‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.
      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
            ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*盐酸&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 48.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 49.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*氯酸钠

  REFRESH lt_zco010.
  SELECT bukrs
         monat
         zzrcb
    FROM zco010
    INTO CORRESPONDING FIELDS OF TABLE lt_zco010
   WHERE bukrs IN s_bukrs
     AND werks IN s_werks
     AND aufnr IN s_aufnr
     AND gjahr = p_gjahr
     AND monat = p_monat
     AND zkwbm = ‘10000007‘.
  SORT lt_zco010 BY bukrs.
  LOOP AT lt_zco010 INTO ls_zco010.
    IF ls_zco010-monat = p_monat.
            ls_month-month = ls_month-month + ls_zco010-zzrcb.
    ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_zco010-monat = 1.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 2.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 3.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 4.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 5.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 6.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5 OR ls_zco010-monat = 6.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 7.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 8.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 9.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9.
              ls_month-year = ls_month-year + ls_zco010-zzrcb .
          ENDIF.
        WHEN 10.
          IF ls_zco010-monat = 1 OR ls_zco010-monat = 2 OR ls_zco010-monat = 3 OR ls_zco010-monat = 4 OR ls_zco010-monat = 5
              OR ls_zco010-monat = 6 OR ls_zco010-monat = 7 OR ls_zco010-monat = 8 OR ls_zco010-monat = 9 OR ls_zco010-monat = 10.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 11.
          IF ls_zco010-monat < 12.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN 12.
          IF ls_zco010-monat < 13.
              ls_month-year = ls_month-year + ls_zco010-zzrcb.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_zco010-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR: ls_aufnr1,ls_zco010.
  ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*氯酸钠*用量

    CLEAR: lv_matnr.
    lv_matnr = ‘10000007‘.
    LOOP AT lt_aufnr INTO ls_aufnr.
      LOOP AT lt_t001k INTO ls_t001k WHERE bukrs = ls_aufnr-bukrs.
        READ TABLE gt_werks WITH KEY werks = ls_t001k-bwkey.
        LOOP AT gt_tab WHERE pid = gt_werks-pid
                          AND medid = lv_matnr.
          IF gt_tab-ym+4(2) = p_monat.
            ls_month-month = ls_month-month + gt_tab-tagvalue.
          ENDIF.
      CASE p_monat.
        WHEN 1.
          IF gt_tab-ym+4(2) = 1.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 2.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 3.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 4.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 5.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 6.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5 OR gt_tab-ym+4(2) = 6.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 7.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 8.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 9.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 10.
          IF gt_tab-ym+4(2) = 1 OR gt_tab-ym+4(2) = 2 OR gt_tab-ym+4(2) = 3 OR gt_tab-ym+4(2) = 4 OR gt_tab-ym+4(2) = 5
              OR gt_tab-ym+4(2) = 6 OR gt_tab-ym+4(2) = 7 OR gt_tab-ym+4(2) = 8 OR gt_tab-ym+4(2) = 9 OR gt_tab-ym+4(2) = 10.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 11.
          IF gt_tab-ym+4(2) < 12.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
          ENDIF.
        WHEN 12.
          IF gt_tab-ym+4(2) < 13.
              ls_month-year = ls_month-year + gt_tab-tagvalue.
            ENDIF.
        WHEN OTHERS.
      ENDCASE.
        ENDLOOP.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*氯酸钠&单位价格
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 51.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 52.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*改动消毒药剂
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 48.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 51.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      <dyn_field1> = <dy_field1> + <dy_field2>.
      <dyn_field2> = <dn_field1> + <dn_field2>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.

  MODIFY <dyn_table> FROM <dyn_wa> INDEX 47.
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.

*其它药剂
  READ TABLE <dyn_table> INTO <dyn_wa>  INDEX 18.
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 19.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 23.
  READ TABLE <dyn_table> INTO <dyn_wa3> INDEX 27.
  READ TABLE <dyn_table> INTO <dyn_wa4> INDEX 31.
  READ TABLE <dyn_table> INTO <dyn_wa5> INDEX 35.
  READ TABLE <dyn_table> INTO <dyn_wa6> INDEX 39.
  READ TABLE <dyn_table> INTO <dyn_wa7> INDEX 43.
  READ TABLE <dyn_table> INTO <dyn_wa8> INDEX 47.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa3> TO <dy_field3>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa3> TO <dn_field3>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa4> TO <dy_field4>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa4> TO <dn_field4>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa5> TO <dy_field5>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa5> TO <dn_field5>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa6> TO <dy_field6>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa6> TO <dn_field6>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa7> TO <dy_field7>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa7> TO <dn_field7>.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa8> TO <dy_field8>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa8> TO <dn_field8>.
    <dyn_field1> = <dyn_field1>  - <dy_field1>  - <dy_field2>  - <dy_field3>  - <dy_field4>
                  - <dy_field5>  - <dy_field6>  - <dy_field7>  - <dy_field8>.
    <dyn_field2> = <dyn_field2>  - <dn_field1>  - <dn_field2>  - <dn_field3>  - <dn_field4>
                  - <dn_field5>  - <dn_field6>  - <dn_field7>  - <dn_field8>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.

*日常维护费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep8
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5101010001‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
ENDIF.

    SORT lt_coep8 BY objnr perio.
        LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep8 INTO ls_coep8 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep8-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep8-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep8-perio = 1.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5 OR ls_coep8-perio = 6.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5
              OR ls_coep8-perio = 6 OR ls_coep8-perio = 7.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5
              OR ls_coep8-perio = 6 OR ls_coep8-perio = 7 OR ls_coep8-perio = 8.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5
              OR ls_coep8-perio = 6 OR ls_coep8-perio = 7 OR ls_coep8-perio = 8 OR ls_coep8-perio = 9.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep8-perio = 1 OR ls_coep8-perio = 2 OR ls_coep8-perio = 3 OR ls_coep8-perio = 4 OR ls_coep8-perio = 5
              OR ls_coep8-perio = 6 OR ls_coep8-perio = 7 OR ls_coep8-perio = 8 OR ls_coep8-perio = 9 OR ls_coep8-perio = 10.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep8-perio < 12.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep8-perio < 13.
              ls_month-year = ls_month-year + ls_coep8-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*污泥外运及处置费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coep9
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5001040000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coep9 BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coep9 INTO ls_coep4 WHERE objnr = ls_aufnr1-objnr.
        IF ls_coep9-perio = p_monat.
          ls_month-month = ls_month-month + ls_coep9-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coep9-perio = 1.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5 OR ls_coep9-perio = 6.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5
              OR ls_coep9-perio = 6 OR ls_coep9-perio = 7.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5
              OR ls_coep9-perio = 6 OR ls_coep9-perio = 7 OR ls_coep9-perio = 8.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5
              OR ls_coep9-perio = 6 OR ls_coep9-perio = 7 OR ls_coep9-perio = 8 OR ls_coep9-perio = 9.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coep9-perio = 1 OR ls_coep9-perio = 2 OR ls_coep9-perio = 3 OR ls_coep9-perio = 4 OR ls_coep9-perio = 5
              OR ls_coep9-perio = 6 OR ls_coep9-perio = 7 OR ls_coep9-perio = 8 OR ls_coep9-perio = 9 OR ls_coep9-perio = 10.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coep9-perio < 12.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coep9-perio < 13.
              ls_month-year = ls_month-year + ls_coep9-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*化验费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepa
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5101020001‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepa BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepa INTO ls_coepa WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepa-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepa-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepa-perio = 1.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5 OR ls_coepa-perio = 6.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5
              OR ls_coepa-perio = 6 OR ls_coepa-perio = 7.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5
              OR ls_coepa-perio = 6 OR ls_coepa-perio = 7 OR ls_coepa-perio = 8.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5
              OR ls_coepa-perio = 6 OR ls_coepa-perio = 7 OR ls_coepa-perio = 8 OR ls_coepa-perio = 9.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepa-perio = 1 OR ls_coepa-perio = 2 OR ls_coepa-perio = 3 OR ls_coepa-perio = 4 OR ls_coepa-perio = 5
              OR ls_coepa-perio = 6 OR ls_coepa-perio = 7 OR ls_coepa-perio = 8 OR ls_coepa-perio = 9 OR ls_coepa-perio = 10.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepa-perio < 12.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepa-perio < 13.
              ls_month-year = ls_month-year + ls_coepa-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.
*监測费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepb
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘5101050000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepb BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepb INTO ls_coepb WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepb-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepb-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepb-perio = 1.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5 OR ls_coepb-perio = 6.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5
              OR ls_coepb-perio = 6 OR ls_coepb-perio = 7.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5
              OR ls_coepb-perio = 6 OR ls_coepb-perio = 7 OR ls_coepb-perio = 8.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5
              OR ls_coepb-perio = 6 OR ls_coepb-perio = 7 OR ls_coepb-perio = 8 OR ls_coepb-perio = 9.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepb-perio = 1 OR ls_coepb-perio = 2 OR ls_coepb-perio = 3 OR ls_coepb-perio = 4 OR ls_coepb-perio = 5
              OR ls_coepb-perio = 6 OR ls_coepb-perio = 7 OR ls_coepb-perio = 8 OR ls_coepb-perio = 9 OR ls_coepb-perio = 10.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepb-perio < 12.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepb-perio < 13.
              ls_month-year = ls_month-year + ls_coepb-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*管理费小计
  CLEAR: lt_setleaf, lr_beknz.
  SELECT valsign
         valoption
         valfrom
         valto
    FROM setleaf
    INTO CORRESPONDING FIELDS OF TABLE lt_setleaf
   WHERE setname = ‘ZCO002‘.
  LOOP AT lt_setleaf INTO ls_setleaf.
    ls_kstar-sign = ls_setleaf-valsign.
    ls_kstar-option = ls_setleaf-valoption.
    ls_kstar-low = ls_setleaf-valfrom.
    ls_kstar-high = ls_setleaf-valto.
    APPEND ls_kstar TO lr_kstar.
    CLEAR: ls_kstar,ls_setleaf.
  ENDLOOP.
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
  INTO CORRESPONDING FIELDS OF TABLE lt_coepc
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
   AND perio = p_monat
   AND gjahr = p_gjahr
   AND kstar IN lr_kstar[]
   AND vrgng = ‘COIN‘
   AND beknz IN lr_beknz[]
   AND bukrs IN s_bukrs.
ENDIF.
    SORT lt_coepc BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepc INTO ls_coepc WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepc-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepc-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepc-perio = 1.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5 OR ls_coepc-perio = 6.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5
              OR ls_coepc-perio = 6 OR ls_coepc-perio = 7.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5
              OR ls_coepc-perio = 6 OR ls_coepc-perio = 7 OR ls_coepc-perio = 8.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5
              OR ls_coepc-perio = 6 OR ls_coepc-perio = 7 OR ls_coepc-perio = 8 OR ls_coepc-perio = 9.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepc-perio = 1 OR ls_coepc-perio = 2 OR ls_coepc-perio = 3 OR ls_coepc-perio = 4 OR ls_coepc-perio = 5
              OR ls_coepc-perio = 6 OR ls_coepc-perio = 7 OR ls_coepc-perio = 8 OR ls_coepc-perio = 9 OR ls_coepc-perio = 10.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepc-perio < 12.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepc-perio < 13.
              ls_month-year = ls_month-year + ls_coepc-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*办公费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepd
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601210001‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepd BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepd INTO ls_coepd WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepd-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepd-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepd-perio = 1.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5 OR ls_coepd-perio = 6.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5
              OR ls_coepd-perio = 6 OR ls_coepd-perio = 7.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5
              OR ls_coepd-perio = 6 OR ls_coepd-perio = 7 OR ls_coepd-perio = 8.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5
              OR ls_coepd-perio = 6 OR ls_coepd-perio = 7 OR ls_coepd-perio = 8 OR ls_coepd-perio = 9.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepd-perio = 1 OR ls_coepd-perio = 2 OR ls_coepd-perio = 3 OR ls_coepd-perio = 4 OR ls_coepd-perio = 5
              OR ls_coepd-perio = 6 OR ls_coepd-perio = 7 OR ls_coepd-perio = 8 OR ls_coepd-perio = 9 OR ls_coepd-perio = 10.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepd-perio < 12.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepd-perio < 13.
              ls_month-year = ls_month-year + ls_coepd-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*差旅费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepe
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601200000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepe BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepe INTO ls_coepe WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepe-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepe-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepe-perio = 1.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5 OR ls_coepe-perio = 6.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5
              OR ls_coepe-perio = 6 OR ls_coepe-perio = 7.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5
              OR ls_coepe-perio = 6 OR ls_coepe-perio = 7 OR ls_coepe-perio = 8.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5
              OR ls_coepe-perio = 6 OR ls_coepe-perio = 7 OR ls_coepe-perio = 8 OR ls_coepe-perio = 9.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepe-perio = 1 OR ls_coepe-perio = 2 OR ls_coepe-perio = 3 OR ls_coepe-perio = 4 OR ls_coepe-perio = 5
              OR ls_coepe-perio = 6 OR ls_coepe-perio = 7 OR ls_coepe-perio = 8 OR ls_coepe-perio = 9 OR ls_coepe-perio = 10.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepe-perio < 12.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepe-perio < 13.
              ls_month-year = ls_month-year + ls_coepe-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*通讯费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepf
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601240000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepf BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepf INTO ls_coepf WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepf-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepf-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepf-perio = 1.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5 OR ls_coepf-perio = 6.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5
              OR ls_coepf-perio = 6 OR ls_coepf-perio = 7.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5
              OR ls_coepf-perio = 6 OR ls_coepf-perio = 7 OR ls_coepf-perio = 8.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5
              OR ls_coepf-perio = 6 OR ls_coepf-perio = 7 OR ls_coepf-perio = 8 OR ls_coepf-perio = 9.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepf-perio = 1 OR ls_coepf-perio = 2 OR ls_coepf-perio = 3 OR ls_coepf-perio = 4 OR ls_coepf-perio = 5
              OR ls_coepf-perio = 6 OR ls_coepf-perio = 7 OR ls_coepf-perio = 8 OR ls_coepf-perio = 9 OR ls_coepf-perio = 10.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepf-perio < 12.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepf-perio < 13.
              ls_month-year = ls_month-year + ls_coepf-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*车辆使用费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepg
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601280000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepg BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepg INTO ls_coepg WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepg-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepg-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepg-perio = 1.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5 OR ls_coepg-perio = 6.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5
              OR ls_coepg-perio = 6 OR ls_coepg-perio = 7.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5
              OR ls_coepg-perio = 6 OR ls_coepg-perio = 7 OR ls_coepg-perio = 8.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5
              OR ls_coepg-perio = 6 OR ls_coepg-perio = 7 OR ls_coepg-perio = 8 OR ls_coepg-perio = 9.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepg-perio = 1 OR ls_coepg-perio = 2 OR ls_coepg-perio = 3 OR ls_coepg-perio = 4 OR ls_coepg-perio = 5
              OR ls_coepg-perio = 6 OR ls_coepg-perio = 7 OR ls_coepg-perio = 8 OR ls_coepg-perio = 9 OR ls_coepg-perio = 10.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepg-perio < 12.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepg-perio < 13.
              ls_month-year = ls_month-year + ls_coepg-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*劳动保护费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coeph
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601560001‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
  ENDIF.

    SORT lt_coeph BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coeph INTO ls_coeph WHERE objnr = ls_aufnr1-objnr.
        IF ls_coeph-perio = p_monat.
          ls_month-month = ls_month-month + ls_coeph-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coeph-perio = 1.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5 OR ls_coeph-perio = 6.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5
              OR ls_coeph-perio = 6 OR ls_coeph-perio = 7.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5
              OR ls_coeph-perio = 6 OR ls_coeph-perio = 7 OR ls_coeph-perio = 8.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5
              OR ls_coeph-perio = 6 OR ls_coeph-perio = 7 OR ls_coeph-perio = 8 OR ls_coeph-perio = 9.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coeph-perio = 1 OR ls_coeph-perio = 2 OR ls_coeph-perio = 3 OR ls_coeph-perio = 4 OR ls_coeph-perio = 5
              OR ls_coeph-perio = 6 OR ls_coeph-perio = 7 OR ls_coeph-perio = 8 OR ls_coeph-perio = 9 OR ls_coeph-perio = 10.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coeph-perio < 12.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coeph-perio < 13.
              ls_month-year = ls_month-year + ls_coeph-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*业务费
IF lt_aufnr1[] IS NOT INITIAL.
  SELECT objnr
         perio
         wogbtr
         beknz
    FROM coep
    INTO CORRESPONDING FIELDS OF TABLE lt_coepi
    FOR ALL ENTRIES IN lt_aufnr1
   WHERE objnr = lt_aufnr1-objnr
     AND perio = p_monat
     AND gjahr = p_gjahr
     AND kstar = ‘6601230000‘
     AND vrgng = ‘COIN‘
     AND beknz IN lr_beknz[]
     AND bukrs IN s_bukrs.
    ENDIF.

    SORT lt_coepi BY objnr perio.
     LOOP AT lt_aufnr1 INTO ls_aufnr1.
      LOOP AT lt_coepi INTO ls_coepi WHERE objnr = ls_aufnr1-objnr.
        IF ls_coepi-perio = p_monat.
          ls_month-month = ls_month-month + ls_coepi-wogbtr.
        ENDIF.
      CASE p_monat.
        WHEN 1.
          IF ls_coepi-perio = 1.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 2.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 3.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 4.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 5.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 6.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5 OR ls_coepi-perio = 6.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 7.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5
              OR ls_coepi-perio = 6 OR ls_coepi-perio = 7.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 8.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5
              OR ls_coepi-perio = 6 OR ls_coepi-perio = 7 OR ls_coepi-perio = 8.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 9.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5
              OR ls_coepi-perio = 6 OR ls_coepi-perio = 7 OR ls_coepi-perio = 8 OR ls_coepi-perio = 9.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 10.
          IF ls_coepi-perio = 1 OR ls_coepi-perio = 2 OR ls_coepi-perio = 3 OR ls_coepi-perio = 4 OR ls_coepi-perio = 5
              OR ls_coepi-perio = 6 OR ls_coepi-perio = 7 OR ls_coepi-perio = 8 OR ls_coepi-perio = 9 OR ls_coepi-perio = 10.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 11.
          IF ls_coepi-perio < 12.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN 12.
          IF ls_coepi-perio < 13.
              ls_month-year = ls_month-year + ls_coepi-wogbtr.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      ENDLOOP.
      AT END OF bukrs.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr1-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*其它费用
  READ TABLE <dyn_table> INTO <dyn_wa>  INDEX 59.
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 60.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 61.
  READ TABLE <dyn_table> INTO <dyn_wa3> INDEX 62.
  READ TABLE <dyn_table> INTO <dyn_wa4> INDEX 63.
  READ TABLE <dyn_table> INTO <dyn_wa5> INDEX 64.
  READ TABLE <dyn_table> INTO <dyn_wa6> INDEX 65.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa3> TO <dy_field3>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa3> TO <dn_field3>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa4> TO <dy_field4>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa4> TO <dn_field4>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa5> TO <dy_field5>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa5> TO <dn_field5>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa6> TO <dy_field6>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa6> TO <dn_field6>.

      <dyn_field1> = <dyn_field1> - <dy_field1> - <dy_field2> - <dy_field3> - <dy_field4> - <dy_field5> - <dy_field6>.
      <dyn_field2> = <dyn_field2> - <dn_field1> - <dn_field2> - <dn_field3> - <dn_field4> - <dn_field5> - <dn_field6>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*实际责任成本
  READ TABLE <dyn_table> INTO <dyn_wa>  INDEX 5.
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 9.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 17.
  READ TABLE <dyn_table> INTO <dyn_wa3> INDEX 18.
  READ TABLE <dyn_table> INTO <dyn_wa4> INDEX 55.
  READ TABLE <dyn_table> INTO <dyn_wa5> INDEX 56.
  READ TABLE <dyn_table> INTO <dyn_wa6> INDEX 57.
  READ TABLE <dyn_table> INTO <dyn_wa7> INDEX 58.
  READ TABLE <dyn_table> INTO <dyn_wa8> INDEX 59.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa3> TO <dy_field3>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa3> TO <dn_field3>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa4> TO <dy_field4>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa4> TO <dn_field4>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa5> TO <dy_field5>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa5> TO <dn_field5>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa6> TO <dy_field6>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa6> TO <dn_field6>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa7> TO <dy_field7>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa7> TO <dn_field7>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa8> TO <dy_field8>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa8> TO <dn_field8>.
      <dyn_field1> = <dyn_field1> + <dy_field1> + <dy_field2> + <dy_field3> + <dy_field4> + <dy_field5> + <dy_field6> + <dy_field7> + <dy_field8>.
      <dyn_field2> = <dyn_field2> + <dn_field1> + <dn_field2> + <dn_field3> + <dn_field4> + <dn_field5> + <dn_field6> + <dn_field7> + <dn_field8>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*实际单位责任成本
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 67.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 3.

    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*核定单位责任成本
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*核定责任成本
IF lt_aufnr[] IS NOT INITIAL.
  SELECT objnr
         wtjhr
    FROM bpej
    INTO CORRESPONDING FIELDS OF TABLE lt_bpej
    FOR ALL ENTRIES IN lt_aufnr
   WHERE objnr = lt_aufnr-objnr
     AND gjahr = p_gjahr
     AND wrttp = ‘41‘.
ENDIF.
    CONCATENATE p_gjahr ‘0201‘ INTO lv_begda.
    CALL FUNCTION ‘LAST_DAY_OF_MONTHS‘
      EXPORTING
        day_in            = lv_begda
      IMPORTING
        last_day_of_month = lv_endda.
    CALL FUNCTION ‘HR_99S_INTERVAL_BETWEEN_DATES‘
      EXPORTING
        begda = lv_begda
        endda = lv_endda
      IMPORTING
        days  = lv_fbdays.
  CLEAR: lv_begda,lv_endda,lv_days.
  CONCATENATE p_gjahr ‘0101‘ INTO lv_begda.
  CONCATENATE p_gjahr ‘1231‘ INTO lv_endda.
  CALL FUNCTION ‘HR_99S_INTERVAL_BETWEEN_DATES‘
    EXPORTING
      begda     = lv_begda
      endda     = lv_endda
    IMPORTING
      days      = lv_days.
CLEAR lv_total.
SORT lt_bpej BY objnr.
LOOP AT lt_aufnr INTO ls_aufnr.
  LOOP AT lt_bpej INTO ls_bpej WHERE objnr = ls_aufnr-objnr.
    lv_total = lv_total + ls_bpej-wtjhr.
    CLEAR ls_bpej.
  ENDLOOP.
      AT END OF bukrs.
    lv_day = lv_total / lv_days.
    CLEAR: lv_begda,lv_endda,lv_days.
    CONCATENATE p_gjahr p_monat ‘01‘ INTO lv_begda.
    CALL FUNCTION ‘LAST_DAY_OF_MONTHS‘
      EXPORTING
        day_in            = lv_begda
      IMPORTING
        last_day_of_month = lv_endda.
    CALL FUNCTION ‘HR_99S_INTERVAL_BETWEEN_DATES‘
      EXPORTING
        begda = lv_begda
        endda = lv_endda
      IMPORTING
        days  = lv_days.
    ls_month-month = lv_day * lv_days.
    CASE p_monat.
      WHEN 1.
         ls_month-year = lv_day * 31.
      WHEN 2.
         ls_month-year = lv_day * ( 31 + lv_fbdays ).
      WHEN 3.
         ls_month-year = lv_day * ( 62 + lv_fbdays ).
      WHEN 4.
         ls_month-year = lv_day * ( 92 + lv_fbdays ).
      WHEN 5.
         ls_month-year = lv_day * ( 123 + lv_fbdays ).
      WHEN 6.
         ls_month-year = lv_day * ( 153 + lv_fbdays ).
      WHEN 7.
         ls_month-year = lv_day * ( 184 + lv_fbdays ).
      WHEN 8.
         ls_month-year = lv_day * ( 215 + lv_fbdays ).
      WHEN 9.
         ls_month-year = lv_day * ( 245 + lv_fbdays ).
      WHEN 10.
         ls_month-year = lv_day * ( 276 + lv_fbdays ).
      WHEN 11.
         ls_month-year = lv_day * ( 306 + lv_fbdays ).
      WHEN 12.
         ls_month-year = lv_day * ( 337 + lv_fbdays ).
      WHEN OTHERS.
    ENDCASE.
        READ TABLE gt_comp INTO ls_comp WITH KEY bukrs = ls_aufnr-bukrs.
        ASSIGN COMPONENT ls_comp-bys OF STRUCTURE <dyn_wa> TO <dyn_field1>.
        <dyn_field1> = ls_month-month.
        ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.
        <dyn_field2> = ls_month-year.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
        CLEAR: ls_month.
      ENDAT.
      CLEAR ls_aufnr1.
ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: lv_hjbys,lv_hjbyljs,<dyn_wa>.

*改动核定单位责任成本
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 70.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 2.

    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dn_field1> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 69.
  CLEAR: lv_month,<dyn_wa>.  CLEAR: lv_hjbys,lv_hjbyljs.

*责任成本结(+)超(-)
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 70.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dn_field1>.

      ASSIGN COMPONENT ls_comp-bys   OF STRUCTURE <dyn_wa2> TO <dy_field2>.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.

      <dyn_field1> = <dy_field1> - <dy_field2>.
      <dyn_field2> = <dn_field1> - <dn_field2>.
        lv_hjbys = lv_hjbys + <dyn_field1>.
        lv_hjbyljs = lv_hjbyljs + <dyn_field2>.
    ENDLOOP.
  ASSIGN COMPONENT ‘HJBYS‘ OF STRUCTURE <dyn_wa> TO <dyn_field3>.
  <dyn_field3> = lv_hjbys.
  ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa> TO <dyn_field4>.
  <dyn_field4> = lv_hjbyljs.
  APPEND <dyn_wa> TO <dyn_table>.
  CLEAR: <dyn_wa>,lv_month.  CLEAR: lv_hjbys,lv_hjbyljs.
*改动人工费小计的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 5.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 5 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*电费小计的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 9.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 9 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*水费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 17.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 17 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.
*药剂费小计的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 18.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 18 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*日常维护费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 55.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 55 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*污泥外运及处置费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 56.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 56 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*化验费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 57.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 57 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.
*监測费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 58.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 58 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.

*管理费的比例
  READ TABLE <dyn_table> INTO <dyn_wa1> INDEX 59.
  READ TABLE <dyn_table> INTO <dyn_wa2> INDEX 67.
    LOOP AT gt_comp INTO ls_comp.
      ASSIGN COMPONENT ls_comp-bl   OF STRUCTURE <dyn_wa> TO <dyn_field1>.
      ASSIGN COMPONENT ‘HJBL‘   OF STRUCTURE <dyn_wa> TO <dyn_field2>.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa1> TO <dy_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa1> TO <dy_field2>.
      CONDENSE <dy_field2> NO-GAPS.

      ASSIGN COMPONENT ‘HJBYLJS‘ OF STRUCTURE <dyn_wa2> TO <dn_field1>.
      CONDENSE <dy_field2> NO-GAPS.
      ASSIGN COMPONENT ls_comp-byljs OF STRUCTURE <dyn_wa2> TO <dn_field2>.
      CONDENSE <dn_field2> NO-GAPS.

      IF <dn_field2> IS NOT INITIAL AND <dn_field2> <> ‘0.000‘.
        lv_danjia = <dy_field2> / <dn_field2>.
        <dyn_field1> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
      IF <dn_field1> IS NOT INITIAL AND <dn_field1> <> ‘0.000‘.
        lv_danjia = <dy_field1> / <dn_field1>.
        <dyn_field2> = lv_danjia.
        CLEAR lv_danjia.
      ENDIF.
  MODIFY <dyn_table> FROM <dyn_wa> INDEX 59 TRANSPORTING (ls_comp-bl) (‘HJBL‘).
  CLEAR: <dyn_wa>,lv_month,lv_hjbys,lv_hjbyljs.
    ENDLOOP.
ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FRM_DOWN_EXCEL
*&---------------------------------------------------------------------*
*       下载Excel
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_down_excel .

  DATA: lv_filename TYPE wwwdatatab-objid.

  lv_filename = ‘ZCO_RP_11.
  SELECT COUNT(*)
    FROM wwwdata
    WHERE relid = ‘MIAND objid = lv_filename.
  IF sy-subrc <> 0.
    MESSAGE  ‘所选XLS模板不存在。请又一次选择XLS模板‘ TYPE ‘E‘.
    EXIT.
  ENDIF.

  PERFORM frm_process_indcator USING ‘数据批量下载中 请等待 ... ... ‘ 0 .
  PERFORM frm_handle_export USING lv_filename l_filename.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FRM_FRM_CREATE_STRUCTURE
*&---------------------------------------------------------------------*
*       创建动态结构
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_frm_create_structure .

  DATA: ls_bukrs TYPE gty_s_bukrs.
  DATA: ls_comp  TYPE gty_s_comp.
  DATA: ls_fieldcat TYPE lvc_s_fcat.
  DATA: lv_index TYPE char2.

*获取查询单位
  SELECT bukrs
         butxt
    FROM t001
    INTO CORRESPONDING FIELDS OF TABLE gt_bukrs
   WHERE bukrs IN s_bukrs[].
    lv_index = lines( gt_bukrs ).
  SORT gt_bukrs BY bukrs.
  ls_fieldcat-fieldname = ‘HJBYS.
  ls_fieldcat-scrtext_l = ‘合计本月数‘.
  ls_fieldcat-inttype = ‘C.
  ls_fieldcat-intlen = 15.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = ‘HJBYLJS.
  ls_fieldcat-scrtext_l = ‘合计本年累计数‘.
  ls_fieldcat-inttype = ‘C.
  ls_fieldcat-intlen = 15.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = ‘HJBL.
  ls_fieldcat-scrtext_l = ‘合计比例‘.
  ls_fieldcat-inttype = ‘C.
  ls_fieldcat-intlen = 15.
  APPEND ls_fieldcat TO gt_fieldcat.
  CLEAR ls_fieldcat.

  LOOP AT gt_bukrs INTO ls_bukrs.

    lv_index = lv_index + 1.
    CONDENSE lv_index NO-GAPS.
    CALL FUNCTIONCONVERSION_EXIT_ALPHA_INPUTEXPORTING
        input  = lv_index
      IMPORTING
        output = lv_index.
    ls_comp-bukrs = ls_bukrs-bukrs.
    CONCATENATEBYSlv_index INTO ls_fieldcat-fieldname.
    ls_comp-bys = ls_fieldcat-fieldname.
    ls_fieldcat-scrtext_l = ‘本月数‘.
    ls_fieldcat-inttype = ‘C.
    ls_fieldcat-intlen = 15.
    APPEND ls_fieldcat TO gt_fieldcat.
    CLEAR ls_fieldcat.

    CONCATENATEBYLJSlv_index INTO ls_fieldcat-fieldname.
    ls_comp-byljs = ls_fieldcat-fieldname.
    ls_fieldcat-scrtext_l = ‘本年累计数‘.
    ls_fieldcat-inttype = ‘C.
    ls_fieldcat-intlen = 15.
    APPEND ls_fieldcat TO gt_fieldcat.
    CLEAR ls_fieldcat.

    CONCATENATEBLlv_index INTO ls_fieldcat-fieldname.
    ls_comp-bl = ls_fieldcat-fieldname.
    ls_fieldcat-scrtext_l = ‘比例‘.
    ls_fieldcat-inttype = ‘C.
    ls_fieldcat-intlen = 15.
    APPEND ls_fieldcat TO gt_fieldcat.
    CLEAR ls_fieldcat.

    APPEND ls_comp TO gt_comp.
    CLEAR ls_comp.

  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FRM_F4_FOR_AUFNR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_f4_for_aufnr .

  TYPES: BEGIN OF lty_s_aufnr,
           aufnr TYPE coas-aufnr,
         END OF lty_s_aufnr.
  DATA: lt_aufnr  TYPE STANDARD TABLE OF lty_s_aufnr.
*  DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
*  DATA: ls_return TYPE ddshretval.
*  DATA: lt_dynpread TYPE STANDARD TABLE OF dynpread.
*  DATA: ls_dynpread TYPE dynpread.
*
*  ls_dynpread-fieldname = ‘S_BUKRS.
*  APPEND ls_dynpread TO lt_dynpread.
*  CLEAR: ls_dynpread.
*  CALL FUNCTIONDYNP_VALUES_READ‘
*    EXPORTING
*      dyname               = sy-repid
*      dynumb               = sy-dynnr
*    TABLES
*      dynpfields           = lt_dynpread
*    EXCEPTIONS
*      invalid_abapworkarea = 1
*      invalid_dynprofield  = 2
*      invalid_dynproname   = 3
*      invalid_dynpronummer = 4
*      invalid_request      = 5
*      no_fielddescription  = 6
*      invalid_parameter    = 7
*      undefind_error       = 8
*      double_conversion    = 9
*      stepl_not_found      = 10
*      OTHERS               = 11.
*  IF sy-subrc = 0.
*    READ TABLE lt_dynpread INTO ls_dynpread WITH KEY fieldname = ‘S_BUKRS.
*    S_bukrs = ls_dynpread-fieldvalue.
*  ENDIF.
*
*  IF S_bukrs[] IS INITIAL.
*    MESSAGE ‘请先输入公司代码!

TYPESDISPLAY LIKEE. * EXIT. * ENDIF. SELECT aufnr INTO CORRESPONDING FIELDS OF TABLE lt_aufnr FROM coas WHERE auart = ‘K002AND bukrs IN s_bukrs . *调用帮助函数 CALL FUNCTIONF4IF_INT_TABLE_VALUE_REQUESTEXPORTING retfield = ‘AUFNRdynpprog = sy-repid dynpnr = sy-dynnr dynprofield = ‘S_AUFNRvalue_org = ‘Smultiple_choice = ‘‘ TABLES value_tab = lt_aufnr * return_tab = lt_return EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. * IF sy-subrc = 0. * READ TABLE lt_return INTO ls_return INDEX 1. * p_aufnr = ls_return-fieldval. * ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_PROCESS_INDCATOR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->TEXT text * -->PERCENTAGE text *----------------------------------------------------------------------* FORM frm_process_indcator USING text percentage. CALL FUNCTION ‘SAPGUI_PROGRESS_INDICATOR‘ EXPORTING percentage = percentage text = text. ENDFORM. " FRM_PROCESS_INDCATOR *&---------------------------------------------------------------------* *& Form FRM_HANDLE_EXPORT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_FILENAME text * -->L_FILENAME text *----------------------------------------------------------------------* FORM frm_handle_export USING p_filename l_filename. DATA: l_path TYPE string, l_fullpath TYPE string. CALL METHOD cl_gui_frontend_services=>file_save_dialog EXPORTING default_extension = ‘XLS‘ default_file_name = l_filename CHANGING filename = l_filename path = l_path fullpath = l_fullpath EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 OTHERS = 4. IF l_path IS NOT INITIAL AND l_fullpath IS NOT INITIAL. PERFORM frm_create_excel USING p_filename l_fullpath. ELSE. MESSAGE ‘请选择路径保存!

‘ TYPE ‘I‘ DISPLAY LIKE ‘E‘. EXIT. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CREATE_EXCEL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->L_PATTERN text * -->L_FULLPATH text *----------------------------------------------------------------------* FORM frm_create_excel USING l_pattern l_fullpath. DATA: lv_x1 TYPE p, lv_x2 TYPE p, lv_y1 TYPE p, lv_y2 TYPE p. DATA: lv_name TYPE char20. DATA: lv_bold TYPE p. DATA: lv_size TYPE char2. DATA: lv_title TYPE string. DATA: lv_no TYPE i. DATA: lv_index TYPE char2. DATA: lv_col1 TYPE i VALUE 6. DATA: lv_col2 TYPE i. DATA: lv_row TYPE i. DATA: lv_month TYPE char5. DATA: l_name LIKE wwwdatatab, l_mime LIKE w3mime OCCURS 10. DATA: ls_bukrs TYPE gty_s_bukrs. l_name-relid = ‘MI‘. l_name-objid = l_pattern. l_name-text = sy-title. DATA: ls_fieldcat TYPE lvc_s_fcat. CALL FUNCTION ‘WWWDATA_IMPORT‘ EXPORTING key = l_name TABLES mime = l_mime EXCEPTIONS wrong_object_type = 1 import_error = 2 OTHERS = 3. CALL FUNCTION ‘GUI_DOWNLOAD‘ EXPORTING filename = l_fullpath filetype = ‘BIN‘ TABLES data_tab = l_mime. IF l_fullpath IS NOT INITIAL. *创建Excel CREATE OBJECT g_excel ‘EXCEL.APPLICATION‘. CALL METHOD OF g_excel ‘Workbooks‘ = g_books. *新建或打开工作簿 SET PROPERTY OF g_excel ‘Visible‘ = 0."1/0 是否显示EXCEL CALL METHOD OF g_books ‘Open‘ = g_book EXPORTING #1 = l_fullpath. ENDIF. CALL METHOD OF g_excel ‘Sheets‘ = g_sheet EXPORTING #1 = 1. CALL METHOD OF g_sheet ‘Select‘ . CALL METHOD OF g_sheet ‘Activate‘. "sheet 激活 SET PROPERTY OF g_sheet ‘NAME‘ = ‘责任成本汇总表‘. "设定sheet名称 *标题 CLEAR lv_title. lv_title = ‘责任成本汇总表‘. PERFORM frm_fill_cell USING 1 1 lv_title. lv_col2 = lines( gt_bukrs ) * 3 + 6. PERFORM frm_merge_cell USING 1 1 1 lv_col2. *表头 LOOP AT gt_bukrs INTO ls_bukrs. lv_col1 = lv_col1 + 1. PERFORM frm_fill_cell USING 2 lv_col1 ls_bukrs-butxt. lv_col2 = lv_col1 + 2. PERFORM frm_merge_cell USING 2 lv_col1 2 lv_col2. lv_col1 = lv_col2. ENDLOOP. CLEAR:lv_col1,lv_col2. lv_col1 = 6. LOOP AT gt_bukrs INTO ls_bukrs. lv_col1 = lv_col1 + 1. PERFORM frm_fill_cell USING 3 lv_col1 ‘本月数‘. lv_col1 = lv_col1 + 1. PERFORM frm_fill_cell USING 3 lv_col1 ‘本年累计数‘. lv_col1 = lv_col1 + 1. PERFORM frm_fill_cell USING 3 lv_col1 ‘比例‘. ENDLOOP. lv_row = 4. LOOP AT <dyn_table> ASSIGNING <dyn_wa>. CLEAR lv_col1. lv_col1 = 4. LOOP AT gt_fieldcat INTO ls_fieldcat. ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <dyn_wa> TO <dyn_field>. PERFORM frm_fill_cell USING lv_row lv_col1 <dyn_field>. lv_col1 = lv_col1 + 1. ENDLOOP. lv_row = lv_row + 1. ENDLOOP. "保存excel数据 PERFORM frm_save_excel. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_FILL_CELL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_I text * -->PV_J text * -->PV_VALUE text *----------------------------------------------------------------------* FORM frm_fill_cell USING pv_i pv_j pv_value. CALL METHOD OF g_excel ‘Cells‘ = g_cells EXPORTING #1 = pv_i #2 = pv_j. SET PROPERTY OF g_cells ‘Value‘ = pv_value . ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_MERGE_CELL *&---------------------------------------------------------------------* * 合并excel单元格 *----------------------------------------------------------------------* * -->PV_X1 text * -->PV_Y1 text * -->PV_X2 text * -->PV_Y2 text *----------------------------------------------------------------------* FORM frm_merge_cell USING pv_x1 pv_y1 pv_x2 pv_y2. *--Selecting cell area to be merged. CALL METHOD OF g_excel ‘Cells‘ = g_cells1 EXPORTING #1 = pv_x1 #2 = pv_y1. CALL METHOD OF g_excel ‘Cells‘ = g_cells2 EXPORTING #1 = pv_x2 #2 = pv_y2. CALL METHOD OF g_excel ‘Range‘ = g_cells EXPORTING #1 = g_cells1 #2 = g_cells2. CALL METHOD OF g_cells ‘Select‘. *--Merging CALL METHOD OF g_cells ‘Merge‘ . ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_SAVE_EXCEL *&---------------------------------------------------------------------* * 保存excel数据 *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_save_excel . CALL METHOD OF g_bookSAVE. CALL METHOD OF g_bookCLOSE. CALL METHOD OF g_excelQUIT. FREE OBJECT g_sheet. FREE OBJECT g_book. FREE OBJECT g_excel. ENDFORM.

责任成本汇总表

标签:percent   业务   inpu   cos   not   min   symbols   www   interval   

原文地址:http://www.cnblogs.com/llguanli/p/7284480.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!