matinal:SAP ABAP OO ALV TREE和SPLITTER

2023-10-22 09:08:22 浏览数 (2)

OOALV的树和分屏 新建的程序是模块池,要先创建事务码

 年度和期间要弄成NUMC类型

代码语言:javascript复制
CONSTANTS:
gc_month TYPE i VALUE 6.

TYPES:
BEGIN OF gty_head,
gjahr TYPE gjahr,
monat TYPE monat,
bukrs TYPE bukrs,
lgort TYPE t001l-lgort, "公司代码
lgobe TYPE t001l-lgobe, "公司的名称
END OF gty_head.

TYPES:
BEGIN OF gty_tree,
nodeid(10) TYPE c,
text(50) TYPE c,
waers(10) TYPE c,
END OF gty_tree.

FIELD-SYMBOLS:
<gfs_item> TYPE STANDARD TABLE.

DATA:
gs_head TYPE gty_head,
gt_tree TYPE TABLE OF gty_tree.

DATA:
gt_fcode TYPE TABLE OF fcode,
gt_tools TYPE TABLE OF sy-ucomm.

****ALV变量
DATA:
gt_stru_item TYPE lvc_t_fcat,
gs_layout_item TYPE lvc_s_layo,
gs_disvar_item TYPE disvariant,
gcl_grid_item TYPE REF TO cl_gui_alv_grid.

***ALV TREE变量
DATA:
gcl_tree TYPE REF TO cl_gui_alv_tree,
gs_disvar_tree TYPE disvariant,
gs_trhead TYPE treev_hhdr,
gt_stru_tree TYPE lvc_t_fcat.

*屏幕分割容器变量
DATA:
gcl_spc_par TYPE REF TO cl_gui_splitter_container,
gcl_spc_sub TYPE REF TO cl_gui_splitter_container,
gcl_gc_tree TYPE REF TO cl_gui_container,
gcl_gc_item TYPE REF TO cl_gui_container,
gcl_gc TYPE REF TO cl_gui_custom_container.

&---------------------------------------------------------------------
*& ALV 类定义
&---------------------------------------------------------------------
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:

data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells,

handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.

ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION

&---------------------------------------------------------------------
*& ALV TREE 类定义
&---------------------------------------------------------------------
CLASS lcl_event_tree_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:

handle_item_double_click FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING fieldname node_key,

handle_node_double_click FOR EVENT node_double_click OF cl_gui_alv_tree
IMPORTING node_key sender.

ENDCLASS. "LCL_EVENT_TREE_RECEIVER DEFINITION
&---------------------------------------------------------------------
*& ALV类实施
&---------------------------------------------------------------------
CLASS lcl_event_receiver IMPLEMENTATION.

METHOD data_changed_finished.
PERFORM frm_data_changed_finished USING et_good_cells.
ENDMETHOD. "data_changed_finished

METHOD handle_double_click.

ENDMETHOD. "HANDLE_DOUBLE_CLICK

ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
&---------------------------------------------------------------------
*& ALV TREE 类实施
&---------------------------------------------------------------------
CLASS lcl_event_tree_receiver IMPLEMENTATION.

METHOD handle_node_double_click.
DATA: lt_children TYPE lvc_t_nkey.

CALL METHOD sender->get_children
EXPORTING
i_node_key = node_key
IMPORTING
et_children = lt_children
EXCEPTIONS
historic_error = 1
node_key_not_found = 2.

IF NOT lt_children IS INITIAL.

CALL METHOD sender->expand_node
EXPORTING
i_node_key = node_key
i_level_count = 2
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
node_not_found = 4
cannot_expand_leaf = 5.
ENDIF.
ENDMETHOD. "HANDLE_node_double_click

METHOD handle_item_double_click.

DATA: ls_line TYPE gty_tree.

CLEAR ls_line.
CALL METHOD gcl_tree->get_outtab_line
EXPORTING
i_node_key = node_key
IMPORTING
e_outtab_line = ls_line
EXCEPTIONS
node_not_found = 1
OTHERS = 2.

**读取数据
PERFORM frm_set_prctr_data USING ls_line.

ENDMETHOD. "HANDLE_item_double_click

