Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Tree

Former Member
0 Likes
434

Hi Gurus,

Am doing ALV Tree using OOPS. In that I created fieldcatalog for header node. So the item node is not displaying correctly. How to create fieldcatalog for item node? Any Suggesstions please

Points will be awarded

Thanks

Ravi

2 REPLIES 2
Read only

Former Member
0 Likes
394

HI.

refer this code.

report z_sales_tree_rpt .

*******************************************************************

  • Create a tree report of sales orders to deliveries to invoices *

*******************************************************************

include z_sales_tree_rpt_top.

include z_sales_tree_class_def.

selection-screen begin of block a0 with frame title text-001.

*selection-screen comment 5(60) text-c00 modif id sc1.

selection-screen begin of block b5 with frame title text-s05.

select-options:

s_erdat for vbak-erdat,

s_ernam for vbak-ernam.

parameters: s_vbtyp like vbfa-vbtyp_n default 'C'.

selection-screen end of block b5.

selection-screen end of block a0.

----


  • Initialization

----


*at selection-screen output.

  • perform update_sel_screen_attributes.

----


  • Start of Selection

----


start-of-selection.

refresh: itab_data, itab_selection.

perform update_selection_table tables itab_selection.

perform create_input_table tables itab_data

itab_selection.

if not itab_data is initial.

  • create the application object

  • this object is needed to handle the ABAP Objects Events of Controls

create object g_application.

call screen 2000.

else.

message i043(z1).

endif.

end-of-selection.

----


  • Includes

----


include z_sales_tree_forms.

include z_sales_tree_pbo.

include z_sale_tree_pai.

----


  • INCLUDE Z_SALES_TREE_CLASS_DEF *

----


class lcl_application definition.

public section.

methods:

handle_node_double_click

for event node_double_click

of cl_gui_list_tree

importing node_key,

handle_expand_no_children

for event expand_no_children

of cl_gui_list_tree

importing node_key,

handle_item_double_click

for event item_double_click

of cl_gui_list_tree

importing node_key item_name,

handle_button_click

for event button_click

of cl_gui_list_tree

importing node_key item_name,

handle_link_click

for event link_click

of cl_gui_list_tree

importing node_key item_name,

handle_checkbox_change

for event checkbox_change

of cl_gui_list_tree

importing node_key item_name checked.

endclass.

----


  • CLASS lcl_application IMPLEMENTATION

----


  • ........ *

----


class lcl_application implementation.

method handle_node_double_click.

" this method handles the node double click event of the tree

" control instance

" show the key of the double clicked node in a dynpro field

read table itab_data with key node_key = node_key into wa_data.

if sy-subrc = 0.

select single rfmng rfwrt matnr

into (vbfa-rfmng, vbfa-rfwrt, vbfa-matnr)

from vbfa

where vbelv = wa_data-vbeln

and posnv = wa_data-posnn.

endif.

endmethod.

method handle_item_double_click.

" this method handles the item double click event of the tree

" control instance. You have variables node_key and item_name

" show the key of the node and the name of the item

" of the double clicked item in a dynpro field

read table itab_data with key node_key = node_key into wa_data.

if sy-subrc = 0.

select single rfmng rfwrt matnr

into (vbfa-rfmng, vbfa-rfwrt, vbfa-matnr)

from vbfa

where vbelv = wa_data-vbeln

and posnv = wa_data-posnn.

endif.

endmethod.

method handle_link_click.

" this method handles the link click event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked link in a dynpro field

  • g_event = 'LINK_CLICK'.

  • g_node_key = node_key.

  • g_item_name = item_name.

endmethod.

method handle_button_click.

" this method handles the button click event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked button in a dynpro field

  • g_event = 'BUTTON_CLICK'.

  • g_node_key = node_key.

  • g_item_name = item_name.

endmethod.

method handle_checkbox_change.

" this method handles the checkbox_change event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked checkbox in a dynpro field

  • g_event = 'CHECKBOX_CHANGE'.

  • g_node_key = node_key.

  • g_item_name = item_name.

endmethod.

method handle_expand_no_children.

data: node_table type treev_ntab,

node type treev_node,

item_table type item_table_type,

item type mtreeitm.

  • show the key of the expanded node in a dynpro field

  • g_event = 'EXPAND_NO_CHILDREN'.

  • g_node_key = node_key.

if node_key = 'Child2'. "#EC NOTEXT

  • add the children for node with key 'Child2'

  • Node with key 'New3'

