SAP ABAP OO ALV TREE(项目 WBS展开)

该程序是初版,有一些BUG请见谅

 主程序

*&---------------------------------------------------------------------*
*& Report ZTYFIR00940
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztyfir00950.

INCLUDE ZTYFIR00950_TOP.
INCLUDE ZTYFIR00950_PBO .
INCLUDE ZTYFIR00950_PAI .
INCLUDE ZTYFIR00950_FRM.

AT SELECTION-SCREEN.
  PERFORM frm_authority_check.

START-OF-SELECTION.

  CALL SCREEN 0100.
View Code

TOP

  1 *&---------------------------------------------------------------------*
  2 *&  包含                ZTYFIR00950_TOP
  3 *&---------------------------------------------------------------------*
  4 TABLES:proj,prps.
  5 
  6 TYPES:BEGIN OF ty_data,
  7       posid TYPE prps-posid,"项目/WBS
  8       post1 TYPE prps-post1,"项目/WBS名称
  9       stufe TYPE prps-stufe,"层级
 10       prart TYPE prps-prart,"项目类型
 11       pratx TYPE tcj1t-pratx,"项目类型描述
 12       rtcur TYPE char3,"币种 默认RMB
 13       objnr TYPE prps-objnr,"对象编号
 14       pspnr TYPE proj-pspnr,"项目内码
 15       pspnr1 TYPE prps-pspnr,"WBS内码
 16       ys_sum TYPE bpge-wlges,"总体-预算金额
 17       cb_sum TYPE bpge-wlges,"总体-成本金额
 18       jz_sum TYPE bpge-wlges,"总体-结转金额
 19       fp_sum TYPE bpge-wlges,"总体-发票金额
 20       fk_sum TYPE bpge-wlges,"总体-付款金额
 21       zz_sum TYPE bpge-wlges,"总体-转资金额
 22       ys_yy TYPE bpge-wlges, "2023-预算金额
 23       cb_yy TYPE bpge-wlges,"2023-成本金额
 24       jz_yy TYPE bpge-wlges,"2023-结转金额
 25       fp_yy TYPE bpge-wlges,"2023-发票金额
 26       fk_yy TYPE bpge-wlges,"2023-付款金额
 27       zz_yy TYPE bpge-wlges,"2023-转资金额
 28       cb_mm TYPE bpge-wlges,"5月-成本金额
 29       jz_mm TYPE bpge-wlges,"5月-结转金额
 30       fp_mm TYPE bpge-wlges,"5月-发票金额
 31       fk_mm TYPE bpge-wlges,"5月-付款金额
 32       zz_mm TYPE bpge-wlges,"5月-转资金额
 33       END OF ty_data,
 34 
 35       BEGIN OF ty_prps,
 36       pspnr TYPE prps-pspnr,
 37       post1 TYPE prps-post1,
 38       prart TYPE prps-prart,
 39       objnr TYPE prps-objnr,
 40       END OF ty_prps.
 41 
 42 DATA:lt_data TYPE TABLE OF ty_data,
 43      ls_data TYPE ty_data,
 44      lt_prps TYPE TABLE OF ty_prps,
 45      ls_prps TYPE ty_prps.
 46 DATA:BEGIN OF ls_bpge,
 47      objnr TYPE bpge-objnr,
 48      wlges TYPE bpge-wlges,
 49      END OF ls_bpge,
 50      lt_bpge LIKE STANDARD TABLE OF ls_bpge.
 51 
 52 DATA ok_code TYPE sy-ucomm.
 53 DATA tree1  TYPE REF TO cl_gui_alv_tree.
 54 DATA: gt_data      TYPE TABLE OF ty_data,"sflight OCCURS 0,      "Output-Table
 55       gt_sflight      TYPE sflight OCCURS 0,
 56       gt_fieldcatalog TYPE lvc_t_fcat. "Fieldcatalog
 57 
 58 *&SPWIZARD: FUNCTION CODES FOR TABSTRIP 'TAB_SHEET'
 59 CONSTANTS: BEGIN OF C_TAB_SHEET,
 60              TAB1 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC2',
 61              TAB2 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC3',
 62              TAB3 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC4',
 63              TAB4 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC5',
 64              TAB5 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC6',
 65              TAB6 LIKE SY-UCOMM VALUE 'TAB_SHEET_FC7',
 66            END OF C_TAB_SHEET.
 67 *&SPWIZARD: DATA FOR TABSTRIP 'TAB_SHEET'
 68 CONTROLS:  TAB_SHEET TYPE TABSTRIP.
 69 DATA:      BEGIN OF G_TAB_SHEET,
 70              SUBSCREEN   LIKE SY-DYNNR,
 71              PROG        LIKE SY-REPID VALUE 'ZTYFIR00950',
 72              PRESSED_TAB LIKE SY-UCOMM VALUE C_TAB_SHEET-TAB1,
 73            END OF G_TAB_SHEET.
 74 
 75 DATA gf_initialized           TYPE abap_bool VALUE abap_false.
 76 DATA gf_navigator_initialized TYPE abap_bool VALUE abap_false.
 77 
 78 DATA:cont_docking       TYPE REF TO cl_gui_docking_container,
 79      ctrl_toolbar       TYPE REF TO cl_gui_toolbar,
 80      ctrl_splitter      TYPE REF TO cl_gui_splitter_container,
 81 
 82      go_docking         TYPE REF TO cl_gui_docking_container,
 83      go_splitter1       TYPE REF TO cl_gui_splitter_container,
 84      go_sp_container1   TYPE REF TO cl_gui_container,      "screen1  的容器
 85      go_sp_container2   TYPE REF TO cl_gui_container,      "screen2  的容器
 86      go_alv_grid1       TYPE REF TO cl_gui_alv_grid,       "alv1
 87 
 88      cont_toolbar       TYPE REF TO cl_gui_container,
 89      ctrl_tree          TYPE REF TO cl_gui_column_tree,
 90      cont_tree          TYPE REF TO cl_gui_container,
 91      cont_tree_agenda   TYPE REF TO cl_gui_container,
 92      worklist_container TYPE REF TO cl_gui_container,
 93      g_hierarchy_header TYPE treev_hhdr.
 94 
 95 *----------------------------------------------------------------------*
 96 *       CLASS lcl_nav_event_receiver DEFINITION
 97 *----------------------------------------------------------------------*
 98 *
 99 *----------------------------------------------------------------------*
100 CLASS lcl_tree_event_receiver DEFINITION.
101   PUBLIC SECTION.
102     METHODS:
103       handle_double_click
104         for event node_double_click of cl_gui_alv_tree
105         importing node_key,
106       handle_item_double_click
107       FOR EVENT item_double_click OF cl_gui_alv_tree
108         IMPORTING fieldname node_key.
109 
110 ENDCLASS.                    "lcl_nav_event_receiver DEFINITION
111 *----------------------------------------------------------------------*
112 *       CLASS lcl_nav_event_receiver IMPLEMENTATION
113 *----------------------------------------------------------------------*
114 *
115 *----------------------------------------------------------------------*
116 CLASS lcl_tree_event_receiver IMPLEMENTATION.
117   METHOD handle_double_click.
118     PERFORM tree_node_double_click USING node_key.
119   ENDMETHOD.                    "link_click
120   METHOD handle_item_double_click.
121     DATA: l_value TYPE lvc_value,
122           l_layi  TYPE lvc_t_layi,
123           l_layn  TYPE lvc_s_layn .
124 
125     CALL METHOD tree1->get_outtab_line
126       EXPORTING
127         i_node_key     = node_key
128       IMPORTING
129         e_outtab_line  = ls_data
130         e_node_text    = l_value
131         et_item_layout = l_layi
132         es_node_layout = l_layn
133       EXCEPTIONS
134         node_not_found = 1
135         OTHERS         = 2.
136     IF sy-subrc = 0.
137       SET PARAMETER ID 'PRO' FIELD ls_data-posid.
138       CALL TRANSACTION 'CJ03' AND SKIP FIRST SCREEN.
139     ENDIF.
140 
141   ENDMETHOD.
142 ENDCLASS.                    "lcl_nav_event_receiver IMPLEMENTATION
143 
144 
145 SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
146 PARAMETERS:p_bukrs     TYPE bkpf-bukrs OBLIGATORY.
147 PARAMETERS:p_gjahr     TYPE bkpf-gjahr OBLIGATORY DEFAULT sy-datum+0(4).
148 PARAMETERS:p_monat     TYPE bkpf-monat OBLIGATORY DEFAULT sy-datum+4(2).
149 SELECT-OPTIONS:s_prart FOR prps-prart.
150 SELECT-OPTIONS:s_pspid FOR proj-pspid.
151 SELECT-OPTIONS:s_posid FOR prps-posid.
152 SELECTION-SCREEN END OF BLOCK b1.
View Code

PBO

 1 *&---------------------------------------------------------------------*
 2 *&  Include  ZTYFIR00950_PBO
 3 *&---------------------------------------------------------------------*
 4 
 5 *&SPWIZARD: OUTPUT MODULE FOR TS 'TAB_SHEET'. DO NOT CHANGE THIS LINE!
 6 *&SPWIZARD: SETS ACTIVE TAB
 7 MODULE TAB_SHEET_ACTIVE_TAB_SET OUTPUT.
 8   TAB_SHEET-ACTIVETAB = G_TAB_SHEET-PRESSED_TAB.
 9   CASE G_TAB_SHEET-PRESSED_TAB.
10     WHEN C_TAB_SHEET-TAB1.
11       G_TAB_SHEET-SUBSCREEN = '0102'.
12     WHEN C_TAB_SHEET-TAB2.
13       G_TAB_SHEET-SUBSCREEN = '0103'.
14     WHEN C_TAB_SHEET-TAB3.
15       G_TAB_SHEET-SUBSCREEN = '0104'.
16     WHEN C_TAB_SHEET-TAB4.
17       G_TAB_SHEET-SUBSCREEN = '0105'.
18     WHEN C_TAB_SHEET-TAB5.
19       G_TAB_SHEET-SUBSCREEN = '0106'.
20     WHEN C_TAB_SHEET-TAB6.
21       G_TAB_SHEET-SUBSCREEN = '0107'.
22     WHEN OTHERS.
23 *&SPWIZARD:      DO NOTHING
24   ENDCASE.
25 ENDMODULE.
26 
27 *&---------------------------------------------------------------------*
28 *&      Module  STATUS_0100  OUTPUT
29 *&---------------------------------------------------------------------*
30 *       text
31 *----------------------------------------------------------------------*
32 MODULE status_0100 OUTPUT.
33 *工具栏
34   PERFORM status_0100.
35 
36 *屏幕拆分
37   PERFORM init_docking.
38 
39 *初始化 ALV
40 *  PERFORM initial_alv.
41 
42 ENDMODULE.
View Code

PAI

*&---------------------------------------------------------------------*
*&  Include  ZTYFIR00950_PAI
*&---------------------------------------------------------------------*

*&SPWIZARD: INPUT MODULE FOR TS 'TAB_SHEET'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GETS ACTIVE TAB
MODULE TAB_SHEET_ACTIVE_TAB_GET INPUT.
  OK_CODE = SY-UCOMM.
  CASE OK_CODE.
    WHEN C_TAB_SHEET-TAB1.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB1.
    WHEN C_TAB_SHEET-TAB2.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB2.
    WHEN C_TAB_SHEET-TAB3.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB3.
    WHEN C_TAB_SHEET-TAB4.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB4.
    WHEN C_TAB_SHEET-TAB5.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB5.
    WHEN C_TAB_SHEET-TAB6.
      G_TAB_SHEET-PRESSED_TAB = C_TAB_SHEET-TAB6.
    WHEN OTHERS.
*&SPWIZARD:      DO NOTHING
  ENDCASE.
ENDMODULE.

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  PERFORM user_command_0100.
ENDMODULE.
View Code

FRM  

   1 *&---------------------------------------------------------------------*
   2 *&  包含                ZTYFIR00950_FRM
   3 *&---------------------------------------------------------------------*
   4 *&---------------------------------------------------------------------*
   5 *&      Form  TREE_NODE_LINK_CLICK
   6 *&---------------------------------------------------------------------*
   7 *       text
   8 *----------------------------------------------------------------------*
   9 *      -->P_NODE_KEY  text
  10 *----------------------------------------------------------------------*
  11 FORM tree_node_double_click  USING    p_node_key.
  12   DATA:lv_tab_sheet TYPE char20.
  13   CHECK NOT p_node_key IS INITIAL.
  14   lv_tab_sheet = tab_sheet.
  15   CASE lv_tab_sheet.
  16     WHEN 'TAB_SHEET_FC2'."预算
  17       gv_sheet = 2.
  18       PERFORM frm_ys_sheet USING p_node_key.
  19     WHEN 'TAB_SHEET_FC3'."成本
  20       gv_sheet = 3.
  21       PERFORM frm_cb_sheet USING p_node_key.
  22     WHEN 'TAB_SHEET_FC4'."结转
  23       gv_sheet = 4.
  24       PERFORM frm_jz_sheet USING p_node_key.
  25     WHEN 'TAB_SHEET_FC5'."发票
  26       gv_sheet = 5.
  27       PERFORM frm_fp_sheet USING p_node_key.
  28     WHEN 'TAB_SHEET_FC6'."付款
  29       gv_sheet = 6.
  30       PERFORM frm_fk_sheet USING p_node_key.
  31 
  32     WHEN 'TAB_SHEET_FC7'."转资
  33       gv_sheet = 7.
  34       PERFORM frm_zz_sheet USING p_node_key.
  35   ENDCASE.
  36 
  37   PERFORM frm_refresh_alv USING gv_sheet.
  38 
  39 
  40 ENDFORM.
  41 
  42 *&---------------------------------------------------------------------*
  43 *&      Form  STATUS_0100
  44 *&---------------------------------------------------------------------*
  45 *       text
  46 *----------------------------------------------------------------------*
  47 FORM status_0100.
  48   SET PF-STATUS '0100'.
  49   SET TITLEBAR '0100' WITH '项目执行情况表'.
  50 ENDFORM.
  51 *&---------------------------------------------------------------------*
  52 *&      Form  USER_COMMAND_0100
  53 *&---------------------------------------------------------------------*
  54 *       text
  55 *----------------------------------------------------------------------*
  56 FORM user_command_0100.
  57   DATA lv_code TYPE sy-ucomm.
  58   CLEAR:lv_code.
  59   lv_code = ok_code.
  60 
  61   CLEAR:ok_code.
  62   CASE lv_code.
  63     WHEN 'BACK'.
  64       PERFORM call_back.
  65     WHEN 'EXIT'.
  66       PERFORM call_exit.
  67     WHEN 'CANLE'.
  68       PERFORM call_canle.
  69     WHEN OTHERS.
  70   ENDCASE.
  71 
  72 ENDFORM.
  73 *&---------------------------------------------------------------------*
  74 *&      Form  CALL_BACK
  75 *&---------------------------------------------------------------------*
  76 *       text
  77 *----------------------------------------------------------------------*
  78 FORM call_back.
  79   LEAVE TO SCREEN 0.
  80 ENDFORM.
  81 *&---------------------------------------------------------------------*
  82 *&      Form  CALL_EXIT
  83 *&---------------------------------------------------------------------*
  84 *       text
  85 *----------------------------------------------------------------------*
  86 FORM call_exit.
  87   LEAVE TO SCREEN 0.
  88 ENDFORM.
  89 *&---------------------------------------------------------------------*
  90 *&      Form  CALL_CANLE
  91 *&---------------------------------------------------------------------*
  92 *       text
  93 *----------------------------------------------------------------------*
  94 FORM call_canle.
  95   LEAVE TO SCREEN 0.
  96 ENDFORM.
  97 *&---------------------------------------------------------------------*
  98 *&      Form  INITIAL_ALV
  99 *&---------------------------------------------------------------------*
 100 *       text
 101 *----------------------------------------------------------------------*
 102 FORM initial_alv.
 103 
 104   DATA: l_repid            LIKE sy-repid,
 105         l_dynnr            LIKE sy-dynnr,
 106         l_hierarchy_header TYPE treev_hhdr,
 107         lt_events          TYPE cntl_simple_events,
 108         l_events           TYPE cntl_simple_event,
 109         l_extension        TYPE i VALUE 200,
 110         l_pref_value       TYPE char32.
 111 
 112   CHECK gf_navigator_initialized EQ abap_false.
 113   gf_navigator_initialized = abap_true.
 114 
 115 
 116 *  CREATE OBJECT ctrl_event_receiver.
 117 
 118   CREATE OBJECT cont_docking
 119     EXPORTING
 120       extension = l_extension.
 121 
 122   CREATE OBJECT ctrl_splitter
 123     EXPORTING
 124       parent            = cont_docking
 125       rows              = 2
 126       columns           = 1
 127     EXCEPTIONS
 128       cntl_error        = 1
 129       cntl_system_error = 2
 130       OTHERS            = 3.
 131   IF sy-subrc <> 0.
 132     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 133     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 134   ENDIF.
 135 
 136   CALL METHOD ctrl_splitter->set_row_height
 137     EXPORTING
 138       id                = 1
 139       height            = 40
 140     EXCEPTIONS
 141       cntl_error        = 1
 142       cntl_system_error = 2
 143       OTHERS            = 3.
 144   IF sy-subrc <> 0.
 145     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 146     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 147   ENDIF.
 148 
 149 *  CALL METHOD ctrl_splitter->set_row_sash
 150 *    EXPORTING
 151 *      id    = 1
 152 *      type  = cl_gui_splitter_container=>type_movable
 153 *      value = cl_gui_splitter_container=>false.
 154 *
 155 *  CALL METHOD ctrl_splitter->set_border
 156 *    EXPORTING
 157 *      border = space.
 158 *
 159 *  CALL METHOD ctrl_splitter->set_row_mode
 160 *    EXPORTING
 161 *      mode = cl_gui_splitter_container=>mode_absolute.
 162 *
 163 *  CALL METHOD ctrl_splitter->get_container
 164 *    EXPORTING
 165 *      row       = 2
 166 *      column    = 1
 167 *    RECEIVING
 168 *      container = cont_tree.
 169 
 170 ENDFORM.
 171 *&---------------------------------------------------------------------*
 172 *&      Form  INIT_DOCKING
 173 *&---------------------------------------------------------------------*
 174 *       text
 175 *----------------------------------------------------------------------*
 176 FORM init_docking.
 177 
 178   DATA: l_repid            LIKE sy-repid,
 179         l_dynnr            LIKE sy-dynnr,
 180         l_hierarchy_header TYPE treev_hhdr,
 181         lt_events          TYPE cntl_simple_events,
 182         l_events           TYPE cntl_simple_event,
 183         l_extension        TYPE i VALUE 200,
 184         l_pref_value       TYPE char32.
 185 
 186   CHECK gf_navigator_initialized EQ abap_false.
 187   gf_navigator_initialized = abap_true.
 188 
 189 **创建docking
 190   CREATE OBJECT go_docking
 191     EXPORTING
 192       repid     = sy-repid
 193       dynnr     = sy-dynnr
 194       extension = '150'         "屏幕大小
 195       side      = cl_gui_docking_container=>dock_at_top.
 196 
 197 *将屏幕拆分成上下两个屏幕:两行一列
 198   CREATE OBJECT go_splitter1
 199     EXPORTING
 200       parent  = go_docking
 201       rows    = 1  "2
 202       columns = 1.
 203 
 204 *第一个屏幕放在第一行第一列
 205   CALL METHOD go_splitter1->get_container
 206     EXPORTING
 207       row       = 1
 208       column    = 1
 209     RECEIVING
 210       container = go_sp_container1.
 211 
 212 *第一个屏幕高度
 213   CALL METHOD go_splitter1->set_row_height
 214     EXPORTING
 215       id     = 1
 216       height = 50.
 217 
 218 **第二个屏幕 放在第二行第一列
 219 *  CALL METHOD go_splitter1->get_container
 220 *    EXPORTING
 221 *      row       = 2
 222 *      column    = 1
 223 *    RECEIVING
 224 *      container = go_sp_container2.
 225 
 226 **--容器1
 227 *  CREATE OBJECT go_alv_grid1
 228 *    EXPORTING
 229 *      i_parent          = go_sp_container1
 230 *    EXCEPTIONS
 231 *      error_cntl_create = 1
 232 *      error_cntl_init   = 2
 233 *      error_cntl_link   = 3
 234 *      error_dp_create   = 4
 235 *      OTHERS            = 5.
 236 *  IF sy-subrc <> 0.
 237 *    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
 238 *    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
 239 *  ENDIF.
 240 ****************************************
 241   IF tree1 IS INITIAL.
 242     PERFORM init_tree.
 243   ENDIF.
 244 
 245 ENDFORM.
 246 *&---------------------------------------------------------------------*
 247 *&      Form  INIT_TREE
 248 *&---------------------------------------------------------------------*
 249 *       text
 250 *----------------------------------------------------------------------*
 251 FORM init_tree .
 252 
 253 * create fieldcatalog for structure sflight
 254   PERFORM build_fieldcatalog.
 255 
 256 * create container for alv-tree
 257   DATA: l_tree_container_name(30) TYPE c,
 258         l_custom_container        TYPE REF TO cl_gui_custom_container.
 259   l_tree_container_name = 'TREE1'.
 260 
 261 *  IF sy-batch IS INITIAL.
 262 *    CREATE OBJECT l_custom_container
 263 *      EXPORTING
 264 *        container_name              = l_tree_container_name
 265 *      EXCEPTIONS
 266 *        cntl_error                  = 1
 267 *        cntl_system_error           = 2
 268 *        create_error                = 3
 269 *        lifetime_error              = 4
 270 *        lifetime_dynpro_dynpro_link = 5.
 271 *    IF sy-subrc <> 0.
 272 *      MESSAGE x208(00) WITH 'ERROR'.                        "#EC NOTEXT
 273 *    ENDIF.
 274 *  ENDIF.
 275 
 276 * create tree control
 277   CREATE OBJECT tree1
 278     EXPORTING
 279       parent                      = go_sp_container1 "l_custom_container
 280       node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
 281       item_selection              = abap_true    "YI3K118558
 282       no_html_header              = 'X'
 283       no_toolbar                  = ''
 284     EXCEPTIONS
 285       cntl_error                  = 1
 286       cntl_system_error           = 2
 287       create_error                = 3
 288       lifetime_error              = 4
 289       illegal_node_selection_mode = 5
 290       failed                      = 6
 291       illegal_column_name         = 7.
 292   IF sy-subrc <> 0.
 293     MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
 294   ENDIF.
 295 
 296   DATA: lt_list_commentary TYPE slis_t_listheader,
 297         l_logo             TYPE sdydo_value.
 298 
 299 
 300 * repid for saving variants
 301   DATA: ls_variant TYPE disvariant.
 302   ls_variant-report = sy-repid.
 303 
 304   PERFORM build_hierarchy_header.
 305 * create emty tree-control
 306   CALL METHOD tree1->set_table_for_first_display
 307     EXPORTING
 308       is_hierarchy_header = g_hierarchy_header
 309       it_list_commentary  = lt_list_commentary
 310       i_logo              = l_logo
 311       i_background_id     = 'ALV_BACKGROUND'
 312       i_save              = 'A'
 313       is_variant          = ls_variant
 314     CHANGING
 315       it_outtab           = gt_data "table must be emty !!
 316       it_fieldcatalog     = gt_fieldcatalog.
 317 
 318 * create hierarchy
 319   PERFORM create_hierarchy.
 320 
 321 * add own functioncodes to the toolbar
 322 *  PERFORM change_toolbar.
 323 
 324 * register events
 325   PERFORM register_events.                                  "YI3K118558
 326 * adjust column_width
 327 * call method tree1->COLUMN_OPTIMIZE.
 328   CALL METHOD tree1->frontend_update.
 329 ENDFORM.
 330 *&---------------------------------------------------------------------*
 331 *&      Form  BUILD_FIELDCATALOG
 332 *&---------------------------------------------------------------------*
 333 *       text
 334 *----------------------------------------------------------------------*
 335 *  -->  p1        text
 336 *  <--  p2        text
 337 *----------------------------------------------------------------------*
 338 FORM build_fieldcatalog .
 339   DATA: ls_fieldcatalog TYPE lvc_s_fcat.
 340   REFRESH gt_fieldcatalog.
 341 
 342 *  CLEAR ls_fieldcatalog.
 343 *  ls_fieldcatalog-fieldname = 'POSID'.
 344 *  ls_fieldcatalog-coltext = '项目/WBS元素'.
 345 *  ls_fieldcatalog-key = ''.
 346 *  ls_fieldcatalog-dd_outlen = '30'.
 347 *  ls_fieldcatalog-outputlen = '30'.
 348 *  APPEND ls_fieldcatalog TO gt_fieldcatalog .
 349 
 350   CLEAR ls_fieldcatalog.
 351   ls_fieldcatalog-fieldname = 'POST1'.
 352   ls_fieldcatalog-coltext = '项目/WBS名称'.
 353   ls_fieldcatalog-key = ''.
 354   ls_fieldcatalog-dd_outlen = '30'.
 355   ls_fieldcatalog-outputlen = '30'.
 356   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 357 
 358   CLEAR ls_fieldcatalog.
 359   ls_fieldcatalog-fieldname = 'PRART'.
 360   ls_fieldcatalog-coltext = '项目类型'.
 361   ls_fieldcatalog-key = ''.
 362   ls_fieldcatalog-dd_outlen = '4'.
 363   ls_fieldcatalog-outputlen = '8'.
 364   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 365 
 366   CLEAR ls_fieldcatalog.
 367   ls_fieldcatalog-fieldname = 'PRATX'.
 368   ls_fieldcatalog-coltext = '项目类型描述'.
 369   ls_fieldcatalog-key = ''.
 370   ls_fieldcatalog-dd_outlen = '10'.
 371   ls_fieldcatalog-outputlen = '20'.
 372   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 373 
 374   CLEAR ls_fieldcatalog.
 375   ls_fieldcatalog-fieldname = 'RTCUR'.
 376   ls_fieldcatalog-coltext = '币种'.
 377   ls_fieldcatalog-key = ''.
 378   ls_fieldcatalog-dd_outlen = '4'.
 379   ls_fieldcatalog-outputlen = '8'.
 380   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 381 
 382   CLEAR ls_fieldcatalog.
 383   ls_fieldcatalog-fieldname = 'YS_SUM'.
 384   ls_fieldcatalog-coltext = '总体预算金额'.
 385   ls_fieldcatalog-key = ''.
 386   ls_fieldcatalog-dd_outlen = '20'.
 387   ls_fieldcatalog-outputlen = '20'.
 388   ls_fieldcatalog-just = 'R'.
 389   ls_fieldcatalog-ref_field = 'DMBTR'.
 390   ls_fieldcatalog-ref_table = 'BSEG'.
 391   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 392 
 393   CLEAR ls_fieldcatalog.
 394   ls_fieldcatalog-fieldname = 'CB_SUM'.
 395   ls_fieldcatalog-coltext = '总体成本金额'.
 396   ls_fieldcatalog-key = ''.
 397   ls_fieldcatalog-dd_outlen = '20'.
 398   ls_fieldcatalog-outputlen = '20'.
 399   ls_fieldcatalog-just = 'R'.
 400   ls_fieldcatalog-ref_field = 'DMBTR'.
 401   ls_fieldcatalog-ref_table = 'BSEG'.
 402   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 403 
 404   CLEAR ls_fieldcatalog.
 405   ls_fieldcatalog-fieldname = 'JZ_SUM'.
 406   ls_fieldcatalog-coltext = '总体结转金额'.
 407   ls_fieldcatalog-key = ''.
 408   ls_fieldcatalog-dd_outlen = '20'.
 409   ls_fieldcatalog-outputlen = '20'.
 410   ls_fieldcatalog-just = 'R'.
 411   ls_fieldcatalog-ref_field = 'DMBTR'.
 412   ls_fieldcatalog-ref_table = 'BSEG'.
 413   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 414 
 415   CLEAR ls_fieldcatalog.
 416   ls_fieldcatalog-fieldname = 'FP_SUM'.
 417   ls_fieldcatalog-coltext = '总体发票金额'.
 418   ls_fieldcatalog-key = ''.
 419   ls_fieldcatalog-dd_outlen = '20'.
 420   ls_fieldcatalog-outputlen = '20'.
 421   ls_fieldcatalog-just = 'R'.
 422   ls_fieldcatalog-ref_field = 'DMBTR'.
 423   ls_fieldcatalog-ref_table = 'BSEG'.
 424   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 425 
 426   CLEAR ls_fieldcatalog.
 427   ls_fieldcatalog-fieldname = 'FK_SUM'.
 428   ls_fieldcatalog-coltext = '总体付款金额'.
 429   ls_fieldcatalog-key = ''.
 430   ls_fieldcatalog-dd_outlen = '20'.
 431   ls_fieldcatalog-outputlen = '20'.
 432   ls_fieldcatalog-just = 'R'.
 433   ls_fieldcatalog-ref_field = 'DMBTR'.
 434   ls_fieldcatalog-ref_table = 'BSEG'.
 435   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 436 
 437   CLEAR ls_fieldcatalog.
 438   ls_fieldcatalog-fieldname = 'ZZ_SUM'.
 439   ls_fieldcatalog-coltext = '总体转资金额'.
 440   ls_fieldcatalog-key = ''.
 441   ls_fieldcatalog-dd_outlen = '20'.
 442   ls_fieldcatalog-outputlen = '20'.
 443   ls_fieldcatalog-just = 'R'.
 444   ls_fieldcatalog-ref_field = 'DMBTR'.
 445   ls_fieldcatalog-ref_table = 'BSEG'.
 446   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 447 
 448   CLEAR ls_fieldcatalog.
 449   ls_fieldcatalog-fieldname = 'YS_YY'.
 450   ls_fieldcatalog-coltext = p_gjahr && '-预算金额'.
 451   ls_fieldcatalog-key = ''.
 452   ls_fieldcatalog-dd_outlen = '20'.
 453   ls_fieldcatalog-outputlen = '20'.
 454   ls_fieldcatalog-just = 'R'.
 455   ls_fieldcatalog-ref_field = 'DMBTR'.
 456   ls_fieldcatalog-ref_table = 'BSEG'.
 457   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 458 
 459   CLEAR ls_fieldcatalog.
 460   ls_fieldcatalog-fieldname = 'CB_YY'.
 461   ls_fieldcatalog-coltext = p_gjahr && '-成本金额'.
 462   ls_fieldcatalog-key = ''.
 463   ls_fieldcatalog-dd_outlen = '20'.
 464   ls_fieldcatalog-outputlen = '20'.
 465   ls_fieldcatalog-just = 'R'.
 466   ls_fieldcatalog-ref_field = 'DMBTR'.
 467   ls_fieldcatalog-ref_table = 'BSEG'.
 468   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 469 
 470   CLEAR ls_fieldcatalog.
 471   ls_fieldcatalog-fieldname = 'JZ_YY'.
 472   ls_fieldcatalog-coltext = p_gjahr && '-结转金额'.
 473   ls_fieldcatalog-key = ''.
 474   ls_fieldcatalog-dd_outlen = '20'.
 475   ls_fieldcatalog-outputlen = '20'.
 476   ls_fieldcatalog-just = 'R'.
 477   ls_fieldcatalog-ref_field = 'DMBTR'.
 478   ls_fieldcatalog-ref_table = 'BSEG'.
 479   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 480 
 481   CLEAR ls_fieldcatalog.
 482   ls_fieldcatalog-fieldname = 'FP_YY'.
 483   ls_fieldcatalog-coltext = p_gjahr && '-发票金额'.
 484   ls_fieldcatalog-key = ''.
 485   ls_fieldcatalog-dd_outlen = '20'.
 486   ls_fieldcatalog-outputlen = '20'.
 487   ls_fieldcatalog-just = 'R'.
 488   ls_fieldcatalog-ref_field = 'DMBTR'.
 489   ls_fieldcatalog-ref_table = 'BSEG'.
 490   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 491 
 492   CLEAR ls_fieldcatalog.
 493   ls_fieldcatalog-fieldname = 'FK_YY'.
 494   ls_fieldcatalog-coltext = p_gjahr && '-付款金额'.
 495   ls_fieldcatalog-key = ''.
 496   ls_fieldcatalog-dd_outlen = '20'.
 497   ls_fieldcatalog-outputlen = '20'.
 498   ls_fieldcatalog-just = 'R'.
 499   ls_fieldcatalog-ref_field = 'DMBTR'.
 500   ls_fieldcatalog-ref_table = 'BSEG'.
 501   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 502 
 503   CLEAR ls_fieldcatalog.
 504   ls_fieldcatalog-fieldname = 'ZZ_YY'.
 505   ls_fieldcatalog-coltext = p_gjahr && '-转资金额'.
 506   ls_fieldcatalog-key = ''.
 507   ls_fieldcatalog-dd_outlen = '20'.
 508   ls_fieldcatalog-outputlen = '20'.
 509   ls_fieldcatalog-just = 'R'.
 510   ls_fieldcatalog-ref_field = 'DMBTR'.
 511   ls_fieldcatalog-ref_table = 'BSEG'.
 512   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 513 
 514   CLEAR ls_fieldcatalog.
 515   ls_fieldcatalog-fieldname = 'CB_MM'.
 516   ls_fieldcatalog-coltext = p_monat && '月-成本金额'.
 517   ls_fieldcatalog-key = ''.
 518   ls_fieldcatalog-dd_outlen = '20'.
 519   ls_fieldcatalog-outputlen = '20'.
 520   ls_fieldcatalog-just = 'R'.
 521   ls_fieldcatalog-ref_field = 'DMBTR'.
 522   ls_fieldcatalog-ref_table = 'BSEG'.
 523   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 524 
 525   CLEAR ls_fieldcatalog.
 526   ls_fieldcatalog-fieldname = 'JZ_MM'.
 527   ls_fieldcatalog-coltext = p_monat && '月-结转金额'.
 528   ls_fieldcatalog-key = ''.
 529   ls_fieldcatalog-dd_outlen = '20'.
 530   ls_fieldcatalog-outputlen = '20'.
 531   ls_fieldcatalog-just = 'R'.
 532   ls_fieldcatalog-ref_field = 'DMBTR'.
 533   ls_fieldcatalog-ref_table = 'BSEG'.
 534   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 535 
 536   CLEAR ls_fieldcatalog.
 537   ls_fieldcatalog-fieldname = 'FP_MM'.
 538   ls_fieldcatalog-coltext = p_monat && '月-发票金额'.
 539   ls_fieldcatalog-key = ''.
 540   ls_fieldcatalog-dd_outlen = '20'.
 541   ls_fieldcatalog-outputlen = '20'.
 542   ls_fieldcatalog-just = 'R'.
 543   ls_fieldcatalog-ref_field = 'DMBTR'.
 544   ls_fieldcatalog-ref_table = 'BSEG'.
 545   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 546 
 547   CLEAR ls_fieldcatalog.
 548   ls_fieldcatalog-fieldname = 'FK_MM'.
 549   ls_fieldcatalog-coltext = p_monat && '月-付款金额'.
 550   ls_fieldcatalog-key = ''.
 551   ls_fieldcatalog-dd_outlen = '20'.
 552   ls_fieldcatalog-outputlen = '20'.
 553   ls_fieldcatalog-just = 'R'.
 554   ls_fieldcatalog-ref_field = 'DMBTR'.
 555   ls_fieldcatalog-ref_table = 'BSEG'.
 556   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 557 
 558   CLEAR ls_fieldcatalog.
 559   ls_fieldcatalog-fieldname = 'ZZ_MM'.
 560   ls_fieldcatalog-coltext = p_monat && '月-转资金额'.
 561   ls_fieldcatalog-key = ''.
 562   ls_fieldcatalog-dd_outlen = '20'.
 563   ls_fieldcatalog-outputlen = '20'.
 564   ls_fieldcatalog-just = 'R'.
 565   ls_fieldcatalog-ref_field = 'DMBTR'.
 566   ls_fieldcatalog-ref_table = 'BSEG'.
 567   APPEND ls_fieldcatalog TO gt_fieldcatalog .
 568 
 569 
 570 ENDFORM.
 571 *&---------------------------------------------------------------------*
 572 *&      Form  CREATE_HIERARCHY
 573 *&---------------------------------------------------------------------*
 574 *       text
 575 *----------------------------------------------------------------------*
 576 FORM create_hierarchy .
 577   DATA: lt_nodes       TYPE TABLE OF lvc_nkey WITH HEADER LINE,
 578         l_cur_node     TYPE lvc_nkey,
 579         l_former_stufe TYPE prps-stufe,
 580         l_index        TYPE i,
 581         lv_node_key    TYPE lvc_nkey.
 582   DATA:is_node_layout    TYPE lvc_s_layn.
 583   DATA:l_node_text TYPE lvc_value.
 584 *get data
 585   PERFORM frm_get_data.
 586 
 587   SORT lt_data BY sort.
 588   LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<fs_data>).
 589     IF <fs_data>-stufe = '1'.
 590 
 591       "ALV TREE图标隐藏
 592       is_node_layout-n_image = 'BNONE'.
 593       is_node_layout-exp_image = 'BNONE'.
 594 
 595       CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
 596         EXPORTING
 597           input  = <fs_data>-posid
 598         IMPORTING
 599           output = l_node_text.
 600 
 601       CALL METHOD tree1->add_node
 602         EXPORTING
 603           i_relat_node_key = ''
 604           i_relationship   = cl_gui_column_tree=>relat_last_child
 605           is_outtab_line   = <fs_data>
 606           i_node_text      = l_node_text
 607           is_node_layout   = is_node_layout
 608         IMPORTING
 609           e_new_node_key   = lv_node_key.
 610 
 611       <fs_data>-node_key =  lv_node_key.
 612     ELSE.
 613       CLEAR lv_node_key.
 614       CONTINUE.
 615     ENDIF.
 616     LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<fs_data1>) WHERE stufe <> 1 AND pspnr = <fs_data>-pspnr.
 617       READ TABLE lt_data INTO ls_data WITH KEY pspnr1 = <fs_data1>-above.
 618       IF sy-subrc = 0.
 619         "ALV TREE图标隐藏
 620         is_node_layout-n_image = 'BNONE'.
 621         is_node_layout-exp_image = 'BNONE'.
 622 
 623         CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
 624           EXPORTING
 625             input  = <fs_data1>-posid
 626           IMPORTING
 627             output = l_node_text.
 628 
 629         CALL METHOD tree1->add_node
 630           EXPORTING
 631             i_relat_node_key = ls_data-node_key
 632             i_relationship   = cl_gui_column_tree=>relat_last_child
 633             is_outtab_line   = <fs_data1>
 634             i_node_text      = l_node_text
 635             is_node_layout   = is_node_layout
 636           IMPORTING
 637             e_new_node_key   = lv_node_key.
 638         <fs_data1>-node_key =  lv_node_key.
 639       ENDIF.
 640     ENDLOOP.
 641   ENDLOOP.
 642 
 643 * calculate totals
 644   CALL METHOD tree1->update_calculations.
 645 
 646 * this method must be called to send the data to the frontend
 647   CALL METHOD tree1->frontend_update.
 648 
 649 ENDFORM.
 650 
 651 
 652 *&---------------------------------------------------------------------*
 653 *&      Form  REGISTER_EVENTS
 654 *&---------------------------------------------------------------------*
 655 *       text
 656 *----------------------------------------------------------------------*
 657 *  -->  p1        text
 658 *  <--  p2        text
 659 *----------------------------------------------------------------------*
 660 FORM register_events .
 661   "注册前端后后端事件
 662   DATA: lt_events        TYPE cntl_simple_events,
 663         l_event          TYPE cntl_simple_event,
 664         l_event_receiver TYPE REF TO lcl_tree_event_receiver.
 665   "获取已注册的前端事件
 666   CALL METHOD tree1->get_registered_events
 667     IMPORTING
 668       events = lt_events.
 669   CLEAR l_event.
 670   l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
 671   APPEND l_event TO lt_events.
 672 
 673   CLEAR l_event.
 674   l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
 675   APPEND l_event TO lt_events.
 676 
 677   CLEAR l_event.
 678   l_event-eventid = cl_gui_column_tree=>eventid_header_click.
 679   APPEND l_event TO lt_events.
 680 
 681   CLEAR l_event.
 682   l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
 683   APPEND l_event TO lt_events.
 684 
 685   CALL METHOD tree1->set_registered_events
 686     EXPORTING
 687       events                    = lt_events
 688     EXCEPTIONS
 689       cntl_error                = 1
 690       cntl_system_error         = 2
 691       illegal_event_combination = 3.
 692   IF sy-subrc <> 0.
 693     MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
 694   ENDIF.
 695 
 696   CREATE OBJECT l_event_receiver.
 697   SET HANDLER l_event_receiver->handle_item_double_click FOR tree1.
 698 
 699 ENDFORM.
 700 *&---------------------------------------------------------------------*
 701 *&      Form  FRM_YS_DATA
 702 *&---------------------------------------------------------------------*
 703 *       text
 704 *----------------------------------------------------------------------*
 705 *  -->  p1        text
 706 *  <--  p2        text
 707 *----------------------------------------------------------------------*
 708 FORM frm_ys_sheet USING node_key.
 709   DATA: l_value  TYPE lvc_value,
 710         l_layi   TYPE lvc_t_layi,
 711         l_layn   TYPE lvc_s_layn,
 712         lv_time  TYPE sy-tabix,
 713         lv_xjys  TYPE rpsco-wlp01,
 714         lv_flg   TYPE c,
 715         lv_above TYPE prps_co-above.
 716 
 717   CALL METHOD tree1->get_outtab_line
 718     EXPORTING
 719       i_node_key     = node_key
 720     IMPORTING
 721       e_outtab_line  = ls_data
 722       e_node_text    = l_value
 723       et_item_layout = l_layi
 724       es_node_layout = l_layn
 725     EXCEPTIONS
 726       node_not_found = 1
 727       OTHERS         = 2.
 728   IF sy-subrc = 0.
 729     CLEAR:gv_text,lv_above.
 730     gv_text = ls_data-posid && ls_data-post1.
 731     lv_above = ls_data-above.
 732     lt_data_tmp = lt_data.
 733 *& 1、根据双击行所属项目首层查询BPJA 确定展示条目
 734     READ TABLE lt_data INTO ls_data_tmp WITH KEY pspnr = ls_data-pspnr stufe = 1.
 735     CHECK sy-subrc = 0.
 736     SELECT DISTINCT gjahr
 737       INTO TABLE @DATA(lt_gjahr)
 738       FROM bpja
 739       WHERE objnr = @ls_data_tmp-objnr
 740         AND wrttp = '41'.
 741     SORT lt_gjahr BY gjahr.
 742 
 743     CLEAR:ls_ys_sheet,lt_ys_sheet,gv_cnz,gv_syz,gv_yfp,gv_ky,gv_bcky,
 744           gv_gjahr,gv_sum_bcky,ls_ys_sheet_tmp,ls_ys_sheet_sum,gv_sum_bcky1.
 745 
 746     SORT lt_ys_year BY objnr gjahr.
 747     SORT lt_cb_sheet BY posid gjahr.
 748     BREAK gxsk_guoyp.
 749     LOOP AT lt_gjahr INTO DATA(ls_gjahr).
 750       CLEAR:ls_ys_sheet_tmp,ls_data_tmp,lv_flg,gv_gjahr.
 751 
 752       ls_ys_sheet-gjahr = ls_gjahr-gjahr.
 753       gv_gjahr  = ls_gjahr-gjahr.
 754 
 755       ls_ys_sheet_tmp = ls_ys_sheet.
 756       "获取不同年度 实际 承诺 剩余计划
 757       PERFORM frm_get_sheet_field_value USING ls_data CHANGING ls_ys_sheet_tmp.
 758 
 759       ls_ys_sheet = ls_ys_sheet_tmp.
 760 
 761       "已分配 = 实际 + 承诺 + 剩余计划
 762       ls_ys_sheet-yfp = ls_ys_sheet-sj + ls_ys_sheet-cnz + ls_ys_sheet-syz.
 763       "可用(统计值) = 预算 - 已分配
 764       ls_ys_sheet-ky = ls_ys_sheet-ys - ls_ys_sheet-yfp.
 765       "本层可用预算
 766       CLEAR:gv_bcky,lv_time,lv_xjys.
 767       "本层预算不为0
 768       IF ls_ys_sheet-ys IS NOT INITIAL.
 769         "本层可用预算= 可用 - (直接下级预算 - 直接下级预算不为0的已分配)
 770         PERFORM frm_get_sheet_bcky USING ls_ys_sheet_tmp ls_data CHANGING gv_bcky.
 771         ls_ys_sheet-bcky = ls_ys_sheet-ky - gv_bcky.
 772       ELSE.
 773         "本层预算为0 找父节点 直到找到
 774         "若为首层 没有父节点 则本层预算直接为0
 775         IF ls_data-stufe = 1.
 776           gv_bcky = 0.
 777           ls_ys_sheet-bcky = ls_ys_sheet-ky - gv_bcky.
 778         ELSE.
 779           CLEAR lv_time.
 780           DO .
 781             lv_time = lv_time + 1.
 782             IF lv_time > 10.
 783               EXIT.
 784             ENDIF.
 785             IF gv_bcky <> 0.
 786               EXIT.
 787             ENDIF.
 788 
 789             READ TABLE lt_data_tmp INTO ls_data_tmp WITH KEY pspnr1 = lv_above."读取成功则ls_data_tmp变为上层WBS结构
 790             IF sy-subrc = 0.
 791               "找上层
 792               PERFORM frm_get_ys_sheet_up USING ls_data_tmp.
 793 *              PERFORM frm_get_sheet_bcky USING ls_ys_sheet_tmp ls_data_tmp CHANGING gv_bcky.
 794             ENDIF.
 795             IF ls_data_tmp-stufe = '1'.
 796               EXIT.
 797             ENDIF.
 798             lv_above = ls_data_tmp-above."赋值后继续寻找ls_data_tmp的上一层
 799           ENDDO.
 800           ls_ys_sheet-bcky = ls_ys_sheet_tmp-bcky.
 801         ENDIF.
 802       ENDIF.
 803 
 804 
 805 
 806 
 807       "汇总行相关字段
 808       gv_cnz = gv_cnz + ls_ys_sheet-cnz.
 809       gv_syz = gv_syz + ls_ys_sheet-syz.
 810       gv_yfp = gv_yfp + ls_ys_sheet-yfp.
 811       gv_ky  = gv_ky  + ls_ys_sheet-ky.
 812 
 813       APPEND ls_ys_sheet TO lt_ys_sheet.
 814       CLEAR:ls_ys_sheet,ls_ys_sheet_tmp,ls_data_tmp.
 815 
 816     ENDLOOP.
 817 
 818 
 819     "最后一行
 820     ls_ys_sheet-gjahr = '全部'.
 821     ls_ys_sheet-ys = ls_data-ys_sum.
 822     ls_ys_sheet-sj = ls_data-cb_sum.
 823     ls_ys_sheet-cnz = gv_cnz."承诺值
 824     ls_ys_sheet-syz = gv_syz."剩余计划值
 825     ls_ys_sheet-yfp = ls_ys_sheet-sj + ls_ys_sheet-cnz + ls_ys_sheet-syz."已分配 = 实际 + 承诺 + 剩余计划
 826     ls_ys_sheet-ky = ls_ys_sheet-ys - ls_ys_sheet-yfp."gv_ky."可用 = 预算 - 已分配
 827     CLEAR:gv_bcky.
 828     "本层可用
 829     CLEAR:gv_gjahr,gv_bcky,gv_sum_bcky1.
 830 
 831     IF ls_ys_sheet-ys IS NOT INITIAL.
 832       CLEAR ls_data_tmp.
 833       gv_gjahr  = ls_gjahr-gjahr.
 834       PERFORM frm_get_sheet_bcky_sum USING ls_ys_sheet ls_data CHANGING gv_bcky.
 835       ls_ys_sheet-bcky = ls_ys_sheet-ky - gv_bcky.
 836       CLEAR ls_data_tmp.
 837     ELSE.
 838       CLEAR:lv_time,lv_above,ls_data_tmp,gv_sum_bcky.
 839       lv_above = ls_data-above.
 840       DO .
 841         lv_time = lv_time + 1.
 842         IF lv_time > 10.
 843           EXIT.
 844         ENDIF.
 845         IF gv_sum_bcky IS NOT INITIAL.
 846           EXIT.
 847         ENDIF.
 848 *        LOOP AT lt_gjahr INTO ls_gjahr.
 849         "找上层WBS对应的全部汇总行  即类似重新调用该sheet页签逻辑
 850         READ TABLE lt_data_tmp INTO ls_data_sum WITH KEY pspnr1 = lv_above."读取成功则ls_data_tmp变为上层WBS结构
 851         IF sy-subrc = 0.
 852 *          PERFORM frm_ys_sheet USING
 853           PERFORM frm_get_sum_sheet."gv_sum_bcky计算
 854         ENDIF.
 855         lv_above = ls_data_sum-above.
 856         gv_sum_bcky1 = gv_sum_bcky1 + gv_sum_bcky.
 857 
 858 *        ENDLOOP.
 859         "查到首层截止
 860         IF ls_data_sum-stufe = '1'.
 861           EXIT.
 862         ENDIF.
 863       ENDDO.
 864       ls_ys_sheet-bcky =  gv_sum_bcky1.
 865     ENDIF.
 866 
 867     APPEND ls_ys_sheet TO lt_ys_sheet.
 868     SORT lt_ys_sheet BY gjahr.
 869   ENDIF.
 870 ENDFORM.
 871 *&---------------------------------------------------------------------*
 872 *&      Form  FRM_AUTHORITY_CHECK
 873 *&---------------------------------------------------------------------*
 874 *       text
 875 *----------------------------------------------------------------------*
 876 *  -->  p1        text
 877 *  <--  p2        text
 878 *----------------------------------------------------------------------*
 879 FORM frm_authority_check .
 880   AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
 881                       ID 'BUKRS' FIELD p_bukrs.
 882   IF sy-subrc NE 0.
 883     DATA(lv_mess) = '您没有公司代码' && p_bukrs && '的查询权限' .
 884     MESSAGE lv_mess TYPE 'E'.
 885     RETURN.
 886   ENDIF.
 887 ENDFORM.
 888 *&---------------------------------------------------------------------*
 889 *&      Form  BUILD_HIERARCHY_HEADER
 890 *&---------------------------------------------------------------------*
 891 *       text
 892 *----------------------------------------------------------------------*
 893 *  -->  p1        text
 894 *  <--  p2        text
 895 *----------------------------------------------------------------------*
 896 FORM build_hierarchy_header .
 897   CLEAR g_hierarchy_header.
 898   g_hierarchy_header-heading = '项目/WBS'.
 899   g_hierarchy_header-tooltip =  '项目/WBS'.
 900   g_hierarchy_header-width = 30.
 901   g_hierarchy_header-width_pix = ''.
 902 ENDFORM.
 903 *&---------------------------------------------------------------------*
 904 *&      Form  FRM_GET_DATA
 905 *&---------------------------------------------------------------------*
 906 *       text
 907 *----------------------------------------------------------------------*
 908 *  -->  p1        text
 909 *  <--  p2        text
 910 *----------------------------------------------------------------------*
 911 FORM frm_get_data .
 912   RANGES:wbs_to_select    FOR prps-pspnr,
 913          wbs_to_select_up FOR prps-pspnr,
 914          r_pspnr FOR proj-pspnr.
 915   "获取符合条件的项目定义
 916   SELECT DISTINCT  a~pspnr
 917     INTO TABLE @DATA(lt_posid)
 918     FROM proj AS a
 919     INNER JOIN prps AS b ON a~pspnr = b~psphi
 920     WHERE a~pspid IN @s_pspid"项目定义
 921       AND b~posid IN @s_posid"WBS元素
 922       AND b~prart IN @s_prart
 923       AND a~vbukr = @p_bukrs
 924       AND b~pbukr = @p_bukrs
 925       AND b~loevm = ''."删除标记
 926   "根据项目定义获取WBS
 927   REFRESH:r_pspnr,wbs_to_select,wbs_to_select_up.
 928   CLEAR:gt_prps,ls_cnz,lt_cnz,ls_syz,lt_syz.
 929   LOOP AT lt_posid INTO DATA(ls_posid).
 930     r_pspnr-sign = 'I'.
 931     r_pspnr-option = 'EQ'.
 932     r_pspnr-low = ls_posid-pspnr.
 933     APPEND r_pspnr.
 934     CLEAR r_pspnr.
 935   ENDLOOP.
 936   SORT r_pspnr.
 937   DELETE ADJACENT DUPLICATES FROM r_pspnr COMPARING ALL FIELDS.
 938   IF lt_posid IS INITIAL.
 939     MESSAGE '没有符合条件的数据' TYPE 'S' DISPLAY LIKE 'E'.
 940     RETURN.
 941   ENDIF.
 942   CALL FUNCTION 'CJDB_FILL_HIERARCHY'
 943     TABLES
 944       i_proj                 = r_pspnr[]
 945       e_prps_co              = gt_prps
 946       e_prps_not_yet_read    = wbs_to_select
 947       e_prps_not_yet_read_up = wbs_to_select_up.
 948   IF gt_prps IS NOT INITIAL.
 949     LOOP AT gt_prps INTO DATA(gs_prps).
 950       ls_data-sort = sy-tabix.
 951       "内外码转换
 952       CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
 953         EXPORTING
 954           input  = gs_prps-pspnr
 955         IMPORTING
 956           output = ls_data-posid.
 957       ls_data-pspnr = gs_prps-psphi."项目定义内码
 958       ls_data-pspnr1 =  gs_prps-pspnr."WBS内码
 959       ls_data-down = gs_prps-down.
 960       ls_data-above = gs_prps-above.
 961       ls_data-stufe = gs_prps-stufe.
 962       APPEND ls_data TO lt_data.
 963     ENDLOOP.
 964     SORT lt_data BY sort.
 965     SORT lt_data BY posid stufe prart.
 966 
 967     "含有下级节点的WBS元素 记录其下面所有WBS元素 用于预算sheet页 本层可用预算逻辑
 968     PERFORM frm_process_wbs.
 969 
 970     IF lt_data IS NOT INITIAL.
 971       "项目定义描述
 972       SELECT pspnr,post1
 973         INTO TABLE @DATA(lt_proj)
 974         FROM proj
 975         FOR ALL ENTRIES IN @lt_data
 976         WHERE pspnr = @lt_data-pspnr.
 977       SORT lt_proj BY pspnr.
 978       "WBS元素描述 项目类型
 979       SELECT pspnr post1 prart objnr
 980         INTO CORRESPONDING FIELDS OF TABLE lt_prps
 981         FROM prps
 982         FOR ALL ENTRIES IN lt_data
 983         WHERE pspnr = lt_data-pspnr1.
 984       SORT lt_prps BY pspnr objnr.
 985       "项目类型描述
 986       SELECT prart,pratx
 987         INTO TABLE @DATA(lt_tcj1t)
 988         FROM tcj1t
 989         WHERE langu = @sy-langu.
 990       SORT lt_tcj1t BY prart.
 991 
 992       "总体-预算金额
 993       PERFORM frm_get_ys_sum.
 994       "总体-成本金额 年度-成本金额 月度-成本金额
 995       PERFORM frm_get_cb_sum.
 996       "总体-结转金额 年度-结转金额 月度-结转金额
 997       PERFORM frm_get_jz_sum.
 998       "总体-发票金额 年度-发票金额 月度-发票金额
 999       PERFORM frm_get_fp_sum.
