2009 Mar 18 1:34 PM
hi gurus,
can any one tell me how to generate the hierarchical (tree ) report for a purticular project.
I should genarate a hierarchical report for all WBS (From top level to lower level WBS ).
With Regards,
Raj.
hi gurus,
can any one tell me how to generate the hierarchical (tree ) report for a purticular project.
I should genarate a hierarchical report for all WBS (From top level to lower level WBS ).
With Regards,
Raj.
2009 Mar 18 1:37 PM
Hi
You can do this in ALV List and Grid Controls.
Regards,
Sunil
2009 Mar 18 1:55 PM
Hi Raj,
First build the tree
data:
fs_node type snodetext,
t_node type standard table of snodetext.
*Display of Tree Structure Starts here
* Node-1 & Level-1 "WBS Elements"
fs_node-name = 'WBS Elements'.
fs_node-nlength = 50.
fs_node-color = 1.
fs_node-tlevel = 1.
append fs_node to t_node.
*Node-2 & Level-2
if not t_infocubes is initial.
fs_node-name = 'Element 1'.
fs_node-nlength = 40.
fs_node-color = 1.
fs_node-tlevel = 2.
fs_node-text1 = w_t.
fs_node-tlength1 = 6.
fs_node-tcolor1 = 1.
append fs_node to t_node.
clear fs_node.
loop at t_infocubes into fs_infocubes.
fs_node-text2 = fs_infocubes-infocube.
fs_node-tlength2 = 40.
fs_node-tcolor2 = 1.
fs_node-text3 = fs_infocubes-txtlg.
fs_node-tlength3 = 40.
fs_node-tcolor3 = 1.
fs_node-tlevel = 3.
append fs_node to t_node.
endloop.
clear fs_node.
endif.Now use the function modules as below:
call function 'RS_TREE_CONSTRUCT'
tables
nodetab = t_node[]
exceptions
tree_failure = 1
id_not_found = 2
wrong_relationship = 3
others = 4.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'RS_TREE_LIST_DISPLAY'
exporting
callback_program = 'YYH_BW_UPGRADE'
callback_user_command = 'USER_COMMAND'
callback_top_of_page = 'TOP_OF_PAGE'
callback_gui_status = 'TREE'.Regards,
Swapna.
2009 Mar 20 10:35 AM
types: begin of str_fin3 ,
prjt_name like proj-pspid , "PROJECT NAME
wbs_element like prps-pspnr,"WBS ELEMENT
nw_no(8) type c, "NETWORK NUMBER
nw_no like afru-aufnr, "NETWORK NUMBER
act_no like afru-VORNR,"ACTIVITY NUMBER
act_desc like afvc-ltxa1,"ACTIVITY DESCRPTION
mat_no like mara-matnr,"MATERIAL NUMBER
mat_desc like makt-maktx,"MATERILA DESCRIPTION
mat_unit like mara-meins , "material unit
planned_wk like afvv-arbei,"Work involved in the activity
act_wk like afvv-ismnw ,"Actual work
unit_wk like afvv-arbeh,"Unit for work
rec_qty like resb-bdmng,"Quantity of Goods Received
req_qty like stko-bmeng, "requirement quantity
mqwp type p decimals 3, "MQWP
variance like resb-bdmng,"VARIANCE
deletion_flag like resb-xloek,"Deleted
matl_group(9) type c,
sort_string like stko-stlal,
plant(4) type c,
amt1 type ck_kwt,
amtt1 type ck_kwt,
end of str_fin3.
data:it_fin3 type table of str_fin3,
wa_fin3 type str_fin3.
This is my final internal Table and I also have parent WBS and child WBS for WBS. i have to do Tree structure based on the WBS Element and pls help me out.
2009 Mar 24 6:01 AM
hi swapna,
thanks , i got the answer. pls tell how to put heading for TREE Report.
with Regards,
Raj.
2009 Mar 18 2:18 PM
Hi raj,
check BCALV_TREE_02 for ALV TREE DISPLAY ( for more clarification debug it )
* my final table structure
***********
BEGIN OF gty_fin ,
posid TYPE ps_posid,
pspnr TYPE ps_intnr,
post1 TYPE ps_post1,
ebeln TYPE ebeln,
ebelp TYPE ebelp ,
name1 TYPE name1,
belnr TYPE mblnr ,
cplan TYPE wtgxxx ,
netpr TYPE ekpo-netpr ,
dmbtr TYPE dmbtr ,
obligo TYPE dmbtr,
vefugt TYPE dmbtr,
verfugbar TYPE dmbtr,
END OF gty_fin ,
***********
* Coding starts here in ur PBO
*do modification accordingly
MODULE status_0100 OUTPUT.
PERFORM init_tree.
ENDMODULE. " STATUS_0100 OUTPUT
FORM init_tree .
* create container for alv-tree
DATA: l_tree_container_name(30) TYPE c.
l_tree_container_name = 'CCONTAINER1'.
CREATE OBJECT g_custom_container
EXPORTING
container_name = l_tree_container_name
* 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 = ' '
no_html_header = 'X'.
DATA l_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
* Hide columns and sum up values initially using the fieldcatalog
PERFORM build_fieldcatalog.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
CHANGING
it_fieldcatalog = git_fieldcatalog
it_outtab = git_edit. "table must be empty !
PERFORM create_hierarchy.
PERFORM register_events.
CALL METHOD g_alv_tree->update_calculations.
* Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.
ENDFORM. "init_tree
" INIT_TREE
*&---------------------------------------------------------------------*
*& Form BUILD_HIERARCHY_HEADER
*&---------------------------------------------------------------------*
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Project Definition'(002).
p_hierarchy_header-tooltip = 'Project Definition'(002).
p_hierarchy_header-width = 35.
p_hierarchy_header-width_pix = ''.
ENDFORM. " BUILD_HIERARCHY_HEADER
*&---------------------------------------------------------------------*
*& Form exit_program
*&---------------------------------------------------------------------*
* free object and leave program
*----------------------------------------------------------------------*
FORM exit_program.
CALL METHOD g_custom_container->free.
LEAVE PROGRAM.
ENDFORM. "exit_program
*&---------------------------------------------------------------------*
*& Form build_fieldcatalog
*&---------------------------------------------------------------------*
FORM build_fieldcatalog.
DATA: lwa_fieldcatalog TYPE lvc_s_fcat.
* The following function module generates a fieldcatalog according
* to a given structure.
REFRESH git_fieldcatalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZDRK' " i created a structure same as final itab.
CHANGING
ct_fieldcat = git_fieldcatalog.
LOOP AT git_fieldcatalog INTO lwa_fieldcatalog.
CASE lwa_fieldcatalog-fieldname.
* hide columns which are already displayed in our tree
WHEN 'POSID' OR 'PSPNR' OR 'EBELN' OR 'EBELP' OR 'POST1'.
lwa_fieldcatalog-no_out = 'X'.
** Do some initial calculations:
** ALV Tree uses the field 'do_sum' to declare that a function
** for the corresponding column shall be calculated.
** Use 'h_ftype' to set the function type (MAX, MIN, SUM, AVG).
WHEN 'DMBTR' OR 'OBLIGO' OR 'VEFUGT' OR 'VERFUGBAR'. " 'CPLAN' OR
lwa_fieldcatalog-do_sum = 'X'.
lwa_fieldcatalog-h_ftype = 'SUM'.
WHEN 'BELNR'.
lwa_fieldcatalog-hotspot = 'X'.
lwa_fieldcatalog-tooltip = 'Invoice Document Number'(003).
ENDCASE.
MODIFY git_fieldcatalog FROM lwa_fieldcatalog.
ENDLOOP.
ENDFORM. " build_fieldcatalog
*&---------------------------------------------------------------------*
*& Form create_hierarchy
*&---------------------------------------------------------------------*
FORM create_hierarchy.
DATA: ls_fin TYPE gty_fin,
lt_fin TYPE TABLE OF gty_fin,
lv_posid1_last TYPE ps_posid,
lv_ebeln TYPE ebeln,
lv_post1 TYPE ps_post1,
lv_ebeln_last TYPE ebeln,
lv_ebelp TYPE ebelp.
DATA: lv_ebeln_key TYPE lvc_nkey,
lv_ebelp_key TYPE lvc_nkey,
lv_last_key TYPE lvc_nkey,
lv_top_key TYPE lvc_nkey,
lv_node_text TYPE lvc_value,
lv_text_psp TYPE char10 .
lv_text_psp = 'Project'(004).
* all my data is in final itab git_fin
lt_fin[] = git_fin .
lv_node_text = gv_proj.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = lv_node_text
IMPORTING
e_new_node_key = lv_top_key.
LOOP AT lt_fin INTO ls_fin.
lv_posid1 = ls_fin-posid.
lv_post1 = ls_fin-post1.
lv_ebeln = ls_fin-ebeln.
lv_ebelp = ls_fin-ebelp.
IF lv_posid1 <> lv_posid1_last. " on change of posid
lv_posid1_last = lv_posid1.
* PO- ebeln nodes
PERFORM add_ebeln USING lv_posid1
lv_post1
lv_top_key
CHANGING lv_ebeln_key.
ENDIF.
IF lv_ebeln <> lv_ebeln_last. " On change of lv_ebeln
lv_ebeln_last = lv_ebeln .
PERFORM add_ebelp USING ls_fin
lv_ebeln_key
lv_ebeln
CHANGING lv_ebelp_key .
ENDIF.
* Leaf:
PERFORM add_complete_line USING ls_fin
lv_ebelp_key
lv_ebelp
CHANGING lv_last_key .
ENDLOOP.
* expand first node initially
CALL METHOD g_alv_tree->expand_node
EXPORTING
i_node_key = lv_top_key.
ENDFORM. " create_hierarchy
*&---------------------------------------------------------------------*
*& Form ADD_EBELN
*&---------------------------------------------------------------------*
FORM add_ebeln USING p_lv_posid1 TYPE ps_posid
p_lv_post1 TYPE ps_post1
p_lv_top_key TYPE lvc_nkey
CHANGING p_lv_ebeln_key TYPE lvc_nkey.
DATA : ls_fin TYPE gty_fin,
lv_node_text TYPE lvc_value ,
lv_text_psp TYPE char11.
lv_text_psp = 'WBS Element'(005).
lv_node_text = p_lv_posid1.
CONCATENATE p_lv_post1 lv_node_text
INTO lv_node_text
SEPARATED BY space.
* 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 = lv_node_text " 'WBS Element'
is_outtab_line = ls_fin
IMPORTING
e_new_node_key = p_lv_ebeln_key.
ENDFORM. " ADD_EBELN
*&---------------------------------------------------------------------*
*& Form ADD_EBELP
*&---------------------------------------------------------------------*
FORM add_ebelp USING p_ls_fin TYPE gty_fin
p_lv_ebeln_key TYPE lvc_nkey
p_lv_ebeln TYPE ebeln
CHANGING p_lv_ebelp_key TYPE lvc_nkey.
DATA : ls_fin TYPE gty_fin ,
lv_node_text TYPE lvc_value,
lv_text_order TYPE char10 .
lv_text_order = 'ORDER '(006).
lv_node_text = p_lv_ebeln .
CONCATENATE lv_text_order lv_node_text
INTO lv_node_text
SEPARATED BY space.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_lv_ebeln_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = lv_node_text " 'EBELN
is_outtab_line = ls_fin
IMPORTING
e_new_node_key = p_lv_ebelp_key.
ENDFORM. " ADD_EBELP
*&---------------------------------------------------------------------*
*& Form ADD_COMPLETE_LINE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_FIN text
* -->P_LV_EBELP_KEY text
* <--P_LV_LAST_KEY text
*----------------------------------------------------------------------*
FORM add_complete_line USING p_ls_fin TYPE gty_fin
p_lv_ebelp_key TYPE lvc_nkey
p_lv_ebelp TYPE ebelp
CHANGING p_lv_last_key TYPE lvc_nkey.
DATA : lv_text_pos TYPE char10,
lv_node_text TYPE lvc_value,
lv_node_layn TYPE lvc_s_layn.
lv_text_pos = 'Position '(007).
lv_node_text = p_lv_ebelp .
IF p_lv_ebelp IS INITIAL .
lv_node_text = 'PLAN'(008) .
lv_node_layn-hidden = 'X'.
ELSE.
CONCATENATE lv_text_pos lv_node_text
INTO lv_node_text
SEPARATED BY space.
ENDIF.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_lv_ebelp_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = p_ls_fin
is_node_layout = lv_node_layn
i_node_text = lv_node_text " Position of item
IMPORTING
e_new_node_key = p_lv_last_key.
CLEAR : lv_node_layn .
ENDFORM. " ADD_COMPLETE_LINE
Regards,
Aby
hope this might be useful.
2009 Mar 21 7:52 AM
can u be more clear ... i am not able to do tree for project system (WBS Based)
2009 Jun 08 6:56 AM
2011 Jul 13 7:12 PM
Hi Shakti raj,
I am working on a similar requirement of tree report for WBS element. Can u please share the code. My gtalk id is
mohnishwithu and skype id is mohnish.lunkad.
Thanks.
Mohnish
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |