2006 Nov 29 12:28 PM
Hi friend I have to creat a report to display all the sales order in the node.
When a user selects the particular node (order number), it should expand and give customer details like ship to party sold to party. please help me. I am new to hirearchy reporting.
I dont know how sould I start.
help?
Hi friend I have to creat a report to display all the sales order in the node.
When a user selects the particular node (order number), it should expand and give customer details like ship to party sold to party. please help me. I am new to hirearchy reporting.
I dont know how sould I start.
help?
2006 Nov 29 12:33 PM
You should probably look at the example of REUSEHIER report.
Also, look at the examples of tree controls in DWDM transaction. That should give you a starting point.
Regards,
Ravi
Note - Please mark all the helpful answers
2006 Nov 29 12:37 PM
FU RS_TREE_LIST_DISPLAY
____________________________________________________
Text
Display hierarchy
Functionality
Function module enabling you to display and interactively manipulate hierarchies and graphs in which unused graphical links are displayed in a different color as link nodes.
A hierarchy must exist, at least in its initial state, before you can use this module.
You have three possibilites:
- You can create a hierarchy with root nodes using module
RS_TREE_CREATE.
- You can copy a complete hierarchy to the function group using the
RS_TREE_CONSTRUCT module. All the parent-child relationships must
be calculated explicitly.
- You can use module RS_TREE_SET_CURRENT_TREE to copy a data cluster
which you have already procured using module
RS_TREE_GET_CURRENT_TREE to the function group. This cluster is
already in the correct format for internal display and may not be
changed. This is used exclusively for internal management (INDX
format).
The modules RS_TREE_GET_LINKTAB and RS_TREE_SET_LINKTAB also exist
for graph management.
You have the option of displaying the hierarchy in a list dialog box.
The SCREEN* parameters are used for this.
Parameters
CALLBACK_PROGRAM
CALLBACK_USER_COMMAND
CALLBACK_TEXT_DISPLAY
CALLBACK_MOREINFO_DISPLAY
CALLBACK_COLOR_DISPLAY
CALLBACK_TOP_OF_PAGE
CALLBACK_GUI_STATUS
CALLBACK_CONTEXT_MENU
STATUS
CHECK_DUPLICATE_NAME
COLOR_OF_NODE
COLOR_OF_MARK
COLOR_OF_LINK
COLOR_OF_MATCH
LOWER_CASE_SENSITIVE
MODIFICATION_LOG
NODE_LENGTH
TEXT_LENGTH
TEXT_LENGTH1
TEXT_LENGTH2
RETURN_MARKED_SUBTREE
SCREEN_START_COLUMN
SCREEN_START_LINE
SCREEN_END_COLUMN
SCREEN_END_LINE
SUPPRESS_NODE_OUTPUT
LAYOUT_MODE
USE_CONTROL
F15
Exceptions
Function Group
SEUT
Regards
Prabhu
2006 Nov 29 12:38 PM
hi Abhay,
May be you can make use of the following code, which would display your report in an ALV TREE control....
[code][code]=======================================================
class lcl_tree_event_receiver definition.
public section.
*Define an event handler method for each event you want to react to.
methods handle_node_double_click
for event node_double_click of cl_gui_alv_tree
importing node_key sender.
* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.
endclass. "LCL_TREE_EVENT_RECEIVER
class lcl_tree_event_receiver implementation.
*Implement event handler methods.
method handle_node_double_click.
data: lt_children type lvc_t_nkey.
* first check if the node is a leaf.
call method sender->get_children
exporting i_node_key = node_key
importing et_children = lt_children.
if not lt_children is initial.
call method sender->expand_node
exporting i_node_key = node_key
i_level_count = 2 .
endif.
endmethod.
endclass.
========================================================
perform create_field_catalog changing gt_fieldcatalog .
call screen 9001.
========================================================
*&---------------------------------------------------------------------*
*& Module PBO_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module pbo_9001 output.
set pf-status 'ZSTATUS'.
set titlebar 'ZTITLE'.
if g_alv_tree is initial.
perform init_tree.
call method cl_gui_cfw=>flush
exceptions cntl_system_error = 1
cntl_error = 2.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = 'Automation Queue failure'(013)
txt1 = 'Internal error:'(014)
txt2 = 'A method in the automation queue'(015)
txt3 = 'caused a failure.'(016).
endif.
endif.
endmodule. " PBO_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Form init_tree
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form init_tree .
* create container for alv-tree
data: l_tree_container_name(30) type c,
l_variant type disvariant .
l_tree_container_name = 'CCONTAINER01'.
create object g_custom_container
exporting
container_name = l_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message e208(00) with 'ERROR'(100).
endif.
* create tree control
create object g_alv_tree
exporting
parent = g_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
no_toolbar = ''
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.
if sy-subrc <> 0.
message e208(00) with 'ERROR'. "#EC NOTEXT
endif.
perform build_hierarchy_header changing l_hierarchy_header.
clear gt_alv.
perform comment_build using gt_list_top_of_page.
l_variant-report = sy-repid.
call method g_alv_tree->set_table_for_first_display
exporting
i_save = 'A'
it_list_commentary = gt_list_top_of_page
is_hierarchy_header = l_hierarchy_header
is_variant = l_variant
changing
it_fieldcatalog = gt_fieldcatalog
it_outtab = gt_alv. "table is empty !
perform populate_alv_table tables gt_alv2
gt_covp
gt_prps.
if gt_alv2[] is initial.
message i001(00) with 'No Wage Data Found'.
exit.
endif.
perform create_hierarchy tables gt_alv2.
perform register_events.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog.
call method g_alv_tree->update_calculations.
* Send data to frontend.
call method g_alv_tree->frontend_update.
endform. " init_tree
*&---------------------------------------------------------------------*
*& Module PAI_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module pai_9001 input.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'EXIT' or 'BACK' or 'CANC'.
perform exit_program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
call method cl_gui_cfw=>flush.
endmodule. " PAI_9001 INPUT
=========================================================
*&---------------------------------------------------------------------*
*& Form create_field_catalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form create_field_catalog changing lt_fieldcat type lvc_t_fcat.
data ls_fcat type lvc_s_fcat.
constants:
lc_owaer(5) value 'TWAER'.
* Generates a fieldcatalog according to a given structure.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZSTRWWWAGES'
changing
ct_fieldcat = lt_fieldcat.
define m_fcat_modify.
ls_fcat-do_sum = &1.
ls_fcat-no_out = &2.
ls_fcat-key = &3.
ls_fcat-h_ftype = &4.
end-of-definition.
loop at lt_fieldcat into ls_fcat.
case ls_fcat-fieldname.
when 'VERNA' or 'PSPID' or 'POSID'.
m_fcat_modify space gc_x gc_x space.
when 'POST1' or 'ENAME'.
m_fcat_modify space space space space.
when 'B_WOGBTR' or 'O_WOGBTR' or 'S_WOGBTR' or 'A_WOGBTR'
or 'GR_WOGBTR' or 'ER_NI' or 'ER_PEN' or 'TO_WOGBTR'
or 'VA_WOGBTR' .
m_fcat_modify gc_x space space 'SUM'.
when 'WAG_BUDG' or 'NI_BUDG' .
m_fcat_modify gc_x space space 'SUM'.
when 'OBJ_CURKEY' or 'POST2' or 'ZINDEX'.
m_fcat_modify space gc_x space space.
endcase.
modify lt_fieldcat from ls_fcat.
endloop.
endform. " create_field_catalog
*&---------------------------------------------------------------------*
*& Form FORM build_hierarchy_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_hierarchy_header changing
p_hierarchy_header type treev_hhdr.
p_hierarchy_header-heading = 'Totals/Contract/Intem/Employee'(006).
p_hierarchy_header-tooltip = 'Wages of Employees'(007).
p_hierarchy_header-width = 50.
p_hierarchy_header-width_pix = ''.
endform. " FORM build_hierarchy_header
*&---------------------------------------------------------------------*
*& Form create_hierarchy
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form create_hierarchy tables pt_alv structure zstrwwwages.
data: ls_alv type zstrwwwages,
lv_verna(25),
lv_verna_last(25),
lv_pspid(24),
lv_pspid_last(24),
lv_posid(24),
lv_posid_last(24),
lv_ename(40),
lv_ename_last(40)..
data: lv_verna_key type lvc_nkey,
lv_pspid_key type lvc_nkey,
lv_posid_key type lvc_nkey,
lv_last_key type lvc_nkey,
lv_top_key type lvc_nkey,
lv_ename_key type lvc_nkey.
* sort table according to conceived hierarchy
sort pt_alv by verna pspid posid.
* Define one top node to calculate values for the whole hierarchy.
call method g_alv_tree->add_node
exporting
i_relat_node_key = space
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = text-008
importing
e_new_node_key = lv_top_key.
loop at pt_alv into ls_alv.
lv_verna = ls_alv-verna.
lv_pspid = ls_alv-pspid.
lv_posid = ls_alv-posid.
lv_ename = ls_alv-ename.
* check not lv_verna is initial." or lv_verna_last is initial.
if lv_verna <> lv_verna_last. "on change of Supervisor
lv_verna_last = lv_verna.
* Supervisor nodes
perform add_supervisor using lv_verna
lv_top_key
changing lv_verna_key.
* clear lv_pspid_last because this is a new supervisor
clear lv_pspid_last.
endif.
* Contract nodes:
if lv_pspid <> lv_pspid_last. "on change of contract
lv_pspid_last = lv_pspid.
perform add_contract_line using ls_alv
lv_verna_key
changing lv_pspid_key.
endif.
* Item nodes:
if lv_posid <> lv_posid_last. "on change of Item
lv_posid_last = lv_posid.
perform add_item_line using ls_alv
lv_pspid_key
changing lv_posid_key.
endif.
* Leaf:
perform add_complete_line using ls_alv
lv_posid_key
changing lv_last_key.
endloop.
endform. " create_hierarchy
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form add_supervisor
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_VERNA text
* -->P_LV_TOP_KEY text
* <--P_LV_VERNA_KEY text
*----------------------------------------------------------------------*
form add_supervisor using p_lv_verna
p_lv_top_key
changing p_lv_verna_key.
data: l_node_text type lvc_value,
ls_alv type zstrwwwages.
l_node_text = p_lv_verna.
* add node
call method g_alv_tree->add_node
exporting
i_relat_node_key = p_lv_top_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_alv
importing
e_new_node_key = p_lv_verna_key.
endform. " add_supervisor
*&---------------------------------------------------------------------*
*& Form add_contract_line
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_ALV text
* -->P_LV_VERNA_KEY text
* <--P_LV_PSPID_KEY text
*----------------------------------------------------------------------*
form add_contract_line using p_ls_alv type zstrwwwages
p_lv_verna_key
changing p_lv_pspid_key.
data: l_node_text type lvc_value,
ls_alv type zstrwwwages.
* add node
l_node_text = p_ls_alv-pspid.
call method g_alv_tree->add_node
exporting
i_relat_node_key = p_lv_verna_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_alv
importing
e_new_node_key = p_lv_pspid_key.
endform. " add_contract_line
*&---------------------------------------------------------------------*
*& Form add_employee
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_ENAME text
* -->P_LV_POSID_KEY text
* <--P_LV_ENAME_KEY text
*----------------------------------------------------------------------*
form add_employee using p_ls_alv type zstrwwwages
p_lv_posid_key
changing p_lv_ename_key.
data: l_node_text type lvc_value,
ls_alv type zstrwwwages.
* add node
l_node_text = p_ls_alv-ename.
call method g_alv_tree->add_node
exporting
i_relat_node_key = p_lv_posid_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_alv
importing
e_new_node_key = p_lv_ename_key.
endform. " add_employee
*&---------------------------------------------------------------------*
*& Form add_item_line
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_POSID text
* -->P_LV_PSPID_KEY text
* <--P_LV_POSID_KEY text
*----------------------------------------------------------------------*
form add_item_line using p_ls_alv type zstrwwwages
p_lv_pspid_key
changing p_lv_posid_key.
data: l_node_text type lvc_value,
ls_alv type zstrwwwages.
* add node
l_node_text = p_ls_alv-posid.
call method g_alv_tree->add_node
exporting
i_relat_node_key = p_lv_pspid_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_alv
importing
e_new_node_key = p_lv_posid_key.
endform. " add_item_line
*&---------------------------------------------------------------------*
*& Form add_complete_line
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_ALV text
* -->P_LV_PSPID_KEY text
* <--P_LV_LAST_KEY text
*----------------------------------------------------------------------*
form add_complete_line using p_ls_alv type zstrwwwages
p_lv_posid_key
changing p_lv_last_key.
data: l_node_text type lvc_value.
l_node_text = p_ls_alv-posid.
call method g_alv_tree->add_node
exporting
i_relat_node_key = p_lv_posid_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = p_ls_alv
i_node_text = l_node_text
importing
e_new_node_key = p_lv_last_key.
endform. " add_complete_line
*&---------------------------------------------------------------------*
*& Form exit_program
*&---------------------------------------------------------------------*
* free object and leave program
*----------------------------------------------------------------------*
form exit_program.
call method g_custom_container->free.
leave program.
endform. " exit_program
*&---------------------------------------------------------------------*
*& Form register_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form register_events .
data: lt_events type cntl_simple_events,
l_event type cntl_simple_event,
l_event_receiver type ref to lcl_tree_event_receiver.
call method g_alv_tree->get_registered_events
importing events = lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
append l_event to lt_events.
* Frontend registration(iii):provide new event table to alv tree
call method g_alv_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 e208(00) with 'ERROR'. "#EC NOTEXT
endif.
* Register events on backend (ABAP Objects event handling)
create object l_event_receiver.
set handler l_event_receiver->handle_node_double_click for g_alv_tree.
endform. " register_events
=========================================================[/code][/code]
2006 Nov 29 1:02 PM
Hi Abhay,
try using this FM,
REUSE_ALV_HIERSEQ_LIST_DISPLAY
hope this helps,
~srikant.
2006 Nov 29 1:20 PM
HI Sajan,
The coding was very helpful and I have also rewarded it.
Can u tell me, nw when I create my screen in SE51, wht exactly Do i need to do there? do i need to create a custom container? if yes how many? if other then what?
please help
2006 Nov 29 1:37 PM
Hi,
You can check the simple sample program <b>BALVHD01</b>
Regards
Vijay