1000       "总体-付款金额 年度-付款金额 月度-付款金额
1001       PERFORM frm_get_fk_sum.
1002       "总体-转资金额 年度-转资金额 月度-转资金额
1003       PERFORM frm_get_zz_sum.
1004 
1005       "年度-预算金额
1006       PERFORM frm_get_ys_yy.
1007 
1008 
1009       "数据整理
1010 **&&  1、只是针对当前每条数据对应WBS的金额进行赋值,针对于有下层节点的WBS后续有汇总逻辑
1011       LOOP AT lt_data INTO ls_data.
1012         READ TABLE lt_proj INTO DATA(ls_proj)
1013           WITH KEY pspnr = ls_data-pspnr BINARY SEARCH.
1014         IF sy-subrc = 0.
1015           ls_data-post1 = ls_proj-post1.
1016         ENDIF.
1017         READ TABLE lt_prps INTO ls_prps
1018           WITH KEY pspnr = ls_data-pspnr1 BINARY SEARCH.
1019         IF sy-subrc = 0.
1020           ls_data-post1 = ls_prps-post1.
1021           ls_data-prart = ls_prps-prart.
1022           ls_data-objnr = ls_prps-objnr.
1023         ENDIF.
1024         READ TABLE lt_tcj1t INTO DATA(ls_tcj1t)
1025           WITH KEY prart = ls_data-prart BINARY SEARCH.
1026         IF sy-subrc = 0.
1027           ls_data-pratx = ls_tcj1t-pratx.
1028         ENDIF.
1029         ls_data-rtcur = 'RMB'.
1030         "总体 预算金额
1031         READ TABLE lt_bpge INTO ls_bpge
1032           WITH KEY objnr = ls_data-objnr BINARY SEARCH.
1033         IF sy-subrc = 0.
1034           ls_data-ys_sum = ls_bpge-wlges.
1035         ENDIF.
1036         "总体-成本金额
1037         READ TABLE lt_cb_sum INTO ls_cb_sum
1038           WITH KEY posid = ls_data-posid BINARY SEARCH.
1039         IF sy-subrc = 0.
1040           ls_data-cb_sum = ls_cb_sum-wtgbtr.
1041         ENDIF.
1042         "总体-结转金额
1043         READ TABLE lt_jz_sum INTO ls_jz_sum
1044           WITH KEY posid = ls_data-posid BINARY SEARCH.
1045         IF sy-subrc = 0.
1046           ls_data-jz_sum = ls_jz_sum-wtgbtr.
1047         ENDIF.
1048         "总体-发票金额
1049         READ TABLE lt_fp_sum INTO ls_fp_sum
1050           WITH KEY  ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1051         IF sy-subrc = 0.
1052           ls_data-fp_sum = ls_fp_sum-rmwwr.
1053         ENDIF.
1054         "总体-付款金额
1055         READ TABLE lt_fkje_sum INTO ls_fkje_sum
1056           WITH KEY ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1057         IF sy-subrc = 0.
1058           ls_data-fk_sum = ls_fkje_sum-hzje_bwb.
1059         ENDIF.
1060         "总体-转资金额
1061         READ TABLE lt_zzje_sum INTO ls_zzje_sum
1062           WITH KEY posnr = ls_data-pspnr1 BINARY SEARCH.
1063         IF sy-subrc = 0.
1064           ls_data-zz_sum = ls_zzje_sum-anbtr.
1065         ENDIF.
1066         "2023-预算金额
1067         READ TABLE lt_ys_sum INTO ls_ys_sum
1068           WITH KEY objnr = ls_data-pspnr1 BINARY SEARCH.
1069         IF sy-subrc = 0.
1070           ls_data-ys_yy = ls_ys_sum-wljhr.
1071         ENDIF.
1072         "2023-成本金额
1073         READ TABLE lt_cb_year INTO ls_cb_year
1074           WITH KEY posid = ls_data-posid BINARY SEARCH.
1075         IF sy-subrc = 0.
1076           ls_data-cb_yy = ls_cb_year-wtgbtr.
1077         ENDIF.
1078         "2023-结转金额
1079         READ TABLE lt_jz_year INTO ls_jz_year
1080           WITH KEY posid = ls_data-posid BINARY SEARCH.
1081         IF sy-subrc = 0.
1082           ls_data-jz_yy = ls_jz_year-wtgbtr.
1083         ENDIF.
1084         "2023-发票金额
1085         READ TABLE lt_fp_year INTO ls_fp_year
1086           WITH KEY ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1087         IF sy-subrc = 0.
1088           ls_data-fp_yy = ls_fp_year-rmwwr.
1089         ENDIF.
1090         "2023-付款金额
1091         READ TABLE lt_fkje_year INTO ls_fkje_year
1092           WITH KEY ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1093         IF sy-subrc = 0.
1094           ls_data-fk_yy = ls_fkje_year-hzje_bwb.
1095         ENDIF.
1096         "2023-转资金额
1097         READ TABLE lt_zzje_year INTO ls_zzje_year
1098           WITH KEY posnr = ls_data-pspnr1 BINARY SEARCH.
1099         IF sy-subrc = 0.
1100           ls_data-zz_yy = ls_zzje_year-anbtr.
1101         ENDIF.
1102         "月度-成本金额
1103         READ TABLE lt_cb_month INTO ls_cb_month
1104           WITH KEY posid = ls_data-posid BINARY SEARCH.
1105         IF sy-subrc = 0.
1106           ls_data-cb_mm = ls_cb_month-wtgbtr.
1107         ENDIF.
1108         "月度-结转金额
1109         READ TABLE lt_jz_month INTO ls_jz_month
1110           WITH KEY posid = ls_data-posid BINARY SEARCH.
1111         IF sy-subrc = 0.
1112           ls_data-jz_mm = ls_jz_month-wtgbtr.
1113         ENDIF.
1114         "月度-发票金额
1115         READ TABLE lt_fp_month INTO ls_fp_month
1116           WITH KEY ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1117         IF sy-subrc = 0.
1118           ls_data-fp_mm = ls_fp_month-rmwwr.
1119         ENDIF.
1120         "月度-付款金额
1121         READ TABLE lt_fkje_month INTO ls_fkje_month
1122           WITH KEY ps_psp_pnr = ls_data-pspnr1 BINARY SEARCH.
1123         IF sy-subrc = 0.
1124           ls_data-fk_mm = ls_fkje_month-hzje_bwb.
1125         ENDIF.
1126         "年度-转资金额
1127         READ TABLE lt_zzje_month INTO ls_zzje_month
1128           WITH KEY posnr = ls_data-pspnr1 BINARY SEARCH.
1129         IF sy-subrc = 0.
1130           ls_data-zz_mm = ls_zzje_month-anbtr.
1131         ENDIF.
1132 
1133         MOVE-CORRESPONDING ls_data TO ls_cnz."预算sheet页签 承诺值字段内表
1134         APPEND ls_cnz TO lt_cnz.
1135         IF ls_data-posid+0(1) = 'V'.
1136           MOVE-CORRESPONDING ls_data TO ls_syz."预算sheet页签 剩余计划值字段内表
1137           APPEND ls_syz TO lt_syz.
1138         ENDIF.
1139         MODIFY lt_data FROM ls_data.
1140         CLEAR ls_cnz.
1141       ENDLOOP.
1142 
1143 **&& 2、针对有下层WBS节点的WBS元素相关字段进行汇总 例:首层项目行,所有字段都应该累加其下层所有WBS元素对应值
1144       "根据层级倒序排序从最底层汇总
1145       SORT lt_data BY pspnr pspnr1 DESCENDING stufe DESCENDING. "倒序不要删除 该排序是汇总的关键 从底层向上层汇总
1146       LOOP AT lt_data INTO ls_data.
1147         "存在上层wbs
1148         IF ls_data-above NE ''. "above = 空为首层项目
1149           LOOP AT lt_data ASSIGNING FIELD-SYMBOL(<fs_data>) WHERE pspnr1 = ls_data-above.
1150             "对相关字段进行汇总
1151             <fs_data>-cb_sum = <fs_data>-cb_sum + ls_data-cb_sum."成本金额
1152             <fs_data>-jz_sum = <fs_data>-jz_sum + ls_data-jz_sum."结转金额
1153             <fs_data>-fp_sum = <fs_data>-fp_sum + ls_data-fp_sum."发票金额
1154             <fs_data>-fk_sum = <fs_data>-fk_sum + ls_data-fk_sum."付款金额
1155             <fs_data>-zz_sum = <fs_data>-zz_sum + ls_data-zz_sum."转资金额
1156 
1157             <fs_data>-cb_yy = <fs_data>-cb_yy + ls_data-cb_yy. "年度-成本
1158             <fs_data>-jz_yy = <fs_data>-jz_yy + ls_data-jz_yy."年度-结转
1159             <fs_data>-fp_yy = <fs_data>-fp_yy + ls_data-fp_yy."年度-发票
1160             <fs_data>-fk_yy = <fs_data>-fk_yy + ls_data-fk_yy."年度-付款
1161             <fs_data>-zz_yy = <fs_data>-zz_yy + ls_data-zz_yy."年度-转资
1162 
1163             <fs_data>-cb_mm = <fs_data>-cb_mm + ls_data-cb_mm. "月度-成本
1164             <fs_data>-jz_mm = <fs_data>-jz_mm + ls_data-jz_mm."月度-结转
1165             <fs_data>-fp_mm = <fs_data>-fp_mm + ls_data-fp_mm."月度-发票
1166             <fs_data>-fk_mm = <fs_data>-fk_mm + ls_data-fk_mm."月度-付款
1167             <fs_data>-zz_mm = <fs_data>-zz_mm + ls_data-zz_mm."月度-转资
1168           ENDLOOP.
1169         ENDIF.
1170       ENDLOOP.
1171 
1172 ***& 3、预算sheet页相关内表处理
1173       PERFORM frm_get_ys_sheet.
1174 
1175 
1176     ENDIF.
1177 
1178   ENDIF.
1179 ENDFORM.
1180 
1181 *&---------------------------------------------------------------------*
1182 *&      Form  ADD_NODES
1183 *&---------------------------------------------------------------------*
1184 *       text
1185 *----------------------------------------------------------------------*
1186 *      -->P_LS_DATA  text
1187 *      -->P_0592   text
1188 *      <--P_L_CUR_NODE  text
1189 *----------------------------------------------------------------------*
1190 FORM add_nodes  USING     ps_wbs TYPE ty_data
1191                           p_cnode_key TYPE lvc_nkey
1192                 CHANGING  p_nnode_key TYPE lvc_nkey.
1193   DATA:is_node_layout    TYPE lvc_s_layn.
1194   DATA:l_node_text TYPE lvc_value.
1195   "ALV TREE图标隐藏
1196   is_node_layout-n_image = 'BNONE'.
1197   is_node_layout-exp_image = 'BNONE'.
1198 
1199   CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
1200     EXPORTING
1201       input  = ps_wbs-posid
1202     IMPORTING
1203       output = l_node_text.
1204 
1205   CALL METHOD tree1->add_node
1206     EXPORTING
1207       i_relat_node_key = p_cnode_key
1208       i_relationship   = cl_gui_column_tree=>relat_last_child
1209       i_node_text      = l_node_text
1210       is_outtab_line   = ps_wbs
1211       is_node_layout   = is_node_layout
1212     IMPORTING
1213       e_new_node_key   = p_nnode_key.
1214 
1215 ENDFORM.
1216 *&---------------------------------------------------------------------*
1217 *&      Form  FRM_GET_YS_SUM
1218 *&---------------------------------------------------------------------*
1219 *       text
1220 *----------------------------------------------------------------------*
1221 *  -->  p1        text
1222 *  <--  p2        text
1223 *----------------------------------------------------------------------*
1224 FORM frm_get_ys_sum .
1225 
1226   IF lt_prps IS NOT INITIAL.
1227     SELECT objnr
1228            trgkz
1229            vorga
1230            versn
1231            wlges
1232       INTO TABLE lt_bpge
1233       FROM bpge
1234       FOR ALL ENTRIES IN lt_prps
1235       WHERE objnr = lt_prps-objnr
1236         AND wrttp = '41'.
1237     SORT lt_bpge BY objnr.
1238   ENDIF.
1239 
1240 ENDFORM.
1241 *&---------------------------------------------------------------------*
1242 *&      Form  FRM_GET_YS_YY
1243 *&---------------------------------------------------------------------*
1244 *       text
1245 *----------------------------------------------------------------------*
1246 *  -->  p1        text
1247 *  <--  p2        text
1248 *----------------------------------------------------------------------*
1249 FORM frm_get_ys_yy .
1250   IF lt_prps IS NOT INITIAL.
1251     SELECT objnr
1252            gjahr
1253            lednr
1254            trgkz
1255            vorga
1256            wljhr
1257       INTO CORRESPONDING FIELDS OF TABLE lt_bpja
1258       FROM bpja
1259       FOR ALL ENTRIES IN lt_prps
1260       WHERE objnr = lt_prps-objnr
1261         AND wrttp = '41'.
1262     SORT lt_bpja BY objnr gjahr.
1263 
1264     CLEAR:ls_ys_sum,lt_ys_sum.
1265     LOOP AT lt_bpja INTO ls_bpja.
1266       IF ls_bpja-gjahr = p_gjahr.
1267         ls_ys_sum-objnr = ls_bpja-objnr.
1268         ls_ys_sum-wljhr = ls_bpja-wljhr.
1269         COLLECT ls_ys_sum INTO lt_ys_sum.
1270       ENDIF.
1271     ENDLOOP.
1272     SORT lt_ys_sum BY objnr.
1273   ENDIF.
1274 ENDFORM.
1275 *&---------------------------------------------------------------------*
1276 *&      Form  FRM_GET_CB_SUM
1277 *&---------------------------------------------------------------------*
1278 *       text
1279 *----------------------------------------------------------------------*
1280 *  -->  p1        text
1281 *  <--  p2        text
1282 *----------------------------------------------------------------------*
1283 FORM frm_get_cb_sum .
1284   DATA:lr_cb  TYPE REF TO data.
1285   FIELD-SYMBOLS:<lt_cb> TYPE ANY TABLE.
1286   RANGES:rg_pspid FOR proj-pspid,
1287          rg_budat FOR cobk-budat.
1288   REFRESH:rg_pspid.
1289   IF lt_data IS NOT INITIAL.
1290     LOOP AT lt_data INTO ls_data.
1291       CLEAR:rg_pspid.
1292       IF ls_data-stufe = '1'."项目
1293         CLEAR rg_pspid.
1294         rg_pspid-sign = 'I'.
1295         rg_pspid-option = 'EQ'.
1296         rg_pspid-low = ls_data-posid.
1297         APPEND rg_pspid.
1298       ENDIF.
1299     ENDLOOP.
1300 
1301     IF rg_pspid[] IS NOT INITIAL.
1302       SET PARAMETER ID 'CAC' FIELD 'JSGX'.
1303       SET PARAMETER ID 'PDB' FIELD '000000000001'.
1304       cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false   metadata = abap_false data = abap_true ).
1305       SUBMIT rkpep003
1306         WITH cn_projn IN rg_pspid[]
1307         WITH p_disvar = '1SAP'
1308         WITH r_budat IN rg_budat[]
1309        EXPORTING LIST TO MEMORY AND RETURN.
1310       IF sy-subrc = 0.
1311         TRY.
1312             cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_cb ).
1313             ASSIGN lr_cb->* TO <lt_cb>.
1314           CATCH cx_salv_bs_sc_runtime_info.
1315 *            MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
1316         ENDTRY.
1317       ENDIF.
1318       cl_salv_bs_runtime_info=>clear_all( ).
1319     ENDIF.
1320     IF <lt_cb> IS NOT INITIAL.
1321       CLEAR:ls_cb,ls_jz,lt_cb,lt_jz,lt_cb_sheet,ls_cb_sheet.
1322       MOVE-CORRESPONDING <lt_cb> TO lt_cb."成本金额
1323       MOVE-CORRESPONDING <lt_cb> TO lt_jz."结转金额
1324 
1325       SORT lt_cb.
1326       SORT lt_jz.
1327       DELETE lt_cb WHERE kstar = '8001990000'.
1328       CLEAR:lt_cb_sum,ls_cb_sum,lt_cb_year,ls_cb_year,lt_cb_month,ls_cb_month.
1329 
1330       LOOP AT lt_cb INTO ls_cb.
1331         "成本汇总
1332         MOVE-CORRESPONDING ls_cb TO ls_cb_sum."按WBS成本汇总
1333         COLLECT ls_cb_sum INTO lt_cb_sum.
1334         "年度维度
1335         IF ls_cb-gjahr = p_gjahr.
1336           MOVE-CORRESPONDING ls_cb TO ls_cb_year.
1337           COLLECT ls_cb_year INTO lt_cb_year.
1338         ENDIF.
1339         "年度+月份维度
1340         IF ls_cb-gjahr = p_gjahr AND ls_cb-budat+4(2) = p_monat.
1341           MOVE-CORRESPONDING ls_cb TO ls_cb_month.
1342           COLLECT ls_cb_month INTO lt_cb_month.
1343         ENDIF.
1344         "预算sheet页‘实际’字段
1345         MOVE-CORRESPONDING ls_cb TO ls_cb_sheet.
1346         COLLECT ls_cb_sheet INTO lt_cb_sheet.
1347 
1348         CLEAR:ls_cb,ls_cb_sum,ls_cb_year,ls_cb_month.
1349       ENDLOOP.
1350       SORT lt_cb_sum BY pspid posid.
1351       SORT lt_cb_year BY pspid posid.
1352       SORT lt_cb_month BY pspid posid.
1353       SORT lt_cb_sheet BY posid posid gjahr.
1354 *      LOOP AT lt_cb_sheet INTO ls_cb_sheet.
1355 *        READ TABLE lt_cb_sheet_tmp INTO ls_cb_sheet_tmp WITH KEY posid = ls_cb_sheet-posid BINARY SEARCH.
1356 *        IF sy-subrc = 0.
1357 *          ls_cb_sheet-wtgbtr = ls_cb_sheet_tmp-wtgbtr.
1358 *          MODIFY lt_cb_sheet FROM ls_cb_sheet TRANSPORTING wtgbtr.
1359 *        ENDIF.
1360 *      ENDLOOP.
1361 
1362     ENDIF.
1363   ENDIF.
1364 ENDFORM.
1365 *&---------------------------------------------------------------------*
1366 *&      Form  FRM_GET_JZ_SUM
1367 *&---------------------------------------------------------------------*
1368 *       text
1369 *----------------------------------------------------------------------*
1370 *  -->  p1        text
1371 *  <--  p2        text
1372 *----------------------------------------------------------------------*
1373 FORM frm_get_jz_sum .
1374   SORT lt_jz.
1375   DELETE lt_jz WHERE kstar NE '8001990000'.
1376   CLEAR:ls_jz_sum,lt_jz_sum,ls_jz_year,lt_jz_year,ls_jz_month,lt_jz_month.
1377   LOOP AT lt_jz INTO ls_jz.
1378     MOVE-CORRESPONDING ls_jz TO ls_jz_sum."按WBS成本汇总
1379     COLLECT ls_jz_sum INTO lt_jz_sum.
1380     "年度维度 结转金额
1381     IF ls_jz-gjahr = p_gjahr.
1382       MOVE-CORRESPONDING ls_jz TO ls_jz_year.
1383       COLLECT ls_jz_year INTO lt_jz_year.
1384     ENDIF.
1385     "年度+月份维度
1386     IF ls_jz-gjahr = p_gjahr AND ls_jz-budat+4(2) = p_monat.
1387       MOVE-CORRESPONDING ls_jz TO ls_jz_month.
1388       COLLECT ls_jz_month INTO lt_jz_month.
1389     ENDIF.
1390     CLEAR:ls_jz,ls_jz_sum,ls_jz_year,ls_jz_month.
1391   ENDLOOP.
1392   SORT lt_jz_sum BY pspid posid.
1393   SORT lt_jz_year BY pspid posid.
1394   SORT lt_jz_month BY pspid posid.
1395 ENDFORM.
1396 *&---------------------------------------------------------------------*
1397 *&      Form  FRM_GET_FP_SUM
1398 *&---------------------------------------------------------------------*
1399 *       text
1400 *----------------------------------------------------------------------*
1401 *  -->  p1        text
1402 *  <--  p2        text
1403 *----------------------------------------------------------------------*
1404 FORM frm_get_fp_sum .
1405   IF lt_data IS NOT INITIAL.
1406     "根据PSPID查ekkn
1407     SELECT ps_psp_pnr,
1408            ebeln,
1409            ebelp,
1410            zekkn
1411       FROM ekkn
1412       INTO TABLE @DATA(lt_ekkn)
1413       FOR ALL ENTRIES IN @lt_data
1414       WHERE ps_psp_pnr = @lt_data-pspnr1
1415         AND loekz = ''.
1416 
1417     SORT lt_ekkn BY ps_psp_pnr ebeln ebelp.
1418     "查询rseg
1419     IF lt_ekkn IS NOT INITIAL.
1420       SELECT a~belnr,
1421              a~gjahr,
1422              a~ebeln,
1423              a~ebelp,
1424              a~buzei,
1425              b~rmwwr,
1426              b~budat
1427       FROM rseg AS a
1428       INNER JOIN rbkp AS b ON a~belnr = b~belnr AND a~gjahr = b~gjahr
1429       FOR ALL ENTRIES IN @lt_ekkn
1430       WHERE a~ebeln = @lt_ekkn-ebeln
1431         AND a~ebelp = @lt_ekkn-ebelp
1432         AND a~bukrs = @p_bukrs
1433 *        AND a~gjahr = @p_gjahr
1434 *        AND b~gjahr = @p_gjahr
1435       INTO TABLE @DATA(lt_rseg).
1436       SORT lt_rseg BY belnr ebeln ebelp.
1437     ENDIF.
1438 
1439     CLEAR:ls_fp_sum,lt_fp_sum,ls_fp_year,lt_fp_year,ls_fp_month,lt_fp_month,ls_belnr,lt_belnr.
1440     LOOP AT lt_ekkn INTO DATA(ls_ekkn).
1441       READ TABLE lt_rseg INTO DATA(ls_resg) WITH KEY ebeln = ls_ekkn-ebeln ebelp = ls_ekkn-ebelp BINARY SEARCH.
1442       IF sy-subrc = 0.
1443         ls_fp_sum-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1444         ls_fp_sum-rmwwr = ls_resg-rmwwr.
1445         COLLECT ls_fp_sum INTO lt_fp_sum.
1446         "双击项目对应发票sheet页限制发票号 年度
1447         ls_belnr-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1448         ls_belnr-belnr = ls_resg-belnr.
1449         ls_belnr-gjahr = ls_resg-gjahr.
1450         APPEND ls_belnr TO lt_belnr.
1451         CLEAR ls_belnr.
1452         IF ls_resg-gjahr = p_gjahr.
1453           ls_fp_year-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1454           ls_fp_year-rmwwr = ls_resg-rmwwr.
1455           COLLECT ls_fp_year INTO lt_fp_year.
1456         ENDIF.
1457         IF ls_resg-gjahr = p_gjahr AND ls_resg-budat+4(2) = p_monat.
1458           ls_fp_month-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1459           ls_fp_month-rmwwr = ls_resg-rmwwr.
1460           COLLECT ls_fp_month INTO lt_fp_month.
1461         ENDIF.
1462       ENDIF.
1463     ENDLOOP.
1464     SORT lt_fp_sum BY ps_psp_pnr.
1465     SORT lt_fp_year BY ps_psp_pnr.
1466     SORT lt_fp_month BY ps_psp_pnr.
1467     SORT lt_belnr BY ps_psp_pnr belnr.
1468   ENDIF.
1469 ENDFORM.
1470 *&---------------------------------------------------------------------*
1471 *&      Form  FRM_PROCESS_WBS
1472 *&---------------------------------------------------------------------*
1473 *       text
1474 *----------------------------------------------------------------------*
1475 *  -->  p1        text
1476 *  <--  p2        text
1477 *----------------------------------------------------------------------*
1478 FORM frm_process_wbs .
1479 
1480   DATA:lt_pspnr_tmp TYPE TABLE OF ty_pspnr,
1481        ls_pspnr_tmp TYPE ty_pspnr,
1482        lt_pspnr_wbs TYPE TABLE OF ty_pspnr_wbs,
1483        ls_pspnr_wbs TYPE ty_pspnr_wbs,
1484        gt_prps_tmp  TYPE TABLE OF prps_co.
1485   CLEAR:ls_pspnr_tmp,lt_pspnr_tmp.
1486   "非首层项目 下层WBS下含有子WBS
1487   SORT gt_prps BY psphi stufe DESCENDING.
1488   gt_prps_tmp = gt_prps.
1489 
1490   LOOP AT gt_prps INTO DATA(gs_prps) WHERE stufe NE 1 AND down NE ''.
1491     ls_pspnr_wbs-pspnr = gs_prps-pspnr.
1492 ***    "子WBS包含自身 汇总金额时使用
1493     CLEAR:ls_pspnr_tmp,lt_pspnr_tmp.
1494     "根据wbs 找出其下面所有子节点
1495     LOOP AT gt_prps_tmp INTO DATA(gs_prps_tmp) WHERE above = gs_prps-pspnr AND psphi = gs_prps-psphi.
1496       CLEAR:ls_pspnr_tmp.
1497 
1498       CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
1499         EXPORTING
1500           input  = gs_prps_tmp-pspnr
1501         IMPORTING
1502           output = ls_pspnr_tmp-posid.
1503 
1504       ls_pspnr_tmp-pspnr = gs_prps_tmp-pspnr.
1505       ls_pspnr_tmp-stufe = gs_prps_tmp-stufe.
1506       APPEND ls_pspnr_tmp TO lt_pspnr_tmp.
1507       "查询子节点下是否存在子节点
1508       READ TABLE lt_pspnr_wbs INTO DATA(ls_wbs_tmp) WITH KEY pspnr  = gs_prps_tmp-pspnr.
1509       IF sy-subrc = 0.
1510         LOOP AT ls_wbs_tmp-pspnr_list INTO DATA(ls_list).
1511           APPEND ls_list TO lt_pspnr_tmp.
1512         ENDLOOP.
1513       ENDIF.
1514       "减少内表数据 优化
1515       DELETE gt_prps_tmp WHERE pspcode = gs_prps_tmp-pspcode.
1516     ENDLOOP.
1517 
1518     SORT lt_pspnr_tmp.
1519     DELETE ADJACENT DUPLICATES FROM lt_pspnr_tmp COMPARING ALL FIELDS.
1520 
1521     ls_pspnr_wbs-pspnr_list = lt_pspnr_tmp.
1522     APPEND ls_pspnr_wbs TO lt_pspnr_wbs.
1523     CLEAR:ls_pspnr_wbs,lt_pspnr_tmp.
1524   ENDLOOP.
1525 
1526   SORT lt_pspnr_wbs BY pspnr.
1527 
1528   LOOP AT lt_data INTO ls_data.
1529     IF ls_data-stufe = '1' AND ls_data-down NE ''.
1530       "首层 list表为该项目下所有WBS 不包含本层
1531       LOOP AT gt_prps INTO gs_prps WHERE psphi = ls_data-pspnr AND pspnr NE ls_data-pspnr1.
1532         CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
1533           EXPORTING
1534             input  = gs_prps-pspnr
1535           IMPORTING
1536             output = ls_pspnr_tmp-posid.
1537         ls_pspnr_tmp-pspnr = gs_prps-pspnr.
1538         ls_pspnr_tmp-stufe = gs_prps-stufe.
1539         APPEND ls_pspnr_tmp TO lt_pspnr_tmp.
1540         CLEAR ls_pspnr_tmp.
1541       ENDLOOP.
1542       SORT lt_pspnr_tmp BY posid pspnr.
1543       ls_data-pspnr_list = lt_pspnr_tmp.
1544       ls_data-pspnr_list1 = lt_pspnr_tmp.
1545     ENDIF.
1546     IF ls_data-stufe NE '1' AND ls_data-down NE ''.
1547       READ TABLE lt_pspnr_wbs INTO ls_pspnr_wbs WITH KEY pspnr = ls_data-pspnr1 BINARY SEARCH.
1548       IF sy-subrc = 0.
1549         ls_data-pspnr_list = ls_pspnr_wbs-pspnr_list.
1550         ls_data-pspnr_list1 = ls_pspnr_wbs-pspnr_list.
1551       ENDIF.
1552     ENDIF.
1553     "包含当前父节点
1554     CLEAR:ls_pspnr_tmp,lt_pspnr_tmp.
1555     ls_pspnr_tmp-posid = ls_data-posid.
1556     ls_pspnr_tmp-pspnr = ls_data-pspnr1.
1557     ls_pspnr_tmp-stufe = ls_data-stufe.
1558     APPEND ls_pspnr_tmp TO ls_data-pspnr_list1.
1559     SORT ls_data-pspnr_list1 BY posid pspnr.
1560     MODIFY lt_data FROM ls_data TRANSPORTING pspnr_list pspnr_list1.
1561   ENDLOOP.
1562 ENDFORM.
1563 *&---------------------------------------------------------------------*
1564 *&      Form  FRM_GET_FK_SUM
1565 *&---------------------------------------------------------------------*
1566 *       text
1567 *----------------------------------------------------------------------*
1568 *  -->  p1        text
1569 *  <--  p2        text
1570 *----------------------------------------------------------------------*
1571 FORM frm_get_fk_sum .
1572   IF lt_data IS NOT INITIAL.
1573     "根据PSPID查ekkn
1574     SELECT ps_psp_pnr,
1575            ebeln,
1576            ebelp,
1577            zekkn
1578       FROM ekkn
1579       INTO TABLE @DATA(lt_ekkn)
1580       FOR ALL ENTRIES IN @lt_data
1581       WHERE ps_psp_pnr = @lt_data-pspnr1
1582         AND loekz = ''.
1583     SORT lt_ekkn BY ps_psp_pnr ebeln ebelp.
1584     "查询资金支付 付款金额
1585     SELECT a~ebeln,
1586            a~ebelp,
1587            b~applyno,
1588            b~apply_item,
1589            b~gjahr,
1590            b~monat,
1591            b~hzje_bwb
1592      FROM ztyfit00050 AS a
1593      INNER JOIN ztyfit00030 AS b ON a~bukrs = b~bukrs AND a~applyno = b~applyno AND a~apply_item = b~apply_item
1594      FOR ALL ENTRIES IN @lt_ekkn
1595      WHERE a~ebeln = @lt_ekkn-ebeln
1596        AND a~ebelp = @lt_ekkn-ebelp
1597        AND b~status IN ('07','11','21')
1598        AND a~bukrs = @p_bukrs
1599       INTO TABLE @DATA(lt_hzje).
1600 *      AND a~gjahr = p_gjahr.
1601     SORT lt_hzje BY ebeln ebelp.
1602     CLEAR:ls_fkje_sum,ls_fkje_year,ls_fkje_month,lt_fkje_sum,lt_fkje_year,lt_fkje_month,ls_applyno,lt_applyno.
1603     LOOP AT lt_ekkn INTO DATA(ls_ekkn).
1604       READ TABLE lt_hzje INTO DATA(ls_hzje) WITH KEY ebeln = ls_ekkn-ebeln ebelp = ls_ekkn-ebelp BINARY SEARCH.
1605       IF sy-subrc = 0.
1606         ls_fkje_sum-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1607         ls_fkje_sum-hzje_bwb = ls_hzje-hzje_bwb.
1608         COLLECT ls_fkje_sum INTO lt_fkje_sum.
1609         ls_applyno-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1610         ls_applyno-applyno = ls_hzje-applyno.
1611         APPEND ls_applyno TO lt_applyno.
1612         CLEAR ls_applyno.
1613         IF ls_hzje-gjahr = p_gjahr.
1614           ls_fkje_year-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1615           ls_fkje_year-hzje_bwb = ls_hzje-hzje_bwb..
1616           COLLECT ls_fkje_year INTO lt_fkje_year.
1617         ENDIF.
1618         IF ls_hzje-gjahr = p_gjahr AND ls_hzje-monat = p_monat.
1619           ls_fkje_month-ps_psp_pnr = ls_ekkn-ps_psp_pnr.
1620           ls_fkje_month-hzje_bwb = ls_hzje-hzje_bwb..
1621           COLLECT ls_fkje_month INTO lt_fkje_month.
1622         ENDIF.
1623       ENDIF.
1624     ENDLOOP.
1625     SORT lt_fkje_sum BY ps_psp_pnr.
1626     SORT lt_fkje_year BY ps_psp_pnr.
1627     SORT lt_fkje_month BY ps_psp_pnr.
1628     SORT lt_applyno BY ps_psp_pnr.
1629   ENDIF.
1630 ENDFORM.
1631 *&---------------------------------------------------------------------*
1632 *&      Form  FRM_GET_ZZ_SUM
1633 *&---------------------------------------------------------------------*
1634 *       text
1635 *----------------------------------------------------------------------*
1636 *  -->  p1        text
1637 *  <--  p2        text
1638 *----------------------------------------------------------------------*
1639 FORM frm_get_zz_sum .
1640   IF lt_data IS NOT INITIAL.
1641     SELECT a~posnr,
1642            b~anln1,
1643            b~anln2,
1644            b~gjahr,
1645            b~monat,
1646            b~lnran,
1647            c~afabe,
1648            c~zujhr,
1649            c~zucod,
1650            c~anbtr
1651       FROM anla AS a
1652       INNER JOIN anek AS b ON a~bukrs = b~bukrs AND a~anln1 = b~anln1 AND a~anln2 = b~anln2
1653       INNER JOIN anep AS c ON b~bukrs = c~bukrs AND b~anln1 = c~anln1 AND b~anln2 = c~anln2 AND b~gjahr = c~gjahr AND b~lnran = c~lnran
1654       FOR ALL ENTRIES IN @lt_data
1655       WHERE a~posnr = @lt_data-pspnr1
1656         AND a~anln1 NOT LIKE '3%'
1657         AND c~afabe = '1'
1658         AND c~bwasl IN ('300','310','320','330','341','346')
1659      INTO TABLE @DATA(lt_zz) .
1660 
1661     SORT lt_zz BY posnr.
1662     CLEAR:ls_zzje_sum,lt_zzje_sum,ls_zzje_year,lt_zzje_year,ls_zzje_month,lt_zzje_month.
1663     LOOP AT lt_zz INTO DATA(ls_zz).
1664       ls_zzje_sum-posnr = ls_zz-posnr.
1665       ls_zzje_sum-anbtr = ls_zz-anbtr.
1666       COLLECT ls_zzje_sum INTO lt_zzje_sum.
1667       IF ls_zz-gjahr = p_gjahr.
1668         ls_zzje_year-posnr = ls_zz-posnr.
1669         ls_zzje_year-anbtr = ls_zz-anbtr.
1670         COLLECT ls_zzje_year INTO lt_zzje_year.
1671       ENDIF.
1672       IF ls_zz-gjahr = p_gjahr AND ls_zz-monat = p_monat.
1673         ls_zzje_month-posnr = ls_zz-posnr.
1674         ls_zzje_month-anbtr = ls_zz-anbtr.
1675         COLLECT ls_zzje_month INTO lt_zzje_month.
1676       ENDIF.
1677     ENDLOOP.
1678   ENDIF.
1679 ENDFORM.
1680 *&---------------------------------------------------------------------*
1681 *&      Form  FRM_REFRESH_ALV
1682 *&---------------------------------------------------------------------*
1683 *       text
1684 *----------------------------------------------------------------------*
1685 *      -->P_GV_SHEET  text
1686 *----------------------------------------------------------------------*
1687 FORM frm_refresh_alv  USING    gv_sheet.
1688   DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
1689   CASE gv_sheet.
1690     WHEN 2.
1691       lr_grid = go_grid_102.
1692     WHEN 3.
1693       lr_grid = go_grid_103.
1694     WHEN 4.
1695       lr_grid = go_grid_104.
1696     WHEN 5.
1697       lr_grid = go_grid_105.
1698     WHEN 6.
1699       lr_grid = go_grid_106.
1700     WHEN 7.
1701       lr_grid = go_grid_107.
1702 
1703     WHEN OTHERS.
1704   ENDCASE.
1705   CALL METHOD lr_grid->refresh_table_display
1706     EXPORTING
1707       i_soft_refresh = 'X'.
1708   "刷新子屏幕101 显示GV_TEXT
1709   CLEAR gv_zrefresh.
1710   DATA:pa_ucomm TYPE sy-ucomm VALUE 'ZREFRESH'.
1711 
1712   cl_gui_cfw=>set_new_ok_code( pa_ucomm ).
1713 ENDFORM.
1714 *&---------------------------------------------------------------------*
1715 *&      Form  FRM_ALV_DISPLAY_102
1716 *&---------------------------------------------------------------------*
1717 *       text
1718 *----------------------------------------------------------------------*
1719 *  -->  p1        text
1720 *  <--  p2        text
1721 *----------------------------------------------------------------------*
1722 FORM frm_alv_display_102 .
1723   DATA: lo_event TYPE REF TO lcl_tree_event_receiver.
1724 
1725   DATA: ls_layout TYPE lvc_s_layo.
1726 
1727 
1728   ls_layout-sel_mode = 'D'.
1729 *  ls_layout-cwidth_opt = 'X'.
1730 *  ls_layout-no_toolbar = 'X'.
1731   REFRESH lt_fieldcat_102.
1732   PERFORM build_fieldcat_main_102 CHANGING lt_fieldcat_102.
1733   CALL METHOD go_grid_102->set_table_for_first_display
1734     EXPORTING
1735       is_layout       = ls_layout
1736       i_save          = 'A'
1737     CHANGING
1738       it_outtab       = lt_ys_sheet
1739       it_fieldcatalog = lt_fieldcat_102.
1740 ENDFORM.
1741 *&---------------------------------------------------------------------*
1742 *&      Form  BUILD_FIELDCAT_MAIN_102
1743 *&---------------------------------------------------------------------*
1744 *       text
1745 *----------------------------------------------------------------------*
1746 *      <--P_LT_FIELDCAT_102  text
1747 *----------------------------------------------------------------------*
1748 FORM build_fieldcat_main_102  CHANGING pt_fieldcat TYPE lvc_t_fcat.
1749   DATA: ls_fieldcat TYPE lvc_s_fcat.
1750 
1751   DEFINE  mac_fieldcat.
1752     CLEAR ls_fieldcat.
1753     ls_fieldcat-col_pos = &1.
1754     ls_fieldcat-fieldname = &2.
1755 
1756     ls_fieldcat-scrtext_s =
1757     ls_fieldcat-scrtext_m =
1758     ls_fieldcat-coltext   =
1759     ls_fieldcat-scrtext_l = &3.
1760 
1761     ls_fieldcat-edit = &4.
1762     ls_fieldcat-outputlen = &5.
1763     ls_fieldcat-ref_table =  &6.
1764     ls_fieldcat-ref_field =  &7.
1765     ls_fieldcat-checkbox =  &8.
1766     APPEND ls_fieldcat TO pt_fieldcat.
1767   END-OF-DEFINITION.
1768 
1769   mac_fieldcat 1 'GJAHR' '年度'     space  '10' space space  space.
1770   mac_fieldcat 2 'YS' '预算'      space  '15' space space  space.
1771   mac_fieldcat 3 'SJ' '实际'      space  '15' space space  space.
1772   mac_fieldcat 4 'CNZ' '承诺'      space  '15' space space  space.
1773   mac_fieldcat 5 'SYZ' '剩余计划'      space  '15' space space  space.
1774   mac_fieldcat 6 'YFP' '已分配'      space  '15' space space  space.
1775   mac_fieldcat 7 'KY' '可用'      space  '15' space space  space.
1776   mac_fieldcat 8 'BCKY' '本层可用'      space  '15' space space  space.
1777 ENDFORM.
1778 *&---------------------------------------------------------------------*
1779 *&      Form  FRM_GET_YS_SHEET
1780 *&---------------------------------------------------------------------*
1781 *       text
1782 *----------------------------------------------------------------------*
1783 *  -->  p1        text
1784 *  <--  p2        text
1785 *----------------------------------------------------------------------*
1786 FORM frm_get_ys_sheet .
1787   CLEAR:ls_ys_year,lt_ys_year,ls_cnz_sum,lt_cnz_sum.
1788   "预算sheet页 实际金额字段内表
1789 *  LOOP AT lt_cb_sheet INTO ls_cb_sheet.
1790 *    READ TABLE lt_data INTO ls_data WITH KEY posid = ls_cb_sheet-posid.
1791 *    IF sy-subrc = 0.
1792 *      ls_cb_sheet-stufe = ls_data-stufe.
1793 *      ls_cb_sheet-above = ls_data-above.
1794 *      ls_cb_sheet-down = ls_data-down.
1795 *      ls_cb_sheet-pspnr1 = ls_data-pspnr1.
1796 *      MODIFY lt_cb_sheet FROM ls_cb_sheet TRANSPORTING stufe above down pspnr1.
1797 *    ENDIF.
1798 *  ENDLOOP.
1799   "预算列 内表处理
1800   LOOP AT lt_bpja INTO ls_bpja. "WHERE objnr = ls_data-objnr.
1801     ls_ys_year-objnr = ls_bpja-objnr.
1802     ls_ys_year-gjahr = ls_bpja-gjahr.
1803     ls_ys_year-wljhr = ls_bpja-wljhr.
1804     COLLECT ls_ys_year INTO lt_ys_year.
1805   ENDLOOP.
1806   SORT lt_ys_year BY objnr gjahr.
1807   SORT lt_cb_sheet BY pspid posid DESCENDING stufe DESCENDING.
1808   "实际列 成本 汇总下层有WBS的项目
1809 *  LOOP AT lt_cb_sheet INTO ls_cb_sheet.
1810 *    "存在上层wbs 下层WBS金额汇总到上层WBS金额上进行累加
1811 *    IF ls_cb_sheet-above NE ''. "above = 空为首层项目
1812 *      LOOP AT lt_cb_sheet ASSIGNING FIELD-SYMBOL(<fs_cb>) WHERE pspnr1 = ls_cb_sheet-above AND gjahr = ls_cb_sheet-gjahr.
1813 *        IF <fs_cb> IS ASSIGNED.
1814 *          "对相关字段进行汇总
1815 *          <fs_cb>-wtgbtr = <fs_cb>-wtgbtr + ls_cb_sheet-wtgbtr.
1816 *        ENDIF.
1817 *      ENDLOOP.
1818 *    ENDIF.
1819 *  ENDLOOP.
1820 
1821   "承诺值列
1822   SORT lt_cnz BY posid stufe objnr.
1823   IF lt_cnz IS NOT INITIAL.
1824     SELECT objnr,lednr,trgkz,gjahr,acpos,vorga,versn,abkat,geber,twaer,perbl,
1825            wlp01,wlp02,wlp03,wlp04,wlp05,wlp06,wlp07,wlp08,wlp09,wlp10,wlp11,
1826            wlp12,wlp13,wlp14,wlp15,wlp16
1827       FROM rpsco
1828       INTO TABLE @DATA(lt_rpsco1)
1829       FOR ALL ENTRIES IN @lt_cnz
1830       WHERE objnr = @lt_cnz-objnr
1831         AND wrttp IN ('21','22').
1832     "汇总
1833     SORT lt_cnz BY objnr.
1834     LOOP AT lt_rpsco1 INTO DATA(ls_rpsco1).
1835       READ TABLE lt_cnz INTO ls_cnz WITH KEY objnr = ls_rpsco1-objnr BINARY SEARCH.
1836       IF sy-subrc = 0.
1837         MOVE-CORRESPONDING ls_cnz TO ls_cnz_sum.
1838         ls_cnz_sum-gjahr = ls_rpsco1-gjahr.
1839         ls_cnz_sum-cnz = ls_rpsco1-wlp01 + ls_rpsco1-wlp02 + ls_rpsco1-wlp03 + ls_rpsco1-wlp04 + ls_rpsco1-wlp05 + ls_rpsco1-wlp06 +
1840                          ls_rpsco1-wlp07 + ls_rpsco1-wlp08 + ls_rpsco1-wlp09 + ls_rpsco1-wlp10 + ls_rpsco1-wlp11 + ls_rpsco1-wlp12 +
1841                          ls_rpsco1-wlp13 + ls_rpsco1-wlp14 + ls_rpsco1-wlp15 + ls_rpsco1-wlp16.
1842         COLLECT ls_cnz_sum INTO lt_cnz_sum.
1843         CLEAR ls_cnz_sum.
1844       ENDIF.
1845     ENDLOOP.
1846 *    SORT lt_cnz_sum BY posid DESCENDING stufe DESCENDING gjahr."累加排序
1847 *    LOOP AT lt_cnz_sum INTO ls_cnz_sum.
1848 *      IF ls_cnz_sum-above NE ''.
1849 *        LOOP AT lt_cnz_sum ASSIGNING FIELD-SYMBOL(<fs_cnz>) WHERE pspnr1 = ls_cnz_sum-above AND gjahr = ls_cnz_sum-gjahr.
1850 *          IF <fs_cnz> IS ASSIGNED.
1851 *            <fs_cnz>-cnz = <fs_cnz>-cnz + ls_cnz_sum-cnz.
1852 *          ENDIF.
1853 *        ENDLOOP.
1854 *      ENDIF.
1855 *    ENDLOOP.
1856     SORT lt_cnz_sum BY posid stufe gjahr.
1857   ENDIF.
1858 
1859   "剩余计划值
1860   SORT lt_syz BY posid stufe objnr.
1861   IF lt_syz IS NOT INITIAL.
1862     SELECT a~pspel,a~objnr,b~lednr,b~wrttp,b~trgkz,b~gjahr,b~acpos,b~vorga,b~versn,b~abkat,b~geber,
1863            b~twaer,b~perbl,b~wlp01,b~wlp02,b~wlp03,b~wlp04,b~wlp05,b~wlp06,b~wlp07,b~wlp08,b~wlp09,
1864            b~wlp10,b~wlp11,b~wlp12,b~wlp13,b~wlp14,b~wlp15,b~wlp16
1865       FROM aufk AS a
1866       INNER JOIN rpsco AS b ON a~objnr = b~objnr
1867       INTO TABLE @DATA(lt_aufk)
1868       FOR ALL ENTRIES IN @lt_syz
1869       WHERE a~pspel = @lt_syz-pspnr1
1870         AND a~bukrs = @p_bukrs
1871         AND a~idat2 IS NULL
1872         AND b~wrttp IN ('1','4').
1873     SORT lt_aufk BY pspel.
1874     CLEAR:ls_syz_sum,lt_syz_sum.
1875     LOOP AT lt_aufk INTO DATA(ls_aufk).
1876       READ TABLE lt_syz INTO ls_syz WITH KEY posid = ls_aufk-pspel BINARY SEARCH.
1877       IF sy-subrc = 0.
1878         MOVE-CORRESPONDING ls_syz TO ls_syz_sum.
1879         IF ls_aufk-wrttp = '4'.
1880           ls_aufk-wlp01 = -1 * ls_aufk-wlp01.
1881           ls_aufk-wlp02 = -1 * ls_aufk-wlp02.
1882           ls_aufk-wlp03 = -1 * ls_aufk-wlp03.
1883           ls_aufk-wlp04 = -1 * ls_aufk-wlp04.
1884           ls_aufk-wlp05 = -1 * ls_aufk-wlp05.
1885           ls_aufk-wlp06 = -1 * ls_aufk-wlp06.
1886           ls_aufk-wlp07 = -1 * ls_aufk-wlp07.
1887           ls_aufk-wlp08 = -1 * ls_aufk-wlp08.
1888           ls_aufk-wlp09 = -1 * ls_aufk-wlp09.
1889           ls_aufk-wlp10 = -1 * ls_aufk-wlp10.
1890           ls_aufk-wlp11 = -1 * ls_aufk-wlp11.
1891           ls_aufk-wlp12 = -1 * ls_aufk-wlp12.
1892           ls_aufk-wlp13 = -1 * ls_aufk-wlp13.
1893           ls_aufk-wlp14 = -1 * ls_aufk-wlp14.
1894           ls_aufk-wlp15 = -1 * ls_aufk-wlp15.
1895           ls_aufk-wlp16 = -1 * ls_aufk-wlp16.
1896         ENDIF.
1897         ls_syz_sum-gjahr = ls_aufk-gjahr.
1898         ls_syz_sum-cnz = ls_aufk-wlp01 + ls_aufk-wlp02 + ls_aufk-wlp03 + ls_aufk-wlp04 + ls_aufk-wlp05 + ls_aufk-wlp06 +
1899                          ls_aufk-wlp07 + ls_aufk-wlp08 + ls_aufk-wlp09 + ls_aufk-wlp10 + ls_aufk-wlp11 + ls_aufk-wlp12 +
1900                          ls_aufk-wlp13 + ls_aufk-wlp14 + ls_aufk-wlp15 + ls_aufk-wlp16.
1901         COLLECT ls_syz_sum INTO lt_syz_sum.
1902         CLEAR:ls_aufk,ls_syz,ls_syz_sum.
1903       ENDIF.
1904     ENDLOOP.
1905     SORT lt_syz_sum BY posid DESCENDING stufe DESCENDING gjahr."累加排序
1906     LOOP AT lt_syz_sum INTO ls_syz_sum.
1907       IF ls_syz_sum-above NE ''.
1908         LOOP AT lt_syz_sum ASSIGNING FIELD-SYMBOL(<fs_syz>) WHERE pspnr1 = ls_syz_sum-above AND gjahr = ls_syz_sum-gjahr.
1909           IF <fs_syz> IS ASSIGNED.
1910             <fs_syz>-cnz = <fs_syz>-cnz + ls_syz_sum-cnz.
1911           ENDIF.
1912         ENDLOOP.
1913       ENDIF.
1914     ENDLOOP.
1915     SORT lt_syz_sum BY posid stufe gjahr.
1916   ENDIF.
1917 
1918 
1919 
1920 ENDFORM.
1921 *&---------------------------------------------------------------------*
1922 *&      Form  FRM_GET_SHEET_BCKY
1923 *&---------------------------------------------------------------------*
1924 *       text
1925 *----------------------------------------------------------------------*
1926 *      -->P_LS_DATA  text
1927 *----------------------------------------------------------------------*
1928 FORM frm_get_sheet_bcky  USING ps_sheet TYPE ty_ys_sheet ps_data TYPE ty_data
1929                          CHANGING ps_bcky TYPE rpsco-wlp01.
1930   DATA:lv_ys    TYPE rpsco-wlp01,
1931        lv_sj    TYPE rpsco-wlp01,
1932        lv_cnz   TYPE rpsco-wlp01,
1933        lv_syz   TYPE rpsco-wlp01,
1934        lv_yfp   TYPE rpsco-wlp01,
1935        lv_xjyfp TYPE rpsco-wlp01. "下级已分配
1936   CLEAR:lv_ys,lv_sj,lv_cnz,lv_syz,lv_xjyfp,ls_ys_year.
1937   "预算= ps_sheet-ys
1938   "下级 ps_data-pspnr_list
1939   LOOP AT ps_data-pspnr_list INTO DATA(ps_list) .
1940     "下级 预算 汇总
1941     READ TABLE lt_ys_year INTO ls_ys_year
1942          WITH KEY objnr = ps_list-pspnr gjahr = gv_gjahr .
1943     IF sy-subrc = 0.
1944       lv_ys = lv_ys + ls_ys_year-wljhr.
1945     ELSE.
1946       CONTINUE.
1947     ENDIF.
1948     "下级预算为0
1949     IF ls_ys_year-wljhr IS INITIAL.
1950       CONTINUE.
1951     ENDIF.
1952     "获取预算不为0对应WBS下的所有节点
1953     READ TABLE lt_data INTO DATA(ls_data1) WITH KEY pspnr1 = ps_list-pspnr.
1954     IF sy-subrc = 0.
1955       LOOP AT ls_data1-pspnr_list1 INTO DATA(ls_list1).
1956         "实际
1957         READ TABLE lt_cb_sheet INTO ls_cb_sheet
1958            WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
1959         IF sy-subrc = 0.
1960           lv_sj =  ls_cb_sheet-wtgbtr.
1961         ENDIF.
1962 
1963         "承诺值
1964         READ TABLE lt_cnz_sum INTO ls_cnz_sum
1965           WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
1966         IF sy-subrc = 0.
1967           lv_cnz = ls_cnz_sum-cnz.
1968         ENDIF.
1969         "剩余计划值
1970         READ TABLE lt_syz_sum INTO ls_syz_sum
1971              WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
1972         IF sy-subrc = 0.
1973           lv_syz = ls_syz_sum-cnz.
1974         ENDIF.
1975         "下级已分配=实际+承诺+剩余计划
1976         IF lv_sj IS NOT INITIAL OR lv_cnz IS NOT INITIAL OR lv_syz IS NOT INITIAL.
1977           lv_xjyfp = lv_xjyfp + ( lv_sj + lv_cnz + lv_syz ).
1978         ENDIF.
1979 
1980         CLEAR:lv_sj,lv_cnz,lv_syz,ls_ys_year.
1981 
1982       ENDLOOP.
1983 
1984     ENDIF.
1985 
1986   ENDLOOP.
1987   "直接下级预算 - 已分配
1988   ps_bcky = lv_ys - lv_xjyfp .
1989 ENDFORM.
1990 *&---------------------------------------------------------------------*
1991 *&      Form  FRM_GET_SHEET_FIELD_VALUE
1992 *&---------------------------------------------------------------------*
1993 *       text
1994 *----------------------------------------------------------------------*
1995 *      <--P_LS_YS_SHEET  text
1996 *----------------------------------------------------------------------*
1997 FORM frm_get_sheet_field_value USING p_s_data TYPE ty_data
1998                                CHANGING p_ys_sheet TYPE ty_ys_sheet.
1999   "预算
2000   READ TABLE lt_ys_year INTO ls_ys_year
2001        WITH KEY objnr = p_s_data-objnr gjahr = gv_gjahr BINARY SEARCH.
2002   IF sy-subrc = 0.
2003     p_ys_sheet-ys = ls_ys_year-wljhr.
2004   ENDIF.
2005 
2006   SORT lt_cb_sheet BY posid gjahr.
2007   SORT lt_cnz_sum BY posid gjahr.
2008   CLEAR:p_ys_sheet-sj,p_ys_sheet-cnz,p_ys_sheet-cnz.
2009   LOOP AT p_s_data-pspnr_list1 INTO DATA(pr_list).
2010     "实际
2011     READ TABLE lt_cb_sheet INTO ls_cb_sheet WITH KEY posid = pr_list-posid gjahr = gv_gjahr BINARY SEARCH.
2012     IF sy-subrc = 0.
2013       p_ys_sheet-sj = p_ys_sheet-sj + ls_cb_sheet-wtgbtr.
2014     ENDIF.
2015     "承诺值
2016     READ TABLE lt_cnz_sum INTO ls_cnz_sum
2017        WITH KEY posid = pr_list-posid gjahr = gv_gjahr BINARY SEARCH.
2018     IF sy-subrc = 0.
2019       p_ys_sheet-cnz = p_ys_sheet-cnz + ls_cnz_sum-cnz.
2020     ENDIF.
2021   ENDLOOP.
2022 
2023   "剩余计划值
2024   READ TABLE lt_syz_sum INTO ls_syz_sum
2025        WITH KEY posid = p_s_data-posid gjahr = gv_gjahr BINARY SEARCH.
2026   IF sy-subrc = 0.
2027     p_ys_sheet-syz = ls_syz_sum-cnz.
2028   ENDIF.
2029 ENDFORM.
2030 *&---------------------------------------------------------------------*
2031 *&      Form  FRM_ZZ_SHEET
2032 *&---------------------------------------------------------------------*
2033 *       text
2034 *----------------------------------------------------------------------*
2035 *      -->P_P_NODE_KEY  text
2036 *----------------------------------------------------------------------*
2037 FORM frm_zz_sheet  USING    node_key.
2038   RANGES:r_posid FOR prps-posid,
2039          r_pspnr FOR prps-pspnr.
2040   DATA: l_value TYPE lvc_value,
2041         l_layi  TYPE lvc_t_layi,
2042         l_layn  TYPE lvc_s_layn,
2043         lv_time TYPE sy-tabix.
2044   CALL METHOD tree1->get_outtab_line
2045     EXPORTING
2046       i_node_key     = node_key
2047     IMPORTING
2048       e_outtab_line  = ls_data
2049       e_node_text    = l_value
2050       et_item_layout = l_layi
2051       es_node_layout = l_layn
2052     EXCEPTIONS
2053       node_not_found = 1
2054       OTHERS         = 2.
2055   IF sy-subrc = 0.
2056     CLEAR:gv_text.
2057     gv_text = ls_data-posid && ls_data-post1.
2058 
2059     IF ls_data-pspnr_list IS NOT INITIAL.
2060       REFRESH:r_posid,r_pspnr.
2061       CLEAR:r_posid,r_pspnr.
2062       "wbs元素汇总 本层和下级所有wbs
2063       r_posid-sign = 'I'.
2064       r_posid-option = 'EQ'.
2065       r_posid-low = ls_data-posid.
2066       APPEND r_posid.
2067 
2068       r_pspnr-sign = 'I'.
2069       r_pspnr-option = 'EQ'.
2070       r_pspnr-low = ls_data-pspnr.
2071       APPEND r_pspnr.
2072 
2073 
2074       LOOP AT ls_data-pspnr_list INTO DATA(ls_list).
2075         r_posid-sign = 'I'.
2076         r_posid-option = 'EQ'.
2077         r_posid-low = ls_list-posid.
2078         APPEND r_posid.
2079 
2080         r_pspnr-sign = 'I'.
2081         r_pspnr-option = 'EQ'.
2082         r_pspnr-low = ls_list-pspnr.
2083         APPEND r_pspnr.
2084         CLEAR:r_posid,r_pspnr.
2085       ENDLOOP.
2086 
2087       SELECT a~gjahr a~monat a~budat a~anln1 a~lnran
2088              b~txt50 b~posnr a~sgtxt a~anlu1 a~anlu2
2089              a~tcode a~cpudt a~cputm c~anbtr c~bwasl c~bzdat
2090         INTO CORRESPONDING FIELDS OF TABLE lt_zz
2091         FROM anek AS a
2092         INNER JOIN anla AS b ON a~bukrs = b~bukrs AND a~anln1 = b~anln1 AND a~anln2 = b~anln2
2093         INNER JOIN anep AS c ON a~bukrs = c~bukrs AND a~gjahr = c~gjahr AND a~anln1 = c~anln1 AND a~anln2 = c~anln2 AND a~lnran = c~lnran
2094         WHERE a~bukrs = p_bukrs
2095           AND a~gjahr = p_gjahr
2096           AND a~monat = p_monat
2097           AND b~posnr IN r_posid
2098           AND a~anln1 NOT LIKE '3%'
2099           AND c~bwasl IN ('300','310','320','330','341','346').
2100 
2101       SORT lt_zz.
2102       "资产WBS描述
2103       SELECT pspnr,
2104              posid,
2105              post1
2106         INTO TABLE @DATA(lt_post1)
2107         FROM prps
2108         WHERE posid IN @r_posid.
2109       SORT lt_post1 BY pspnr posid.
2110       "转出卡片描述
2111       IF lt_zz IS NOT INITIAL.
2112         SELECT anln1,
2113                anln2,
2114                txt50
2115           INTO TABLE @DATA(lt_anlu1)
2116           FROM anla
2117           FOR ALL ENTRIES IN  @lt_zz
2118           WHERE anln1 = @lt_zz-anlu1
2119             AND anln2 = @lt_zz-anlu2.
2120 
2121         SORT lt_anlu1 BY anln1 anln2.
2122 
2123         LOOP AT lt_zz INTO ls_zz.
2124           READ TABLE lt_post1 INTO DATA(ls_post1) WITH KEY pspnr = ls_zz-posnr BINARY SEARCH.
2125           IF sy-subrc = 0.
2126             ls_zz-post1 = ls_post1-post1.
2127           ENDIF.
2128           READ TABLE lt_anlu1 INTO DATA(ls_anlu1) WITH KEY anln1 = ls_zz-anlu1 anln2 = ls_zz-anlu2 BINARY SEARCH.
2129           IF sy-subrc = 0.
2130             ls_zz-anlu1_t = ls_anlu1-txt50.
2131           ENDIF.
2132           MODIFY lt_zz FROM ls_zz TRANSPORTING post1 anlu1_t.
2133         ENDLOOP.
2134       ENDIF.
2135 
2136     ENDIF.
2137   ENDIF.
2138 ENDFORM.
2139 *&---------------------------------------------------------------------*
2140 *&      Form  FRM_ALV_DISPLAY_107
2141 *&---------------------------------------------------------------------*
2142 *       text
2143 *----------------------------------------------------------------------*
2144 *  -->  p1        text
2145 *  <--  p2        text
2146 *----------------------------------------------------------------------*
2147 FORM frm_alv_display_107 .
2148   DATA: ls_layout TYPE lvc_s_layo.
2149   ls_layout-sel_mode = 'D'.
2150 *  ls_layout-cwidth_opt = 'X'.
2151 *  ls_layout-no_toolbar = 'X'.
2152   REFRESH lt_fieldcat_107.
2153   PERFORM build_fieldcat_main_107 CHANGING lt_fieldcat_107.
2154   CALL METHOD go_grid_107->set_table_for_first_display
2155     EXPORTING
2156       is_layout       = ls_layout
2157       i_save          = 'A'
2158     CHANGING
2159       it_outtab       = lt_zz
2160       it_fieldcatalog = lt_fieldcat_107.
2161 ENDFORM.
2162 *&---------------------------------------------------------------------*
2163 *&      Form  BUILD_FIELDCAT_MAIN_107
2164 *&---------------------------------------------------------------------*
2165 *       text
2166 *----------------------------------------------------------------------*
2167 *      <--P_LT_FIELDCAT_107  text
2168 *----------------------------------------------------------------------*
2169 FORM build_fieldcat_main_107  CHANGING pt_fieldcat TYPE lvc_t_fcat.
2170   DATA: ls_fieldcat TYPE lvc_s_fcat.
2171 
2172   DEFINE  mac_fieldcat.
2173     CLEAR ls_fieldcat.
2174     ls_fieldcat-col_pos = &1.
2175     ls_fieldcat-fieldname = &2.
2176 
2177     ls_fieldcat-scrtext_s =
2178     ls_fieldcat-scrtext_m =
2179     ls_fieldcat-coltext   =
2180     ls_fieldcat-scrtext_l = &3.
2181 
2182     ls_fieldcat-edit = &4.
2183     ls_fieldcat-outputlen = &5.
2184     ls_fieldcat-ref_table =  &6.
2185     ls_fieldcat-ref_field =  &7.
2186     ls_fieldcat-checkbox =  &8.
2187     APPEND ls_fieldcat TO pt_fieldcat.
2188   END-OF-DEFINITION.
2189   mac_fieldcat 1 'GJAHR' '年度'     space  '6' space space  space.
2190   mac_fieldcat 2 'MONAT' '期间'     space  '6' space space  space.
2191   mac_fieldcat 3 'BUDAT' '过账日期' space  '10' space space  space.
2192   mac_fieldcat 4 'ANLN1' '资产卡片' space  '10' space space  space.
2193   mac_fieldcat 5 'TXT50' '资产描述' space  '10' space space  space.
2194   mac_fieldcat 6 'POSNR' '资产WBS' space  '10' space space  space.
2195   mac_fieldcat 7 'POST1' '资产WBS描述' space  '10' space space  space.
2196   mac_fieldcat 8 'ANBTR' '转账金额' space  '10' space space  space.
2197   mac_fieldcat 9 'SGTXT' '摘要' space  '10' space space  space.
2198   mac_fieldcat 10 'BWASL' '事务类型' space  '10' space space  space.
2199   mac_fieldcat 11 'BZDAT' '资产价值日' space  '10' space space  space.
2200   mac_fieldcat 12 'ANLU1' '转出卡片' space  '10' space space  space.
2201   mac_fieldcat 13 'ANLU1_T' '转出卡片描述' space  '10' space space  space.
2202   mac_fieldcat 14 'TCODE' '事务代码' space  '10' space space  space.
2203   mac_fieldcat 15 'CPUDT' '创建日期' space  '10' space space  space.
2204   mac_fieldcat 16 'CPUTM' '创建时间' space  '10' space space  space.
2205 ENDFORM.
2206 *&---------------------------------------------------------------------*
2207 *&      Form  FRM_CB_SHEET
2208 *&---------------------------------------------------------------------*
2209 *       text
2210 *----------------------------------------------------------------------*
2211 *      -->P_P_NODE_KEY  text
2212 *----------------------------------------------------------------------*
2213 FORM frm_cb_sheet  USING node_key.
2214   RANGES:rg_pspid FOR proj-pspid,
2215          rg_pspnr FOR prps-posid,
2216          rg_budat FOR cobk-budat.
2217   REFRESH:rg_pspid,rg_budat,rg_pspnr.
2218   DATA:lr_cb_sheet  TYPE REF TO data.
2219   FIELD-SYMBOLS:<lt_cb_sheet> TYPE ANY TABLE.
2220   DATA: l_value TYPE lvc_value,
2221         l_layi  TYPE lvc_t_layi,
2222         l_layn  TYPE lvc_s_layn.
2223 
2224   CALL METHOD tree1->get_outtab_line
2225     EXPORTING
2226       i_node_key     = node_key
2227     IMPORTING
2228       e_outtab_line  = ls_data
2229       e_node_text    = l_value
2230       et_item_layout = l_layi
2231       es_node_layout = l_layn
2232     EXCEPTIONS
2233       node_not_found = 1
2234       OTHERS         = 2.
2235   IF sy-subrc = 0.
2236     CLEAR:gv_text.
2237     gv_text = ls_data-posid && ls_data-post1.
2238     "调用CJI3 传入项目定义 本层WBS 记账日期本年年底
2239     rg_pspid-sign = 'I'.
2240     rg_pspid-option = 'EQ'.
2241     CALL FUNCTION 'CONVERSION_EXIT_KONPD_OUTPUT'
2242       EXPORTING
2243         input  = ls_data-pspnr
2244       IMPORTING
2245         output = rg_pspid-low.
2246     APPEND rg_pspid.
2247     CLEAR rg_pspid.
2248 
2249     "本层WBS
2250     rg_pspnr-sign = 'I'.
2251     rg_pspnr-option = 'EQ'.
2252     rg_pspnr-low = ls_data-posid.
2253     APPEND rg_pspnr.
2254     CLEAR rg_pspnr.
2255     "本年最后一天
2256     rg_budat-sign = 'I'.
2257     rg_budat-option = 'EQ'.
2258     rg_budat-high = p_gjahr && '1231'.
2259     APPEND rg_budat.
2260     CLEAR rg_budat.
2261 
2262     cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false   metadata = abap_false data = abap_true ).
2263     SUBMIT rkpep003
2264       WITH cn_projn IN rg_pspid[]
2265       WITH cn_pspnr IN rg_pspnr[]
2266       WITH p_disvar = '1SAP'
2267       WITH r_budat IN rg_budat[]
2268      EXPORTING LIST TO MEMORY AND RETURN.
2269     IF sy-subrc = 0.
2270       TRY.
2271           cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_cb_sheet ).
2272           ASSIGN lr_cb_sheet->* TO <lt_cb_sheet>.
2273         CATCH cx_salv_bs_sc_runtime_info.
2274       ENDTRY.
2275     ENDIF.
2276     cl_salv_bs_runtime_info=>clear_all( ).
2277     CHECK <lt_cb_sheet> IS ASSIGNED.
2278     IF <lt_cb_sheet> IS NOT INITIAL.
2279       MOVE-CORRESPONDING <lt_cb_sheet> TO lt_cb_sheet1.
2280       LOOP AT lt_cb_sheet1 INTO ls_cb_sheet1.
2281         CALL FUNCTION 'CONVERSION_EXIT_OBART_OUTPUT'
2282           EXPORTING
2283             input  = ls_cb_sheet1-obart
2284           IMPORTING
2285             output = ls_cb_sheet1-obart.
2286         MODIFY lt_cb_sheet1 FROM  ls_cb_sheet1 TRANSPORTING obart.
2287       ENDLOOP.
2288       SORT lt_cb_sheet1 BY gjahr perab.
2289     ENDIF.
2290 
2291   ENDIF.
2292 ENDFORM.
2293 *&---------------------------------------------------------------------*
2294 *&      Form  FRM_ALV_DISPLAY_103
2295 *&---------------------------------------------------------------------*
2296 *       text
2297 *----------------------------------------------------------------------*
2298 *  -->  p1        text
2299 *  <--  p2        text
2300 *----------------------------------------------------------------------*
2301 FORM frm_alv_display_103 .
2302   DATA: ls_layout TYPE lvc_s_layo.
2303   ls_layout-sel_mode = 'D'.
2304 *  ls_layout-cwidth_opt = 'X'.
2305 *  ls_layout-no_toolbar = 'X'.
2306   REFRESH lt_fieldcat_103.
2307   PERFORM build_fieldcat_main_103 CHANGING lt_fieldcat_103.
2308 *  PERFORM frm_sort_field.
2309   CALL METHOD go_grid_103->set_table_for_first_display
2310     EXPORTING
2311       is_layout       = ls_layout
2312       i_save          = 'A'
2313     CHANGING
2314       it_outtab       = lt_cb_sheet1
2315       it_fieldcatalog = lt_fieldcat_103
2316       it_sort         = gt_sort[].
2317 ENDFORM.
2318 *&---------------------------------------------------------------------*
2319 *&      Form  BUILD_FIELDCAT_MAIN_103
2320 *&---------------------------------------------------------------------*
2321 *       text
2322 *----------------------------------------------------------------------*
2323 *      <--P_LT_FIELDCAT_103  text
2324 *----------------------------------------------------------------------*
2325 FORM build_fieldcat_main_103  CHANGING pt_fieldcat TYPE lvc_t_fcat.
2326   DATA: ls_fieldcat TYPE lvc_s_fcat.
2327 
2328   DEFINE  mac_fieldcat.
2329     CLEAR ls_fieldcat.
2330     ls_fieldcat-col_pos = &1.
2331     ls_fieldcat-fieldname = &2.
2332 
2333     ls_fieldcat-scrtext_s =
2334     ls_fieldcat-scrtext_m =
2335     ls_fieldcat-coltext   =
2336     ls_fieldcat-scrtext_l = &3.
2337 
2338     ls_fieldcat-edit = &4.
2339     ls_fieldcat-outputlen = &5.
2340     ls_fieldcat-ref_table =  &6.
2341     ls_fieldcat-ref_field =  &7.
2342     ls_fieldcat-do_sum =  &8.
2343     APPEND ls_fieldcat TO pt_fieldcat.
2344   END-OF-DEFINITION.
2345 
2346   mac_fieldcat 1 'GJAHR' '年度' space  '10' space space  space.
2347   mac_fieldcat 2 'PERAB' '起始期间' space  '10' space space  space.
2348   mac_fieldcat 3 'CPUDT' '创建日期' space  '10' space space  space.
2349   mac_fieldcat 4 'BLDAT' '凭证日期' space  '10' space space  space.
2350   mac_fieldcat 5 'BUDAT' '过账日期' space  '10' space space  space.
2351   mac_fieldcat 6 'OBART' '对象类型' space  '8' space space  space.
2352   mac_fieldcat 7 'OBJID' '对象' space  '20' space space  space.
2353   mac_fieldcat 8 'KSTAR' '成本要素' space  '10' space space  space.
2354   mac_fieldcat 9 'CEL_KTXT' '成本要素名称' space  '20' space space  space.
2355   mac_fieldcat 10 'WKGBTR' '成控范围货币值' space  '10' space space  'X'.
2356   mac_fieldcat 11 'KWAER' 'CO货币' space  '6' space space  space.
2357   mac_fieldcat 12 'WTGBTR' '业务货币值' space  '10' space space  'X'.
2358   mac_fieldcat 13 'TWAER' '交易货币' space  '6' space space  space.
2359   mac_fieldcat 14 'BELNR' '凭证编号' space  '10' space space  space.
2360   mac_fieldcat 15 'BUZEI' '凭证行' space  '10' space space  space.
2361   mac_fieldcat 16 'AWTYP' '参考过程' space  '10' space space  space.
2362   mac_fieldcat 17 'REFBT' '参考凭证类型' space  '10' space space  space.
2363   mac_fieldcat 18 'BLART' '凭证类型' space  '10' space space  space.
2364   mac_fieldcat 19 'REFBN' '参考凭证号码' space  '10' space space  space.
2365   mac_fieldcat 20 'REFBK' '参考公司代码' space  '10' space space  space.
2366   mac_fieldcat 21 'REFGJ' '参考会计年度' space  '10' space space  space.
2367   mac_fieldcat 22 'ORGVG' '源业务处理' space  '10' space space  space.
2368   mac_fieldcat 23 'WSDAT' '起息日' space  '10' space space  space.
2369   mac_fieldcat 24 'EBELN' '采购凭证号' space  '10' space space  space.
2370   mac_fieldcat 25 'EBELP' '行项目' space  '6' space space  space.
2371   mac_fieldcat 26 'EBTXT' '采购订单文本' space  '15' space space  space.
2372   mac_fieldcat 27 'BUKRS' '公司代码' space  '8' space space  space.
2373   mac_fieldcat 28 'OBJART_TXT' '对象类型' space  '8' space space  space.
2374   mac_fieldcat 29 'POSID' 'WBS元素' space  '20' space space  space.
2375   mac_fieldcat 30 'OBJ_TXT' 'CO对象名' space  '10' space space  space.
2376   mac_fieldcat 31 'OBJNR_N1' '辅助科目设置_1' space  '10' space space  space.
2377   mac_fieldcat 32 'GKONT' '冲销科目记账' space  '10' space space  space.
2378   mac_fieldcat 33 'GKOAR' '冲销科目类型' space  '4' space space  space.
2379   mac_fieldcat 34 'GKONT_KTXT' '冲转科目名' space  '4' space space  space.
2380   mac_fieldcat 35 'MATNR' '物料' space  '10' space space  space.
2381   mac_fieldcat 36 'MAT_TXT' '物料描述' space  '10' space space  space.
2382   mac_fieldcat 37 'ZZ00011' '核算供应商' space  '10' space space  space.
2383 ENDFORM.
2384 *&---------------------------------------------------------------------*
2385 *&      Form  FRM_SORT_FIELD
2386 *&---------------------------------------------------------------------*
2387 *       text
2388 *----------------------------------------------------------------------*
2389 *  -->  p1        text
2390 *  <--  p2        text
2391 *----------------------------------------------------------------------*
2392 FORM frm_sort_field .
2393   REFRESH gt_sort.
2394 
2395   CLEAR:gt_sort.
2396   gt_sort-spos = 1.
2397   gt_sort-fieldname = 'OBJID'.
2398   gt_sort-up = 'X'.
2399   APPEND gt_sort.
2400 
2401   CLEAR:gt_sort.
2402   gt_sort-spos = 2.
2403   gt_sort-fieldname = 'KSTAR'.
2404   gt_sort-up = 'X'.
2405   APPEND gt_sort.
2406 ENDFORM.
2407 *&---------------------------------------------------------------------*
2408 *&      Module  INITIAL_ALV_104  OUTPUT
2409 *&---------------------------------------------------------------------*
2410 *       text
2411 *----------------------------------------------------------------------*
2412 MODULE initial_alv_104 OUTPUT.
2413   IF go_grid_104 IS INITIAL.
2414     CREATE OBJECT go_container_104
2415       EXPORTING
2416         container_name = 'SHEET4'.
2417 
2418     CREATE OBJECT go_grid_104
2419       EXPORTING
2420         i_parent = go_container_104.
2421     PERFORM frm_alv_display_104.
2422 
2423 
2424   ELSE.
2425     CALL METHOD go_grid_104->refresh_table_display
2426       EXPORTING
2427         is_stable = stbl.
2428   ENDIF.
2429 ENDMODULE.
2430 *&---------------------------------------------------------------------*
2431 *&      Form  FRM_ALV_DISPLAY_104
2432 *&---------------------------------------------------------------------*
2433 *       text
2434 *----------------------------------------------------------------------*
2435 *  -->  p1        text
2436 *  <--  p2        text
2437 *----------------------------------------------------------------------*
2438 FORM frm_alv_display_104 .
2439   DATA: ls_layout TYPE lvc_s_layo.
2440   ls_layout-sel_mode = 'D'.
2441 *  ls_layout-cwidth_opt = 'X'.
2442 *  ls_layout-no_toolbar = 'X'.
2443   REFRESH lt_fieldcat_103.
2444   "结转展示字段与成本相同
2445   PERFORM build_fieldcat_main_103 CHANGING lt_fieldcat_103.
2446 *  PERFORM frm_sort_field.
2447   CALL METHOD go_grid_104->set_table_for_first_display
2448     EXPORTING
2449       is_layout       = ls_layout
2450       i_save          = 'A'
2451     CHANGING
2452       it_outtab       = lt_jz_sheet
2453       it_fieldcatalog = lt_fieldcat_103
2454       it_sort         = gt_sort[].
2455 ENDFORM.
2456 *&---------------------------------------------------------------------*
2457 *&      Form  FRM_JZ_SHEET
2458 *&---------------------------------------------------------------------*
2459 *       text
2460 *----------------------------------------------------------------------*
2461 *      -->P_P_NODE_KEY  text
2462 *----------------------------------------------------------------------*
2463 FORM frm_jz_sheet  USING   node_key.
2464   RANGES:rg_pspid FOR proj-pspid,
2465          rg_pspnr FOR prps-posid,
2466          rg_budat FOR cobk-budat,
2467          rg_kstar FOR cskb-kstar.
2468   REFRESH:rg_pspid,rg_budat,rg_pspnr,rg_kstar.
2469   DATA:lr_jz_sheet  TYPE REF TO data.
2470   FIELD-SYMBOLS:<lt_jz_sheet> TYPE ANY TABLE.
2471   DATA: l_value TYPE lvc_value,
2472         l_layi  TYPE lvc_t_layi,
2473         l_layn  TYPE lvc_s_layn.
2474 
2475   CALL METHOD tree1->get_outtab_line
2476     EXPORTING
2477       i_node_key     = node_key
2478     IMPORTING
2479       e_outtab_line  = ls_data
2480       e_node_text    = l_value
2481       et_item_layout = l_layi
2482       es_node_layout = l_layn
2483     EXCEPTIONS
2484       node_not_found = 1
2485       OTHERS         = 2.
2486   IF sy-subrc = 0.
2487     CLEAR:gv_text.
2488     gv_text = ls_data-posid && ls_data-post1.
2489     "调用CJI3 传入项目定义 本层WBS 记账日期本年年底 成本要素
2490     rg_pspid-sign = 'I'.
2491     rg_pspid-option = 'EQ'.
2492     CALL FUNCTION 'CONVERSION_EXIT_KONPD_OUTPUT'
2493       EXPORTING
2494         input  = ls_data-pspnr
2495       IMPORTING
2496         output = rg_pspid-low.
2497     APPEND rg_pspid.
2498     CLEAR rg_pspid.
2499 
2500     "本层WBS
2501     rg_pspnr-sign = 'I'.
2502     rg_pspnr-option = 'EQ'.
2503     rg_pspnr-low = ls_data-posid.
2504     APPEND rg_pspnr.
2505     CLEAR rg_pspnr.
2506     "本年最后一天
2507     rg_budat-sign = 'I'.
2508     rg_budat-option = 'EQ'.
2509     rg_budat-high = p_gjahr && '1231'.
2510     APPEND rg_budat.
2511     CLEAR rg_budat.
2512 
2513     "成本要素
2514     rg_kstar-sign = 'I'.
2515     rg_kstar-option = 'EQ'.
2516     rg_kstar-low = '8001990000'.
2517     APPEND rg_kstar.
2518     CLEAR rg_kstar.
2519 
2520 
2521     cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false   metadata = abap_false data = abap_true ).
2522     SUBMIT rkpep003
2523       WITH cn_projn IN rg_pspid[]
2524       WITH cn_pspnr IN rg_pspnr[]
2525       WITH p_disvar = '1SAP'
2526       WITH r_budat IN rg_budat[]
2527       WITH r_kstar IN rg_kstar[]
2528      EXPORTING LIST TO MEMORY AND RETURN.
2529     IF sy-subrc = 0.
2530       TRY.
2531           cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_jz_sheet ).
2532           ASSIGN lr_jz_sheet->* TO <lt_jz_sheet>.
2533         CATCH cx_salv_bs_sc_runtime_info.
2534       ENDTRY.
2535     ENDIF.
2536     cl_salv_bs_runtime_info=>clear_all( ).
2537     CHECK <lt_jz_sheet> IS ASSIGNED.
2538     IF <lt_jz_sheet> IS NOT INITIAL.
2539       MOVE-CORRESPONDING <lt_jz_sheet> TO lt_jz_sheet.
2540       LOOP AT lt_jz_sheet INTO ls_jz_sheet.
2541         CALL FUNCTION 'CONVERSION_EXIT_OBART_OUTPUT'
2542           EXPORTING
2543             input  = ls_jz_sheet-obart
2544           IMPORTING
2545             output = ls_jz_sheet-obart.
2546         MODIFY lt_jz_sheet FROM  ls_jz_sheet TRANSPORTING obart.
2547       ENDLOOP.
2548       SORT lt_jz_sheet BY gjahr perab.
2549     ENDIF.
2550 
2551   ENDIF.
2552 ENDFORM.
2553 *&---------------------------------------------------------------------*
2554 *&      Module  INITIAL_ALV_105  OUTPUT
2555 *&---------------------------------------------------------------------*
2556 *       text
2557 *----------------------------------------------------------------------*
2558 MODULE initial_alv_105 OUTPUT.
2559   IF go_grid_105 IS INITIAL.
2560     CREATE OBJECT go_container_105
2561       EXPORTING
2562         container_name = 'SHEET5'.
2563 
2564     CREATE OBJECT go_grid_105
2565       EXPORTING
2566         i_parent = go_container_105.
2567     PERFORM frm_alv_display_105.
2568 
2569 
2570   ELSE.
2571     CALL METHOD go_grid_105->refresh_table_display
2572       EXPORTING
2573         is_stable = stbl.
2574   ENDIF.
2575 ENDMODULE.
2576 *&---------------------------------------------------------------------*
2577 *&      Form  FRM_ALV_DISPLAY_105
2578 *&---------------------------------------------------------------------*
2579 *       text
2580 *----------------------------------------------------------------------*
2581 *  -->  p1        text
2582 *  <--  p2        text
2583 *----------------------------------------------------------------------*
2584 FORM frm_alv_display_105 .
2585   DATA: ls_layout TYPE lvc_s_layo.
2586   ls_layout-sel_mode = 'D'.
2587 *  ls_layout-cwidth_opt = 'X'.
2588 *  ls_layout-no_toolbar = 'X'.
2589   REFRESH lt_fieldcat_105.
2590   PERFORM build_fieldcat_main_105 CHANGING lt_fieldcat_105.
2591   CALL METHOD go_grid_105->set_table_for_first_display
2592     EXPORTING
2593       is_layout       = ls_layout
2594       i_save          = 'A'
2595     CHANGING
2596       it_outtab       = lt_fp_sheet
2597       it_fieldcatalog = lt_fieldcat_105.
2598 ENDFORM.
2599 *&---------------------------------------------------------------------*
2600 *&      Form  BUILD_FIELDCAT_MAIN_105
2601 *&---------------------------------------------------------------------*
2602 *       text
2603 *----------------------------------------------------------------------*
2604 *      <--P_LT_FIELDCAT_105  text
2605 *----------------------------------------------------------------------*
2606 FORM build_fieldcat_main_105  CHANGING pt_fieldcat TYPE lvc_t_fcat.
2607   DATA: ls_fieldcat TYPE lvc_s_fcat.
2608 
2609   DEFINE  mac_fieldcat.
2610     CLEAR ls_fieldcat.
2611     ls_fieldcat-col_pos = &1.
2612     ls_fieldcat-fieldname = &2.
2613 
2614     ls_fieldcat-scrtext_s =
2615     ls_fieldcat-scrtext_m =
2616     ls_fieldcat-coltext   =
2617     ls_fieldcat-scrtext_l = &3.
2618 
2619     ls_fieldcat-edit = &4.
2620     ls_fieldcat-outputlen = &5.
2621     ls_fieldcat-ref_table =  &6.
2622     ls_fieldcat-ref_field =  &7.
2623     ls_fieldcat-do_sum =  &8.
2624     APPEND ls_fieldcat TO pt_fieldcat.
2625   END-OF-DEFINITION.
2626 
2627   mac_fieldcat 1 'BELNR' '发票凭证号' space  '10' space space  space.
2628   mac_fieldcat 2 'GJAHR' '财年' space  '4' space space  space.
2629   mac_fieldcat 3 'BLART' '凭证类型' space  '4' space space  space.
2630   mac_fieldcat 4 'BLDAT' '凭证日期' space  '10' space space  space.
2631   mac_fieldcat 5 'BUDAT' '过账日期' space  '10' space space  space.
2632   mac_fieldcat 6 'USNAM' '用户名' space  '6' space space  space.
2633   mac_fieldcat 7 'TCODE' '事务代码' space  '8' space space  space.
2634   mac_fieldcat 8 'CPUDT' '录入日期' space  '10' space space  space.
2635   mac_fieldcat 9 'CPUTM' '录入时间' space  '10' space space  space.
2636   mac_fieldcat 10 'VGART' '交易类型' space  '8' space space  space.
2637   mac_fieldcat 11 'XBLNR' '参考凭证号' space  '10' space space  space.
2638   mac_fieldcat 12 'BUKRS' '公司代码' space  '8' space space  space.
2639   mac_fieldcat 13 'LIFNR' '出票方' space  '6' space space  space.
2640   mac_fieldcat 14 'WAERS' '货币码' space  '6' space space  space.
2641   mac_fieldcat 15 'KURSF' '汇率' space  '6' space space  space.
2642   mac_fieldcat 16 'RMWWR' '发票金额' space  '10' space space  space.
2643   mac_fieldcat 17 'BEZNK' '未计划的交货成本' space  '10' space space  space.
2644   mac_fieldcat 18 'WMWST1' '增值税金额' space  '10' space space  space.
2645   mac_fieldcat 19 'mwskz1' '税码' space  '4' space space  space.
2646   mac_fieldcat 20 'BKTXT' '凭证抬头文本' space  '15' space space  space.
2647   mac_fieldcat 21 'ERFNAM' '输入者' space  '10' space space  space.
2648   mac_fieldcat 22 'SGTXT' '文本' space  '15' space space  space.
2649   mac_fieldcat 23 'ZFBDT' '付款起算日期' space  '10' space space  space.
2650 
2651 ENDFORM.
2652 *&---------------------------------------------------------------------*
2653 *&      Form  FRM_FP_SHEET
2654 *&---------------------------------------------------------------------*
2655 *       text
2656 *----------------------------------------------------------------------*
2657 *      -->P_P_NODE_KEY  text
2658 *----------------------------------------------------------------------*
2659 FORM frm_fp_sheet  USING  node_key.
2660   RANGES:r_belnr FOR bkpf-belnr,
2661          r_gjahr FOR bkpf-gjahr.
2662   DATA:lr_fp_sheet  TYPE REF TO data.
2663   FIELD-SYMBOLS:<lt_fp_sheet> TYPE ANY TABLE.
2664   DATA: l_value TYPE lvc_value,
2665         l_layi  TYPE lvc_t_layi,
2666         l_layn  TYPE lvc_s_layn.
2667   REFRESH:r_belnr,r_gjahr.
2668   CALL METHOD tree1->get_outtab_line
2669     EXPORTING
2670       i_node_key     = node_key
2671     IMPORTING
2672       e_outtab_line  = ls_data
2673       e_node_text    = l_value
2674       et_item_layout = l_layi
2675       es_node_layout = l_layn
2676     EXCEPTIONS
2677       node_not_found = 1
2678       OTHERS         = 2.
2679   IF sy-subrc = 0.
2680     CLEAR:gv_text.
2681     gv_text = ls_data-posid && ls_data-post1.
2682     "获取双击行对应的发票、年度
2683     SORT ls_data-pspnr_list BY pspnr.
2684     LOOP AT lt_belnr INTO ls_belnr.
2685       READ TABLE ls_data-pspnr_list INTO DATA(ls_list) WITH KEY pspnr = ls_belnr-ps_psp_pnr BINARY SEARCH.
2686       IF sy-subrc = 0.
2687         CLEAR:r_belnr.
2688         r_belnr-sign = 'I'.
2689         r_belnr-option = 'EQ'.
2690         r_belnr-low = ls_belnr-belnr.
2691         APPEND r_belnr.
2692 
2693         CLEAR:r_gjahr.
2694         r_gjahr-sign = 'I'.
2695         r_gjahr-option = 'EQ'.
2696         r_gjahr-low = ls_belnr-gjahr.
2697         APPEND r_gjahr.
2698       ENDIF.
2699     ENDLOOP.
2700     CLEAR ls_list.
2701     SORT r_belnr.
2702     DELETE ADJACENT DUPLICATES FROM r_belnr COMPARING ALL FIELDS.
2703     SORT r_gjahr.
2704     DELETE ADJACENT DUPLICATES FROM r_gjahr COMPARING ALL FIELDS.
2705     cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false   metadata = abap_false data = abap_true ).
2706     SUBMIT rmmr1mdi
2707       WITH so_bukrs-low = p_bukrs
2708       WITH so_belnr IN r_belnr
2709       WITH so_gjahr IN r_gjahr
2710       WITH p_iv_ov = 'X' "发票已联机校验
2711       WITH p_st_po = 'X'"已过帐
2712       WITH pa_inv = 'X' "发票
2713       WITH pa_cred = 'X'"贷方凭证
2714      EXPORTING LIST TO MEMORY AND RETURN.
2715     IF sy-subrc = 0.
2716       TRY.
2717           cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_fp_sheet ).
2718           ASSIGN lr_fp_sheet->* TO <lt_fp_sheet>.
2719         CATCH cx_salv_bs_sc_runtime_info.
2720       ENDTRY.
2721     ENDIF.
2722     cl_salv_bs_runtime_info=>clear_all( ).
2723     CHECK <lt_fp_sheet> IS ASSIGNED.
2724     IF <lt_fp_sheet> IS NOT INITIAL.
2725       MOVE-CORRESPONDING <lt_fp_sheet> TO lt_fp_sheet.
2726     ENDIF.
2727   ENDIF.
2728 ENDFORM.
2729 *&---------------------------------------------------------------------*
2730 *&      Module  INITIAL_ALV_106  OUTPUT
2731 *&---------------------------------------------------------------------*
2732 *       text
2733 *----------------------------------------------------------------------*
2734 MODULE initial_alv_106 OUTPUT.
2735   IF go_grid_106 IS INITIAL.
2736     CREATE OBJECT go_container_106
2737       EXPORTING
2738         container_name = 'SHEET6'.
2739 
2740     CREATE OBJECT go_grid_106
2741       EXPORTING
2742         i_parent = go_container_106.
2743     PERFORM frm_alv_display_106.
2744 
2745   ELSE.
2746     CALL METHOD go_grid_106->refresh_table_display
2747       EXPORTING
2748         is_stable = stbl.
2749   ENDIF.
2750 ENDMODULE.
2751 *&---------------------------------------------------------------------*
2752 *&      Form  FRM_ALV_DISPLAY_106
2753 *&---------------------------------------------------------------------*
2754 *       text
2755 *----------------------------------------------------------------------*
2756 *  -->  p1        text
2757 *  <--  p2        text
2758 *----------------------------------------------------------------------*
2759 FORM frm_alv_display_106 .
2760   DATA: ls_layout TYPE lvc_s_layo.
2761   ls_layout-sel_mode = 'D'.
2762 *  ls_layout-cwidth_opt = 'X'.
2763 *  ls_layout-no_toolbar = 'X'.
2764   REFRESH lt_fieldcat_106.
2765   PERFORM build_fieldcat_main_106 CHANGING lt_fieldcat_106.
2766   CALL METHOD go_grid_106->set_table_for_first_display
2767     EXPORTING
2768       is_layout       = ls_layout
2769       i_save          = 'A'
2770     CHANGING
2771       it_outtab       = lt_fk_sheet
2772       it_fieldcatalog = lt_fieldcat_106.
2773 ENDFORM.
2774 *&---------------------------------------------------------------------*
2775 *&      Form  BUILD_FIELDCAT_MAIN_106
2776 *&---------------------------------------------------------------------*
2777 *       text
2778 *----------------------------------------------------------------------*
2779 *      <--P_LT_FIELDCAT_106  text
2780 *----------------------------------------------------------------------*
2781 FORM build_fieldcat_main_106  CHANGING pt_fieldcat TYPE lvc_t_fcat.
2782   DATA: ls_fieldcat TYPE lvc_s_fcat.
2783 
2784   DEFINE  mac_fieldcat.
2785     CLEAR ls_fieldcat.
2786     ls_fieldcat-col_pos = &1.
2787     ls_fieldcat-fieldname = &2.
2788 
2789     ls_fieldcat-scrtext_s =
2790     ls_fieldcat-scrtext_m =
2791     ls_fieldcat-coltext   =
2792     ls_fieldcat-scrtext_l = &3.
2793 
2794     ls_fieldcat-edit = &4.
2795     ls_fieldcat-outputlen = &5.
2796     ls_fieldcat-ref_table =  &6.
2797     ls_fieldcat-ref_field =  &7.
2798     ls_fieldcat-do_sum =  &8.
2799     APPEND ls_fieldcat TO pt_fieldcat.
2800   END-OF-DEFINITION.
2801 
2802   mac_fieldcat 1 'BUKRS' '公司代码' space  '10' space space  space.
2803   mac_fieldcat 2 'APPLYNO' '资金支付申请号' space  '10' space space  space.
2804   mac_fieldcat 3 'APPLY_ITEM' '行项目号' space  '10' space space  space.
2805   mac_fieldcat 4 'GJAHR' '财年' space  '10' space space  space.
2806   mac_fieldcat 5 'MONAT' '会计期间' space  '10' space space  space.
2807   mac_fieldcat 6 'KOSTL' '成本中心' space  '10' space space  space.
2808   mac_fieldcat 7 'ZDJLX_TEXT' '单据类型' space  '10' space space  space.
2809   mac_fieldcat 8 'ZFKLX_TEXT' '付款类型' space  '10' space space  space.
2810   mac_fieldcat 9 'TR_TYPE_TEXT' '结算方式' space  '10' space space  space.
2811   mac_fieldcat 10 'BUDGET_NO' '预算码' space  '10' space space  space.
2812   mac_fieldcat 11 'BUDG_TXT' '预算码描述' space  '10' space space  space.
2813   mac_fieldcat 12 'LIFNR' '供应商' space  '10' space space  space.
2814   mac_fieldcat 13 'NAME1' '供应商名称' space  '10' space space  space.
2815   mac_fieldcat 14 'HTKEY' '合同编号' space  '10' space space  space.
2816   mac_fieldcat 15 'HTTXT' '合同名称' space  '10' space space  space.
2817   mac_fieldcat 16 'HTWRB' '合同金额' space  '10' space space  space.
2818   mac_fieldcat 17 'EBELN' '采购凭证号' space  '10' space space  space.
2819   mac_fieldcat 18 'PSPID' '项目定义' space  '10' space space  space.
2820   mac_fieldcat 19 'POST1' '项目定义描述' space  '10' space space  space.
2821   mac_fieldcat 20 'ABWHK' '往来核算科目' space  '10' space space  space.
2822   mac_fieldcat 21 'ZCHKM' '支出户银行科目' space  '10' space space  space.
2823   mac_fieldcat 22 'BRPDT' '申请日期' space  '10' space space  space.
2824   mac_fieldcat 23 'ZJBR' '经办人' space  '10' space space  space.
2825   mac_fieldcat 24 'WAERS' '货币码' space  '10' space space  space.
2826   mac_fieldcat 25 'KURSF' '汇率' space  '10' space space  space.
2827   mac_fieldcat 26 'SQJE_HSB' '申请金额' space  '10' space space  space.
2828   mac_fieldcat 27 'SQJE_BWB' '申请本位币金额' space  '10' space space  space.
2829   mac_fieldcat 28 'HZJE_HSB' '核准金额' space  '10' space space  space.
2830   mac_fieldcat 29 'HZJE_BWB' '核准本位币金额' space  '10' space space  space.
2831   mac_fieldcat 30 'ZYFJZLX' '应付转其它类型' space  '10' space space  space.
2832   mac_fieldcat 31 'ZYFJZJE' '应付转其它金额' space  '10' space space  space.
2833   mac_fieldcat 32 'ZNBWB_TEXT' '内部外部' space  '10' space space  space.
2834   mac_fieldcat 33 'PERSONALFLAG_TEXT' '对公对私' space  '10' space space  space.
2835   mac_fieldcat 34 'PAYER_CNAPS' '付款方开户行' space  '10' space space  space.
2836   mac_fieldcat 35 'PAYER_BANK_NAME' '付款方开户行名称' space  '10' space space  space.
2837   mac_fieldcat 36 'PAYER_NO' '付款方内部账号' space  '10' space space  space.
2838   mac_fieldcat 37 'PAYBANK_NO' '付款方银行账号' space  '10' space space  space.
2839   mac_fieldcat 38 'HKONT' '银行核算科目' space  '10' space space  space.
2840   mac_fieldcat 39 'PAY_DATE' '付款日期' space  '10' space space  space.
2841   mac_fieldcat 40 'URGENT_FLAG_TEXT' '加急标识' space  '10' space space  space.
2842   mac_fieldcat 41 'RECE_ACC_NAME' '收款方户名' space  '10' space space  space.
2843   mac_fieldcat 42 'RECE_CNAPS' '收款方开户行' space  '10' space space  space.
2844   mac_fieldcat 43 'RECE_OPBANK_NAME' '收款方开户行名称' space  '10' space space  space.
2845   mac_fieldcat 44 'RECE_ACNT_NO' '收款方内部账号' space  '10' space space  space.
2846   mac_fieldcat 45 'RECE_ACC_NO' '收款方银行账号' space  '10' space space  space.
2847   mac_fieldcat 46 'ABSTRACT' '摘要' space  '10' space space  space.
2848   mac_fieldcat 47 'STATUS_TEXT' '申请单状态' space  '10' space space  space.
2849   mac_fieldcat 48 'ZJPZH_ZY' '资金占用凭证编号' space  '10' space space  space.
2850   mac_fieldcat 49 'ZJPZH_HY' '资金耗用凭证编号' space  '10' space space  space.
2851   mac_fieldcat 50 'BELNR_N' '会计凭证号码' space  '10' space space  space.
2852   mac_fieldcat 51 'APPLYNO_EX' '原始申请单号' space  '10' space space  space.
2853   mac_fieldcat 52 'ERNAM_T' '创建人' space  '10' space space  space.
2854   mac_fieldcat 53 'ERDAT' '创建日期' space  '10' space space  space.
2855   mac_fieldcat 54 'CHUSER_T' '最后修改人' space  '10' space space  space.
2856   mac_fieldcat 55 'CHDATE' '最后修改日期' space  '10' space space  space.
2857   mac_fieldcat 56 'FILEID_T' '回款单文件ID' space  '10' space space  space.
2858 
2859 ENDFORM.
2860 *&---------------------------------------------------------------------*
2861 *&      Form  FRM_FK_SHEET
2862 *&---------------------------------------------------------------------*
2863 *       text
2864 *----------------------------------------------------------------------*
2865 *      -->P_P_NODE_KEY  text
2866 *----------------------------------------------------------------------*
2867 FORM frm_fk_sheet  USING   node_key.
2868   RANGES:r_bukrs FOR bkpf-bukrs,
2869          r_gjahr FOR bkpf-gjahr,
2870          r_monat FOR bkpf-monat,
2871          r_djlx FOR ztyfit00030-zdjlx,
2872          r_applyno FOR ztyfit00030-applyno.
2873   DATA:lr_fk_sheet  TYPE REF TO data.
2874   FIELD-SYMBOLS:<lt_fk_sheet> TYPE ANY TABLE.
2875   DATA: l_value TYPE lvc_value,
2876         l_layi  TYPE lvc_t_layi,
2877         l_layn  TYPE lvc_s_layn.
2878   REFRESH:r_bukrs,r_gjahr,r_monat,r_djlx,r_applyno.
2879   CALL METHOD tree1->get_outtab_line
2880     EXPORTING
2881       i_node_key     = node_key
2882     IMPORTING
2883       e_outtab_line  = ls_data
2884       e_node_text    = l_value
2885       et_item_layout = l_layi
2886       es_node_layout = l_layn
2887     EXCEPTIONS
2888       node_not_found = 1
2889       OTHERS         = 2.
2890   IF sy-subrc = 0.
2891     CLEAR:gv_text.
2892     gv_text = ls_data-posid && ls_data-post1.
2893 
2894     CLEAR:r_bukrs,r_gjahr,r_monat.
2895     r_bukrs-sign = 'I'.
2896     r_bukrs-option = 'EQ'.
2897     r_bukrs-low = p_bukrs.
2898     APPEND r_bukrs.
2899 
2900     r_gjahr-sign = 'I'.
2901     r_gjahr-option = 'EQ'.
2902     r_gjahr-low = p_gjahr.
2903     APPEND r_gjahr.
2904 
2905     r_monat-sign = 'I'.
2906     r_monat-option = 'EQ'.
2907     r_monat-low = '01'.
2908     r_monat-high = '12'.
2909     APPEND r_monat.
2910 
2911     r_djlx-sign = 'I'.
2912     r_djlx-option = 'EQ'.
2913     r_djlx-low = '01'.
2914     APPEND r_djlx.
2915     "获取上级行对应的资金支付申请单号
2916     SORT ls_data-pspnr_list BY pspnr.
2917     LOOP AT lt_applyno INTO ls_applyno.
2918       READ TABLE ls_data-pspnr_list INTO DATA(ls_list) WITH KEY pspnr = ls_applyno-ps_psp_pnr BINARY SEARCH.
2919       IF sy-subrc = 0.
2920         CLEAR:r_applyno.
2921         r_applyno-sign = 'I'.
2922         r_applyno-option = 'EQ'.
2923         r_applyno-low = ls_applyno-applyno.
2924         APPEND r_applyno.
2925       ENDIF.
2926     ENDLOOP.
2927     CLEAR ls_list.
2928 
2929     cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false   metadata = abap_false data = abap_true ).
2930     SUBMIT ztyfie00010
2931       WITH r1 = 'X' "查询
2932       WITH s_bukrs IN r_bukrs "公司代码
2933       WITH s_gjahr IN r_gjahr "年度
2934       WITH s_monat IN r_monat
2935       WITH s_zdjlx IN r_djlx
2936       WITH s_appno IN r_applyno
2937      EXPORTING LIST TO MEMORY AND RETURN.
2938     IF sy-subrc = 0.
2939       TRY.
2940           cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_fk_sheet ).
2941           ASSIGN lr_fk_sheet->* TO <lt_fk_sheet>.
2942         CATCH cx_salv_bs_sc_runtime_info.
2943       ENDTRY.
2944     ENDIF.
2945     cl_salv_bs_runtime_info=>clear_all( ).
2946     IF <lt_fk_sheet> IS ASSIGNED.
2947       IF <lt_fk_sheet> IS NOT INITIAL.
2948         MOVE-CORRESPONDING <lt_fk_sheet> TO lt_fk_sheet.
2949       ENDIF.
2950     ENDIF.
2951 
2952   ENDIF.
2953 ENDFORM.
2954 
2955 FORM frm_get_ys_sheet_up USING ls_data_tmp.
2956   CLEAR:ls_ys_sheet_tmp,ls_ys_sheet_up,gv_bcky.
2957 *  ls_ys_sheet_tmp = ls_ys_sheet.
2958   "获取不同年度 实际 承诺 剩余计划
2959   PERFORM frm_get_sheet_field_value USING ls_data_tmp CHANGING ls_ys_sheet_tmp.
2960 
2961   "已分配 = 实际 + 承诺 + 剩余计划
2962   ls_ys_sheet_tmp-yfp = ls_ys_sheet_tmp-sj + ls_ys_sheet_tmp-cnz + ls_ys_sheet_tmp-syz.
2963   "可用(统计值) = 预算 - 已分配
2964   ls_ys_sheet_tmp-ky = ls_ys_sheet_tmp-ys - ls_ys_sheet_tmp-yfp.
2965   "本层可用预算
2966   IF ls_ys_sheet_tmp-ys IS INITIAL.
2967     RETURN.
2968   ELSE.
2969     "本层可用预算= 可用 - (直接下级预算 - 直接下级预算不为0的已分配)
2970     PERFORM frm_get_sheet_bcky USING ls_ys_sheet_tmp ls_data_tmp CHANGING gv_bcky.
2971   ENDIF.
2972   ls_ys_sheet_tmp-bcky = ls_ys_sheet_tmp-ky - gv_bcky.
2973 ENDFORM.
2974 *&---------------------------------------------------------------------*
2975 *&      Form  FRM_GET_SUM_SHEET
2976 *&---------------------------------------------------------------------*
2977 *       text
2978 *----------------------------------------------------------------------*
2979 *  -->  p1        text
2980 *  <--  p2        text
2981 *----------------------------------------------------------------------*
2982 FORM frm_get_sum_sheet.
2983   DATA: lv_time  TYPE sy-tabix,
2984         lv_xjys  TYPE rpsco-wlp01,
2985         lv_flg   TYPE c,
2986         lv_above TYPE prps_co-above.
2987   DATA:lv_bcky_up TYPE  rpsco-wlp01.
2988   lv_above = ls_data_sum-above.
2989   lt_data_tmp = lt_data.
2990 *& 1、根据双击行所属项目首层查询BPJA 确定展示条目
2991   READ TABLE lt_data INTO ls_data_tmp WITH KEY pspnr = ls_data_sum-pspnr stufe = 1.
2992   CHECK sy-subrc = 0.
2993   SELECT DISTINCT gjahr
2994     INTO TABLE @DATA(lt_gjahr)
2995     FROM bpja
2996     WHERE objnr = @ls_data_tmp-objnr
2997       AND wrttp = '41'.
2998   SORT lt_gjahr BY gjahr.
2999 
3000   CLEAR:ls_ys_sheet_sum,gv_cnz,gv_syz,gv_yfp,gv_ky,gv_bcky,gv_gjahr,gv_sum_bcky.
3001   SORT lt_ys_year BY objnr gjahr.
3002   SORT lt_cb_sheet BY posid gjahr.
3003 
3004   LOOP AT lt_gjahr INTO DATA(ls_gjahr).
3005     CLEAR:ls_ys_sheet_tmp,ls_data_tmp,lv_flg.
3006 
3007     ls_ys_sheet_sum-gjahr = ls_gjahr-gjahr.
3008     gv_gjahr  = ls_gjahr-gjahr.
3009 
3010     ls_ys_sheet_tmp = ls_ys_sheet_sum.
3011     "获取不同年度 实际 承诺 剩余计划
3012     PERFORM frm_get_sheet_field_value USING ls_data_sum CHANGING ls_ys_sheet_tmp.
3013 
3014     ls_ys_sheet_sum = ls_ys_sheet_tmp.
3015 
3016     "已分配 = 实际 + 承诺 + 剩余计划
3017     ls_ys_sheet_sum-yfp = ls_ys_sheet_sum-sj + ls_ys_sheet_sum-cnz + ls_ys_sheet_sum-syz.
3018     "可用(统计值) = 预算 - 已分配
3019     ls_ys_sheet_sum-ky = ls_ys_sheet_sum-ys - ls_ys_sheet_sum-yfp.
3020     "本层可用预算
3021     CLEAR:gv_bcky,lv_time,lv_xjys.
3022     "本层预算不为0
3023     IF ls_ys_sheet_sum-ys IS NOT INITIAL.
3024       "本层可用预算= 可用 - (直接下级预算 - 直接下级预算不为0的已分配)
3025       PERFORM frm_get_sheet_bcky USING ls_ys_sheet_tmp ls_data_sum CHANGING gv_bcky.
3026 *      PERFORM frm_get_sheet_bcky_sum USING ls_ys_sheet_tmp ls_data_sum CHANGING gv_bcky.
3027       ls_ys_sheet_sum-bcky = ls_ys_sheet_sum-ky - gv_bcky.
3028 *    ELSE.
3029 *      "本层预算为0 找父节点 直到找到
3030 *      "若为首层 没有父节点 则本层预算直接为0
3031 *      IF ls_data_sum-stufe = 1.
3032 *        gv_bcky = 0.
3033 *        ls_ys_sheet_sum-bcky = ls_ys_sheet_sum-ky - gv_bcky.
3034 *      ELSE.
3035 *        DO .
3036 *          lv_time = lv_time + 1.
3037 *          IF lv_time > 10.
3038 *            EXIT.
3039 *          ENDIF.
3040 *          IF gv_bcky <> 0.
3041 *            EXIT.
3042 *          ENDIF.
3043 *
3044 *          READ TABLE lt_data_tmp INTO ls_data_tmp WITH KEY pspnr1 = lv_above."读取成功则ls_data_tmp变为上层WBS结构
3045 *          IF sy-subrc = 0.
3046 *            "找上层
3047 *            PERFORM frm_get_ys_sheet_up USING ls_data_tmp.
3048 *          ENDIF.
3049 *          IF ls_data_tmp-stufe = '1'.
3050 *            EXIT.
3051 *          ENDIF.
3052 *          lv_above = ls_data_tmp-above."赋值后继续寻找ls_data_tmp的上一层
3053 *        ENDDO.
3054 *        ls_ys_sheet_sum-bcky = ls_ys_sheet_tmp-bcky.
3055 *      ENDIF.
3056     ENDIF.
3057 
3058     "*汇总行相关字段
3059     gv_cnz = gv_cnz + ls_ys_sheet_sum-cnz.
3060     gv_syz = gv_syz + ls_ys_sheet_sum-syz.
3061     gv_yfp = gv_yfp + ls_ys_sheet_sum-yfp.
3062     gv_ky  = gv_ky  + ls_ys_sheet_sum-ky.
3063 
3064   ENDLOOP.
3065 
3066 
3067   "最后一行
3068   CLEAR lv_bcky_up.
3069   ls_ys_sheet_sum-gjahr = '全部'.
3070   ls_ys_sheet_sum-ys = ls_data_sum-ys_sum.
3071   ls_ys_sheet_sum-sj = ls_data_sum-cb_sum.
3072   ls_ys_sheet_sum-cnz = gv_cnz."承诺值
3073   ls_ys_sheet_sum-syz = gv_syz."剩余计划值
3074   ls_ys_sheet_sum-yfp = ls_ys_sheet_sum-sj + ls_ys_sheet_sum-cnz + ls_ys_sheet_sum-syz."已分配 = 实际 + 承诺 + 剩余计划
3075   ls_ys_sheet_sum-ky = ls_ys_sheet_sum-ys - ls_ys_sheet_sum-yfp."gv_ky."可用 = 预算 - 已分配
3076   "本层可用
3077 
3078   CLEAR ls_data_tmp.
3079   gv_gjahr  = ls_gjahr-gjahr.
3080   PERFORM frm_get_sheet_bcky_sum USING ls_ys_sheet_sum ls_data_sum CHANGING gv_sum_bcky.
3081 
3082 *  LOOP AT lt_gjahr INTO ls_gjahr.
3083 *    gv_gjahr  = ls_gjahr-gjahr.
3084 *    PERFORM frm_get_sheet_bcky USING ls_ys_sheet_sum ls_data_sum CHANGING lv_bcky_up .
3085 *    gv_sum_bcky = gv_sum_bcky + lv_bcky_up.
3086 *  ENDLOOP.
3087   "最终本层可用
3088   gv_sum_bcky = ls_ys_sheet_sum-ky - gv_sum_bcky.
3089 
3090 ENDFORM.
3091 *&---------------------------------------------------------------------*
3092 *&      Form  FRM_GET_SHEET_BCKY_SUM
3093 *&---------------------------------------------------------------------*
3094 *       text
3095 *----------------------------------------------------------------------*
3096 *      -->P_LS_YS_SHEET  text
3097 *      -->P_LS_DATA  text
3098 *      <--P_GV_BCKY  text
3099 *----------------------------------------------------------------------*
3100 FORM frm_get_sheet_bcky_sum  USING ps_sheet TYPE ty_ys_sheet ps_data TYPE ty_data
3101                              CHANGING ps_bcky TYPE rpsco-wlp01.
3102   DATA:lv_ys    TYPE rpsco-wlp01,
3103        lv_sj    TYPE rpsco-wlp01,
3104        lv_cnz   TYPE rpsco-wlp01,
3105        lv_syz   TYPE rpsco-wlp01,
3106        lv_yfp   TYPE rpsco-wlp01,
3107        lv_ky    TYPE rpsco-wlp01,
3108        lv_xjyfp TYPE rpsco-wlp01. "下级已分配
3109   CLEAR:lv_ys,lv_sj,lv_cnz,lv_syz,lv_xjyfp,ls_ys_year,lv_ky,ps_bcky.
3110   "预算= ps_sheet-ys
3111   "下级 ps_data-pspnr_list
3112   LOOP AT ps_data-pspnr_list INTO DATA(ps_list) .
3113     "直接下级 预算
3114     "获取对象号
3115     READ TABLE lt_data INTO ls_data_tmp WITH KEY posid = ps_list-posid.
3116     IF sy-subrc = 0.
3117       "根据对象号查询下属WBS的预算
3118       READ TABLE lt_bpge INTO ls_bpge
3119          WITH KEY objnr = ls_data_tmp-objnr.
3120       IF sy-subrc = 0.
3121         IF ls_bpge-wlges = 0.
3122           CONTINUE.
3123         ENDIF.
3124       ELSE.
3125         CONTINUE.
3126       ENDIF.
3127     ELSE.
3128       CONTINUE.
3129     ENDIF.
3130    CLEAR ls_data_tmp.
3131     "获取预算不为0对应WBS下的所有节点 已分配
3132       READ TABLE lt_data INTO DATA(ls_data1) WITH KEY pspnr1 = ps_list-pspnr.
3133       IF sy-subrc = 0.
3134         LOOP AT ls_data1-pspnr_list1 INTO DATA(ls_list1).
3135           "实际
3136           READ TABLE lt_cb_sheet INTO ls_cb_sheet
3137              WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
3138           IF sy-subrc = 0.
3139             lv_sj =  ls_cb_sheet-wtgbtr.
3140           ENDIF.
3141 
3142           "承诺值
3143           READ TABLE lt_cnz_sum INTO ls_cnz_sum
3144             WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
3145           IF sy-subrc = 0.
3146             lv_cnz = ls_cnz_sum-cnz.
3147           ENDIF.
3148           "剩余计划值
3149           READ TABLE lt_syz_sum INTO ls_syz_sum
3150                WITH KEY posid = ls_list1-posid gjahr = gv_gjahr BINARY SEARCH.
3151           IF sy-subrc = 0.
3152             lv_syz = ls_syz_sum-cnz.
3153           ENDIF.
3154           "下级已分配=实际+承诺+剩余计划
3155           IF lv_sj IS NOT INITIAL OR lv_cnz IS NOT INITIAL OR lv_syz IS NOT INITIAL.
3156             lv_xjyfp = lv_xjyfp + ( lv_sj + lv_cnz + lv_syz ) .
3157           ENDIF.
3158 
3159           CLEAR:lv_sj,lv_cnz,lv_syz,ls_ys_year.
3160 
3161         ENDLOOP.
3162 
3163       ENDIF.
3164       "直接下级预算汇总 - 直接下级不为0已分配汇总
3165       lv_ky =  ls_bpge-wlges - lv_xjyfp.
3166     "下级不为0可用 汇总
3167     ps_bcky = ps_bcky + lv_ky.
3168     CLEAR:lv_ky,ls_bpge,lv_xjyfp.
3169 
3170   ENDLOOP.
3171 
3172 ENDFORM.
View Code

 

100屏幕:

101屏幕在100屏幕基础上画页签自动生成代码

 

posted @ 2023-07-27 10:06  年轻的小菜鸟  阅读(157)  评论(0编辑  收藏  举报