clear node.

node-node_key = 'New3'. "#EC NOTEXT

node-relatkey = 'Child2'.

node-relatship = cl_gui_list_tree=>relat_last_child.

append node to node_table.

  • Node with key 'New4'

clear node.

node-node_key = 'New4'. "#EC NOTEXT

node-relatkey = 'Child2'.

node-relatship = cl_gui_list_tree=>relat_last_child.

append node to node_table.

  • Items of node with key 'New3'

clear item.

item-node_key = 'New3'.

item-item_name = '1'.

item-class = cl_gui_list_tree=>item_class_text.

item-length = 11.

item-usebgcolor = 'X'. "

item-text = 'SAPTROX1'.

append item to item_table.

clear item.

item-node_key = 'New3'.

item-item_name = '2'.

item-class = cl_gui_list_tree=>item_class_text.

item-alignment = cl_gui_list_tree=>align_auto.

item-font = cl_gui_list_tree=>item_font_prop.

item-text = 'Comment to SAPTROX1'. "#EC NOTEXT

append item to item_table.

  • Items of node with key 'New4'

clear item.

item-node_key = 'New4'.

item-item_name = '1'.

item-class = cl_gui_list_tree=>item_class_text.

item-length = 11.

item-usebgcolor = 'X'. "

item-text = 'SAPTRIXTROX'.

append item to item_table.

clear item.

item-node_key = 'New4'.

item-item_name = '2'.

item-class = cl_gui_list_tree=>item_class_text.

item-alignment = cl_gui_list_tree=>align_auto.

item-font = cl_gui_list_tree=>item_font_prop.

item-text = 'Comment to SAPTRIXTROX'. "#EC NOTEXT

append item to item_table.

endif.

call method g_tree->add_nodes_and_items

exporting

node_table = node_table

item_table = item_table

item_table_structure_name = 'MTREEITM'

exceptions

failed = 1

cntl_system_error = 3

error_in_tables = 4

dp_error = 5

table_structure_name_not_found = 6.

if sy-subrc <> 0.

message a000(tree_control_msg).

endif.

endmethod.

endclass.

Reward all helpfull answers.

Regards.

Jay

Read only

Former Member
0 Likes
394

Hi Ravi,

look at this Demos:

SALV_DEMO_TREE_DATA_UPDATE

SALV_DEMO_TREE_EVENTS

SALV_DEMO_TREE_FUNCTIONS

SALV_DEMO_TREE_METADATA

SALV_DEMO_TREE_SELECTIONS

SALV_DEMO_TREE_SETTINGS

SALV_DEMO_TREE_SIMPLE

I fill the Fieldcat like this:

FORM TREE_HEADER.

*

SETTINGS = GR_TREE->GET_TREE_SETTINGS( ).

SETTINGS->SET_HIERARCHY_HEADER( 'Material' ).

SETTINGS->SET_HIERARCHY_TOOLTIP( 'Stückliste' ).

SETTINGS->SET_HIERARCHY_SIZE( 50 ).

*

TITLE = SY-TITLE.

SETTINGS->SET_HEADER( TITLE ).

*

ENDFORM. "TREE_HEADER

************************************************************************

FORM TREE_SPALTEN.

*

LR_COLUMNS = GR_TREE->GET_COLUMNS( ).

  • Alle Spalten optimale Breite setzen

LR_COLUMNS->SET_OPTIMIZE( ABAP_TRUE ).

*

TRY.

*

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'STUFE' ).

LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'IDNRK' ).

LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'POSNR' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN->SET_SHORT_TEXT( 'PosNr' ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'MAKTX' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'MENGE' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN->SET_ZERO( ABAP_FALSE ).

LR_COLUMN->SET_TOOLTIP( 'Einsatzmenge' ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'MEINS' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN->SET_SHORT_TEXT( 'ME' ).

  • LR_COLUMN->SET_OPTIMIZED( ABAP_FALSE ).

LR_COLUMN->SET_OUTPUT_LENGTH( '02' ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'EBELN' ).

LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'LIFNR' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'NAME1' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'LAND1' ).

LR_COLUMN->SET_VISIBLE( ABAP_TRUE ).

LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'ORT01' ).

LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).

*

CATCH CX_SALV_NOT_FOUND.

*

ENDTRY.

ENDFORM. "SET_COLUMNS_TECHNICAL

************************************************************************

Hope it helps.

regards, Dieter