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

tree structure

Former Member
0 Likes
834

Hi ,

Kindly can any one help me to built a tree structure in a report.

Actually I hav tables as IFLO-tplnr,pltxt,vwerk. KNVV-kunnr,bzirk,vwerk.

EQUI-equnr,objnr,matnr,sernr. Relating table between knvv and equi is IHPA-parnr,vwerk,objnr.

I have to get the tree structure as follows,

TPLNR(plant)----


PLTXT(desc)

BZIRK(sales dist1)----


(desc)

KUNNR(cust1)----


(name1).

EQUNR(Equ1)----


(Equtu)

Matnr----


(desc)

Sernr----


(desc)

KUNNR(cust2)----


(name2).

BZIRK(Sales dist2)----


(desc)

KUNNR(cust1)----


I already retrieved the data in to one Internal table with all the fields.

now I have to display in tree structure.

after displaying if I double click on node it has to go to concern tcodes (IL03,XD03,EQ03,MM03..)

Kindly help me.

PLEASE...... DONT GIVE STANDARD REFERENCE PROGRAMS TO SEARCH AS I HAVE ALREADY DONE .

KINDLY WRITE me THE CODE FOR HOW TO BUILD THE NODES , HOW TO ADD WITH DESCRIPTIONS AT THE LAST.......,how to handle double click on node....

Thanks & Regards,

Srilakshmi.

6 REPLIES 6
Read only

Former Member
0 Likes
754

structure in a clear way

tplnr----


pltxt

-


bzirk1----


desc

-


bzirk2----


desc

tplnr----


pltxt

-


bzirk1----


desc

-


kunnr1----


name1

-


kunnr2----


name2

-


bzirk2----


desc

tplnr----


pltxt

-


bzirk1----


desc

-


kunnr1----


name1

-


equnr1----


equtx1

-


equnr2----


equtx2

-


kunnr2----


name2

-


bzirk2----


desc

please help me it is very urjent

Srilakshmi

Read only

sharat_chandra
Product and Topic Expert
Product and Topic Expert
0 Likes
754

Hi,

Since you already have the data in the internal table, you can just fill in the tree hierarchy. Now, this depends on the tree model you want to use.

There are different tree models like simple tree model(CL_SIMPLE_TREE_MODEL),

ALV tree model(CL_GUI_ALV_TREE) etc.

For e.g if you use the simple tree model, you should fill your node table which defines the hierarchy of the tree. This node table is of line type "TREEMSNODT".

The fields NODE_KEY and RELATKEY would give the relationship between two nodes. In your example "BZIRK1" would be the NODE_KEY and "TPLNR" would be the RELATKEY.

Please have look at the package

- SLIS where the example programs for tree using CL_GUI_ALV_TREE are given(BCALV_TREE*)

- SEU_TREE_MODEL where example of CL_SIMPLE_TREE_MODEL are given.

Read only

Former Member
0 Likes
754

Hi Sharat,

I did this as follows

FORM add_plant_line USING wa_hfinal TYPE ty_hfinal

p_relatkey TYPE lvc_nkey

CHANGING v_plant_key TYPE lvc_nkey.

DATA : i_item_layout TYPE lvc_t_layi,

wa_item_layout TYPE lvc_s_layi.

CONCATENATE wa_hfinal-tplnr wa_hfinal-space wa_hfinal-pltxt INTO v_node_text1. " SEPARATED BY space.

  • set item-layout

wa_item_layout-t_image = icon_technical_place.

wa_item_layout-fieldname = tree->c_hierarchy_column_name.

wa_item_layout-style = cl_gui_column_tree=>style_intensifd_critical.

APPEND wa_item_layout TO i_item_layout.

*wa_item_layout-fieldname = 'PRODUCTION PLANT'.

  • wa_item_layout-alignment = cl_gui_column_tree=>align_right.

  • append wa_item_layout to i_item_layout.

*

  • add node

v_node_text = v_node_text1.

DATA: wa_node TYPE lvc_s_layn.

wa_node-n_image = ' '.