ENDCLASS. "LCL_EVENT_TREE_RECEIVER IMPLEMENTATION
&---------------------------------------------------------------------
*& Module STATUS_9001 OUTPUT
&---------------------------------------------------------------------
*&
&---------------------------------------------------------------------
MODULE status_9001 OUTPUT.
PERFORM frm_set_status.

PERFORM frm_show_data.
ENDMODULE.
&---------------------------------------------------------------------
& Module USER_EXIT INPUT
&---------------------------------------------------------------------
“ text
”----------------------------------------------------------------------
MODULE user_exit INPUT.
CALL FUNCTION ‘DEQUEUE_ALL’.

LEAVE TO SCREEN 0.
ENDMODULE.
&---------------------------------------------------------------------
*& Module SET_ATR_9001 OUTPUT
&---------------------------------------------------------------------
*&
&---------------------------------------------------------------------
MODULE set_atr_9001 OUTPUT.
PERFORM frm_refresh_alv USING gcl_grid_item gt_stru_item gs_layout_item.
ENDMODULE.
&---------------------------------------------------------------------
*& Form FRM_SET_STATUS
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_set_status .
*设置按钮
CLEAR:gt_fcode[].

SET PF-STATUS ‘STATUS9001’ EXCLUDING gt_fcode.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_SHOW_DATA
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_show_data .

PERFORM frm_create_contaner. "屏幕拆分并创建容器

PERFORM frm_create_tree. "创建ALV TREE

PERFORM frm_create_alv_item."创建ITEM ALV

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_CONTANER
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_contaner .
CHECK gcl_gc IS NOT BOUND.

CREATE OBJECT gcl_gc
EXPORTING
“* parent =
container_name = ‘CONTENT’
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc NE 0.
MESSAGE ‘屏幕初始化失败’(026) TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.

CREATE OBJECT gcl_spc_sub
EXPORTING
parent = gcl_gc
rows = 1
columns = 2.

CALL METHOD gcl_spc_sub->set_column_width
EXPORTING
id = 1
width = 20.

CALL METHOD gcl_spc_sub->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = gcl_gc_tree.

CALL METHOD gcl_spc_sub->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = gcl_gc_item.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_TREE
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_tree .
CHECK gcl_tree IS NOT BOUND.

CREATE OBJECT gcl_tree
EXPORTING
”* lifetime =
parent = gcl_gc_tree
“* shellstyle =
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
”* hide_selection =
item_selection = abap_true
no_toolbar = abap_false
no_html_header = abap_true
“* i_print =
”* i_fcat_complete =
“* i_model_mode =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘S’ NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.

PERFORM frm_register_event_tree.

CLEAR: gt_tree.

CALL METHOD gcl_tree->set_table_for_first_display
EXPORTING
”* i_structure_name =
is_variant = gs_disvar_tree
i_save = ‘X’
“* i_default = ‘X’
is_hierarchy_header = gs_trhead
”* is_exception_field =
“* it_special_groups =
”* it_list_commentary =
“* i_logo =
”* i_background_id =
“* it_toolbar_excluding =
”* it_except_qinfo =
CHANGING
it_outtab = gt_tree[] "内表必须为空
“* it_filter =
it_fieldcatalog = gt_stru_tree.

PERFORM frm_delete_hierarchy_tree. "删除层级结构

PERFORM frm_create_hierarchy_tree."创建层级结构

CALL METHOD gcl_tree->frontend_update.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_ALV_ITEM
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_alv_item .
CHECK gcl_grid_item IS NOT BOUND.

CREATE OBJECT gcl_grid_item
EXPORTING
i_parent = gcl_gc_item.

SET HANDLER lcl_event_receiver=>data_changed_finished FOR gcl_grid_item.
SET HANDLER lcl_event_receiver=>handle_double_click FOR gcl_grid_item.

CALL METHOD gcl_grid_item->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified
EXCEPTIONS
error = 1.

CALL METHOD gcl_grid_item->set_table_for_first_display
EXPORTING
is_layout = gs_layout_item
i_save = ‘A’
is_variant = gs_disvar_item
it_toolbar_excluding = gt_tools
CHANGING
it_fieldcatalog = gt_stru_item
it_outtab = <gfs_item>[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ‘ALV显示错误’(003) TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.

&---------------------------------------------------------------------
*& Form FRM_INITIAL
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_initial .
DATA:
lv_memory(30).

CLEAR:
gs_head,
gt_tree,
gt_fcode,
gt_stru_item,
gs_layout_item,
gs_disvar_item,
gcl_grid_item,
gcl_tree,
gs_disvar_tree ,
gs_trhead,
gt_stru_tree,
gcl_spc_par,
gcl_spc_sub,
gcl_gc_tree,
gcl_gc_item,
gt_tools.

gt_tools = VALUE #( ( ‘&LOCAL&DELETE_ROW’ )
( ‘&LOCAL©_ROW’ )
( ‘&LOCAL©’ )
( ‘&LOCAL&APPEND’ )
( ‘&LOCAL&INSERT_ROW’ )
( ‘&LOCAL&CUT’ )
( ‘&LOCAL&PASTE_NEW_ROW’ )
( ‘&LOCAL&PASTE’ )
( ‘&LOCAL&UNDO’ )
( ‘&PRINT’ )
( '&GRAPH ’ )
( ‘&INFO’ )
( ‘&SORT_ASC’ )
( ‘&SORT_DSC’ )
( ‘&REFRESH’ )
).

gs_head = VALUE #( gjahr = COND #( WHEN sy-datum 4(2)   1 GT 12 THEN sy-datum 0(4)   1 ELSE sy-datum 0(4) )
monat = COND #( WHEN sy-datum 4(2)   1 GT 12 THEN ‘01’ ELSE sy-datum 4(2)   1 )
).

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_ITEM_LAYOUT
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_item_layout .
gs_layout_item = VALUE #( cwidth_opt = abap_true
no_merging = abap_true
” zebra = abap_true
stylefname = ‘CELLSTYLES’
).

gs_disvar_item = VALUE #( report = sy-repid
username = sy-uname
log_group = ‘LGIT’
).
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_ITEM_STRU
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> GS_HEAD
&---------------------------------------------------------------------
FORM frm_create_item_stru USING ps_head TYPE gty_head.
DATA:
lv_gjahr TYPE gjahr,
lv_monat TYPE monat,
lv_fname(20),
lv_ftext(30),
lv_tab TYPE REF TO data.

gt_stru_item = VALUE #(
( fieldname = ‘LGORT’ coltext = ‘库存地点’ ref_table = ‘T001’ ref_field = ‘BUKRS’ key = ‘X’ )
( fieldname = ‘LGOBE’ coltext = ‘仓储地点的描述’ ref_table = ‘T001’ ref_field = ‘BUTXT’ key = ‘X’ )
( fieldname = ‘CELLSTYLES’ coltext = ‘’ ref_table = ‘PRHS_ERP_QTYCNVFACT_DATA_ALV’ ref_field = ‘CELLSTYLES’ )
).

DO gc_month TIMES.
IF lv_gjahr IS INITIAL.
lv_gjahr = ps_head-gjahr.
ELSE.
ADD 1 TO lv_monat.
IF lv_monat GT 12.
ADD 1 TO lv_gjahr.
SUBTRACT 12 FROM lv_monat.
ENDIF.
ENDIF.

CLEAR:
lv_fname,
lv_ftext.

lv_fname = lv_gjahr && lv_monat.
lv_ftext = |{ lv_gjahr }年{ lv_monat }月|.

gt_stru_item = VALUE #( BASE gt_stru_item
( fieldname = lv_fname coltext = lv_ftext ref_table = ‘’ ref_field = ‘’ edit = abap_true )
).

ENDDO.
****动态创建内表

CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_stru_item
IMPORTING
ep_table = lv_tab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.

TRY.
IF <gfs_item> IS ASSIGNED.
UNASSIGN <gfs_item>.
ENDIF.

ASSIGN lv_tab->* TO <gfs_item>.
CATCH cx_root INTO DATA(lv_cx).
MESSAGE lv_cx->get_text( ) TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDTRY.

