Code: Alles auswählen.
data : l_top_key type lvc_nkey.
data : lv_wert2 type i,
pv_wert type i.
data : ls_cosp_all type cosp.
data : l_objnr type cosp-objnr,
l_objnr_last type cosp-objnr,
l_objnr_key type lvc_nkey..
data : l_kstar type cosp-kstar,
l_kstar_last type cosp-kstar,
l_kstar_key type lvc_nkey,
l_last_key type lvc_nkey.
.
check not p_cosp is initial.
refresh gt_cosp_all[].
select * from cosp
into table gt_cosp_all up to g_max rows
where lednr = '00'
and objnr in gr_objnr
and gjahr = p_gjahr
and ( wrttp = '01'
or wrttp = '04' )
and versn = p_versn
and kstar in gr_kstar
and ( beknz = 'S' or
beknz = 'H' ).
sort gt_cosp_all by objnr descending.
if sy-subrc is initial.
endif.
* ADD cosp-wog001 FROM gr_objnr-low TO
* gr_objnr-high GIVING lv_wert2.
*
* ADD lv_wert2 TO pv_wert.
*
call method g_alv_tree->add_node
exporting
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = text-500
importing
e_new_node_key = l_top_key.
loop at gt_cosp_all into ls_cosp_all.
l_kstar = ls_cosp_all-kstar.
l_objnr = ls_cosp_all-objnr.
if l_kstar <> l_kstar_last.
l_kstar_last = l_kstar.
*Kostenart node
perform add_kstar using l_kstar
l_top_key
changing l_kstar_key.
clear l_objnr_last.
endif.
*Objnr node
if l_objnr <> l_objnr_last.
l_objnr_last = l_objnr.
perform add_carrid_line using ls_cosp_all
l_kstar_key
changing l_objnr_key.
endif.
perform add_complete_line using ls_cosp_all
l_kstar_key
changing l_last_key.
-----------------------------------------------------kann mir jemand bei diesem Problem Helfen
Danke
endloop.
Dazu wäre interessant zu wissen, was Du innerhalb der form-routine machst. Wenn ich Dich richtig verstanden habe, werden zusätzliche Einträge an deine Tabelle gt_cosp_all angehängt, was nicht erwünscht ist?!zhamama hat geschrieben: Besonders bei Perform Create_hierarchy: meine Interne Tabelle gt_cosp_all hat nur 6 Datensätze aber innerhalb der Loop Schleife und zwar an der Stelle __perform add_kstar using l_kstar l_top_key changing l_kstar_key.:
(werden die datensätze um 1 addiert d.h anstat 6 --->7 und so weiter
Code: Alles auswählen.
form init_free .
* Erstellung einer CONTAINER for alv_tree
data : l_tree_container_name(30) type c value 'CONTAINER1'.
data : l_hierarchy_header type treev_hhdr.
perform crate_container using l_tree_container_name.
* Tree Contol erstellen.
perform creat_tree_control.
*Bildung der Kopf_Hierarchy.
perform buil_hierarchy_header changing l_hierarchy_header.
*Fieldcatalog
perform build_fieldcatalog.
call method g_alv_tree->set_table_for_first_display
exporting
is_hierarchy_header = l_hierarchy_header
changing
it_fieldcatalog = gt_fieldcatalog
it_outtab = gt_cosp_all.
perform create_hierarchy.
perform event_registrierung.
* Update calculations which were initially defined by field DO_SUM
Code: Alles auswählen.
* of the fieldcatalog. (see build_fieldcatalog).
call method g_alv_tree->update_calculations.
* Send data to frontend.
call method g_alv_tree->frontend_update.
endform. " init_free
Code: Alles auswählen.
FORM init_free .
* Erstellung einer CONTAINER for alv_tree
DATA : l_tree_container_name(30) TYPE c VALUE 'CONTAINER1'.
DATA : l_hierarchy_header TYPE treev_hhdr.
PERFORM crate_container USING l_tree_container_name.
* Tree Contol erstellen.
PERFORM creat_tree_control.
*Bildung der Kopf_Hierarchy.
PERFORM buil_hierarchy_header CHANGING l_hierarchy_header.
*Fieldcatalog
PERFORM build_fieldcatalog.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
CHANGING
it_fieldcatalog = gt_fieldcatalog
it_outtab = gt_cosp_all.
PERFORM create_hierarchy.
PERFORM event_registrierung.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog. (see build_fieldcatalog).
[b]CALL METHOD g_alv_tree->update_calculations.[/b]
* Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.