wa_node-exp_image = ' '.

wa_node-isfolder = 'X'.

CALL METHOD tree->add_node

EXPORTING

i_relat_node_key = p_relatkey

i_relationship = cl_gui_column_tree=>relat_last_child

i_node_text = v_node_text

  • is_outtab_line = wa_hierarchy

is_node_layout = wa_node

it_item_layout = i_item_layout

IMPORTING

e_new_node_key = v_plant_key.

ENDFORM. " add_plant_line

&----


*& Form add_bzirk_line

&----


  • text

----


  • -->P_WA_HIERARCHY text

  • -->P_V_PLANT_KEY text

  • <--P_V_SALESDISTRICT_KEY text

----


FORM add_bzirk_line USING wa_hfinal TYPE ty_hfinal

v_plant_key TYPE lvc_nkey

CHANGING v_salesdistrict_key TYPE lvc_nkey.

DATA: i_item_layout TYPE lvc_t_layi,

wa_item_layout TYPE lvc_s_layi.

CLEAR : v_node_text,

v_node_text1.

CONCATENATE wa_hfinal-bzirk c_text1 'sales district' INTO v_node_text1 . "SEPARATED BY space.

  • set item-layout

wa_item_layout-t_image = icon_technical_place.

wa_item_layout-style = cl_gui_column_tree=>style_intensified.

wa_item_layout-fieldname = tree->c_hierarchy_column_name.

APPEND wa_item_layout TO i_item_layout.

DATA: wa_node TYPE lvc_s_layn.

wa_node-n_image = ' '.

wa_node-exp_image = ' '.

wa_node-isfolder = 'X'.

  • add node

v_node_text = v_node_text1. "wa_hierarchy-bzirk.

CALL METHOD tree->add_node

EXPORTING

i_relat_node_key = v_plant_key

i_relationship = cl_gui_column_tree=>relat_last_child

i_node_text = v_node_text1

  • * is_outtab_line = wa_hierarchy

is_node_layout = wa_node

it_item_layout = i_item_layout

IMPORTING

e_new_node_key = v_salesdistrict_key.

ENDFORM. " add_bzirk_line

&----


*& Form add_customer_line

&----


  • text

----


  • -->P_WA_HFINAL text

  • -->P_V_SALESDISTRICT_KEY text

  • <--P_V_CUSTOMER_KEY text

----


FORM add_customer_line USING wa_hfinal TYPE ty_hfinal

v_salesdistrict_key TYPE lvc_nkey

CHANGING v_customer_key TYPE lvc_nkey.

CLEAR : v_node_text ,

v_node_text1.

  • set item-layout

DATA: i_item_layout TYPE lvc_t_layi,

wa_item_layout TYPE lvc_s_layi.

CONCATENATE wa_hfinal-kunnr c_text1 wa_hfinal-name1 INTO v_node_text1 SEPARATED BY space.

wa_item_layout-fieldname = tree->c_hierarchy_column_name.

wa_item_layout-t_image = icon_customer.

  • ls_item_layout-style = cl_gui_column_tree=>style_emphasized_a.

wa_item_layout-class = cl_gui_column_tree=>item_class_checkbox. "ITEM_CLASS_TEXT .

wa_item_layout-editable = 'X'.

APPEND wa_item_layout TO i_item_layout.

v_node_text = v_node_text1.

DATA: wa_node TYPE lvc_s_layn.

wa_node-n_image = ' '.

wa_node-exp_image = ' '.

wa_node-isfolder = 'X'.

CALL METHOD tree->add_node

EXPORTING

i_relat_node_key = v_salesdistrict_key

i_relationship = cl_gui_column_tree=>relat_last_child

  • is_outtab_line = wa_hierarchy

i_node_text = v_node_text

is_node_layout = wa_node

it_item_layout = i_item_layout

IMPORTING

e_new_node_key = v_customer_key.

ENDFORM. " add_customer_line

But i am not able to give the space between tplntr and pltxt.

To display this I just concatenated using separated by space

but I am not getting space how to do this,

tplnr -


pltxt

bzirk1----


sales district

bzirk----


sal dis 2

how to handle this very urjent yaar please give respose as fast as possible

Regards,

Srilakshmi

Read only

sharat_chandra
Product and Topic Expert
Product and Topic Expert
0 Likes
754

Hi,

I am not sure why the SEPARATED BY space does not work. I could see in your code below that you have commented out the clause.

-->CONCATENATE wa_hfinal-tplnr wa_hfinal-space wa_hfinal-pltxt INTO v_node_text1. " SEPARATED BY space.

Please tryto use this

CONCATENATE wa_hfinal-tplnr wa_hfinal-pltxt INTO v_node_text1

SEPARATED BY space.

This should work.

Read only

Former Member
0 Likes
754

Hi

The following coding was used in a modified version of sample report BCALV_TREE_DEMO where I added a checkbox to each displayed line in the ALV tree.

The event handler method HANDLE_CHECKBOX_CHANGE (event CHECKBOX_CHANGE) looks like this:

METHOD handle_checkbox_change.

BREAK-POINT.

DATA: ld_nkey TYPE lvc_nkey.

DATA: lt_nodes TYPE lvc_t_nkey.

DATA: ld_ntext TYPE lvc_value,

ls_item_u TYPE lvc_s_laci,

ls_item TYPE lvc_s_layi,

lt_items TYPE lvc_t_layi.

ld_nkey = node_key.

" Get subtree of selected node (including selected node)

CALL METHOD tree1->get_subtree

EXPORTING

i_node_key = ld_nkey

IMPORTING

et_subtree_nodes = lt_nodes.

LOOP AT lt_nodes INTO ld_nkey.

CALL METHOD tree1->get_outtab_line

EXPORTING

i_node_key = ld_nkey

IMPORTING

E_OUTTAB_LINE =

e_node_text = ld_ntext

et_item_layout = lt_items

ES_NODE_LAYOUT =

EXCEPTIONS

node_not_found = 1

OTHERS = 2.

IF sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT lt_items INTO ls_item

WHERE ( class = cl_gui_column_tree=>item_class_checkbox

AND editable = 'X' ).

CLEAR: ls_item_u.

MOVE-CORRESPONDING ls_item TO ls_item_u.

ls_item_u-chosen = checked. " mark checkbox

ls_item_u-u_chosen = 'X'. " do update of checkbox

CALL METHOD tree1->change_item

EXPORTING

i_node_key = ld_nkey

i_fieldname = tree1->c_hierarchy_column_name

i_data = ' '

i_u_data = ' '

is_item_layout = ls_item_u

EXCEPTIONS

node_not_found = 1

OTHERS = 2.

IF sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP. " items of a single node

ENDLOOP. " nodes

update frontend

CALL METHOD tree1->frontend_update.

ENDMETHOD. "handle_checkbox_change

Basically you should be able to Cut&Paste this coding and it will work on your ALV tree (CL_GUI_ALV_TREE).

Do not forget to register the required event and set the event handler:

define the events which will be passed to the backend

l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.

APPEND l_event TO lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.

APPEND l_event TO lt_events.

CALL METHOD tree1->set_registered_events

EXPORTING

events = lt_events

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

IF sy-subrc 0.

MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT

ENDIF.

SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.

with regards,

Hema Sundara.

Read only

Former Member
0 Likes
754

Hi

You can use the class CL_GUI_ALV_TREE and method SET_TABLE_FOR_FIRST_DISPLAY.

By performing a where used list on this - it would return sample and demo programs.

SAP also provides demo programs as follows:

BCALV_TEST_SIMPLE_TREE

BCALV_TREE_01

BCALV_TREE_02

BCALV_TREE_03

BCALV_TREE_04

BCALV_TREE_05

BCALV_TREE_06

BCALV_TREE_DEMO

BCALV_TREE_DND

They are easy to follow and if you dont have any complications can even reuse exact code from those programs.

Hope this helps.

http://www.sapdev.co.uk/reporting/alv/alvtree.htm

with regards.

Hema Sundara.