DELETE gt_stru_item WHERE fieldname EQ ‘CELLSTYLES’.

LOOP AT gt_stru_item ASSIGNING FIELD-SYMBOL(<lfs_item>).
<lfs_item>-scrtext_l = <lfs_item>-scrtext_m = <lfs_item>-scrtext_s = <lfs_item>-coltext.
ENDLOOP.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_TREE_STRU
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_tree_stru.

gs_trhead = VALUE #( t_image = icon_contract_account
heading = ‘公司’(001)
tooltip = ‘公司’(001)
width = 18
).

gs_disvar_tree = VALUE #( report = sy-repid
username = sy-uname
log_group = ‘LGTR’
).

gt_stru_tree = VALUE #( ( fieldname = ‘TEXT’
scrtext_l = ‘描述’(002)
scrtext_m = ‘描述’(002)
scrtext_s = ‘描述’(002)
coltext = ‘描述’(002)
outputlen = 40
col_opt = ‘X’
)
( fieldname = ‘WAERS’
scrtext_l = ‘货币码’
scrtext_m = ‘货币码’
scrtext_s = ‘货币码’
coltext = ‘货币码’
outputlen = 40
col_opt = ‘X’
)
).

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_DELETE_HIERARCHY_TREE
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_delete_hierarchy_tree .
CALL METHOD gcl_tree->delete_all_nodes
EXCEPTIONS
failed = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_CREATE_HIERARCHY_TREE
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_create_hierarchy_tree .
DATA:
ls_tree TYPE gty_tree,
lv_resparea(30),
lv_node_p TYPE lvc_nkey,
lv_node_c TYPE lvc_nkey,
lv_node_d TYPE lvc_nkey,
lt_nkey_p TYPE lvc_t_nkey.

*检查区域

SELECT
a~bukrs,
a~butxt,
a~waers,
b~bwkey AS werks,
c~name1 AS wetxt,
d~lgort,
d~lgobe
FROM t001 AS a
INNER JOIN t001k AS b ON a~bukrs = b~bukrs
INNER JOIN t001w AS c ON b~bwkey = c~werks
INNER JOIN t001l AS d ON b~bwkey = d~werks
INTO TABLE @DATA(lt_bukrs).

SORT lt_bukrs BY bukrs werks lgort.

LOOP AT lt_bukrs ASSIGNING FIELD-SYMBOL(<lfs_bukrs>).
CLEAR:ls_tree.
AT NEW bukrs.
ls_tree = VALUE #( nodeid = <lfs_bukrs>-bukrs text = <lfs_bukrs>-butxt waers = <lfs_bukrs>-waers ).
PERFORM frm_add_node USING ls_tree ‘’ CHANGING lv_node_p.
APPEND lv_node_p TO lt_nkey_p.
ENDAT.

AT NEW werks.
ls_tree = VALUE #( nodeid = <lfs_bukrs>-werks text = <lfs_bukrs>-wetxt ).
PERFORM frm_add_node USING ls_tree lv_node_p CHANGING lv_node_c.
ENDAT.

ls_tree = VALUE #( nodeid = <lfs_bukrs>-lgort text = <lfs_bukrs>-lgobe ).
PERFORM frm_add_node USING ls_tree lv_node_c CHANGING lv_node_d.

IF gs_head-lgort IS INITIAL. "给默认值
gs_head-bukrs = <lfs_bukrs>-bukrs.
gs_head-lgort = <lfs_bukrs>-lgort.
gs_head-lgobe = <lfs_bukrs>-lgobe.
ENDIF.
ENDLOOP.

**展开节点
gcl_tree->expand_nodes(
EXPORTING
it_node_key = lt_nkey_p
EXCEPTIONS
failed = 1
cntl_system_error = 2
error_in_node_key_table = 3
dp_error = 4
node_not_found = 5
).
IF sy-subrc <> 0.
“ Implement suitable error handling here
ENDIF.

*读取默认利润中心的数据
PERFORM frm_get_zjjh_data CHANGING gs_head.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_ADD_NODE
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> LS_TREE
*& --> P_
*& <-- LV_NODE_P
&---------------------------------------------------------------------
FORM frm_add_node USING ps_tree TYPE gty_tree
p_node_key
CHANGING ev_node TYPE lvc_nkey.
DATA:
lv_node_text TYPE lvc_value.

CALL FUNCTION ‘CONVERSION_EXIT_ABPSN_OUTPUT’
EXPORTING
input = ps_tree-nodeid
IMPORTING
output = lv_node_text.

CALL METHOD gcl_tree->add_node
EXPORTING
i_relat_node_key = p_node_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = lv_node_text
is_outtab_line = ps_tree
IMPORTING
e_new_node_key = ev_node
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_REGISTER_EVENT_TREE
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_register_event_tree .

DATA:
lt_events TYPE cntl_simple_events.

CLEAR:
lt_events.
CALL METHOD gcl_tree->get_registered_events
IMPORTING
events = lt_events.

lt_events = VALUE #( ( eventid = cl_gui_column_tree=>eventid_node_double_click )
( eventid = cl_gui_column_tree=>eventid_item_double_click )
).

CALL METHOD gcl_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘S’ NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.

SET HANDLER lcl_event_tree_receiver=>handle_item_double_click FOR gcl_tree.

SET HANDLER lcl_event_tree_receiver=>handle_node_double_click FOR gcl_tree.

CALL METHOD cl_gui_cfw=>dispatch .

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_REFRESH_ALV
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> GCL_GRID_ITEM
*& --> GT_STRU_ITEM
*& --> GS_LAYOUT_ITEM
&---------------------------------------------------------------------
FORM frm_refresh_alv USING pcl_grid TYPE REF TO cl_gui_alv_grid
it_stru TYPE lvc_t_fcat
ps_layout TYPE lvc_s_layo.
DATA: ls_stbl TYPE lvc_s_stbl.

ls_stbl-row = abap_true." 基于行的稳定刷新
ls_stbl-col = abap_true." 基于列的稳定刷新

CALL METHOD pcl_grid->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = it_stru.

CALL METHOD pcl_grid->set_frontend_layout
EXPORTING
is_layout = ps_layout.

CALL METHOD pcl_grid->refresh_table_display
EXPORTING
is_stable = ls_stbl.

FREE: ls_stbl.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_DATA_CHANGED_FINISHED
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> ET_GOOD_CELLS
&---------------------------------------------------------------------
FORM frm_data_changed_finished USING it_good_cells TYPE lvc_t_modi.

CHECK it_good_cells[] IS NOT INITIAL.

PERFORM frm_refresh_alv USING gcl_grid_item gt_stru_item gs_layout_item.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_ZJJH_DATA
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& <-- GS_HEAD
&---------------------------------------------------------------------
FORM frm_get_zjjh_data CHANGING ps_head TYPE gty_head.
SELECT SINGLE a~lgort,
a~lgobe
INTO CORRESPONDING FIELDS OF @ps_head
FROM t001l AS a
WHERE a~lgort EQ @ps_head-lgort. "#EC CI_NOORDER

*读取行项目数据
PERFORM frm_get_item_data USING ps_head.

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_ITEM_DATA
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> PS_HEAD
&---------------------------------------------------------------------
FORM frm_get_item_data USING ps_head.
*先读取计划项目
IF <gfs_item> IS ASSIGNED.
CLEAR <gfs_item>.
ENDIF.

SELECT lgort,lgobe
INTO CORRESPONDING FIELDS OF TABLE @<gfs_item>
FROM t001l
ORDER BY lgort ASCENDING. "#EC CI_NOWHERE

ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_SET_PRCTR_DATA
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> LS_LINE
&---------------------------------------------------------------------
FORM frm_set_prctr_data USING ps_tree TYPE gty_tree.
CHECK ps_tree-nodeid NE gs_head-lgort.
gs_head-lgort = ps_tree-nodeid.

PERFORM frm_get_zjjh_data CHANGING gs_head.
LEAVE TO SCREEN 9001.
ENDFORM.

LOAD-OF-PROGRAM.

PERFORM frm_initial.

PERFORM frm_create_item_layout.

PERFORM frm_create_item_stru USING gs_head.

PERFORM frm_create_tree_stru.

0 人点赞