2012 Feb 20 5:37 AM
Hello Experts,
We have requirement to retrieve list of wbs elements by providing the WBS element group,(The group which we provide in kjh3 to view the elemnet).
For exp : we are providing a wbs elemnt group in KJH3,and we can view the hiarerchy from it (all of the wbs elements),
they can be retrieved by using table setnode and setleaf but its' better to have soem FM.BAPI.
Is there any bapi/fm which will return the same?
<urgency downgraded> it will be really helpful if we can have some feedback.
similar in case of order also,we have bapiinternalorder but it does return the orders with the help of its' group only.
Is there any other bapi/fm?
Thnaks in Advance.
Edited by: rinkibk on Feb 20, 2012 6:59 AM
Edited by: Suhas Saha on Feb 20, 2012 1:04 PM
Hello Experts,
We have requirement to retrieve list of wbs elements by providing the WBS element group,(The group which we provide in kjh3 to view the elemnet).
For exp : we are providing a wbs elemnt group in KJH3,and we can view the hiarerchy from it (all of the wbs elements),
they can be retrieved by using table setnode and setleaf but its' better to have soem FM.BAPI.
Is there any bapi/fm which will return the same?
<urgency downgraded> it will be really helpful if we can have some feedback.
similar in case of order also,we have bapiinternalorder but it does return the orders with the help of its' group only.
Is there any other bapi/fm?
Thnaks in Advance.
Edited by: rinkibk on Feb 20, 2012 6:59 AM
Edited by: Suhas Saha on Feb 20, 2012 1:04 PM
2012 Feb 20 6:49 AM
2012 Feb 20 7:50 AM
2012 Feb 20 8:10 AM
REPORT zztest_su_set1.
*Data Types For Reading Hierachial Sets and Level Sets
*Must be a Global Types
*Start
CONSTANTS: c_father_of_top LIKE grpdynp-name_coall VALUE '$$TOP$$'.
TYPES: BEGIN OF ty_set_parent,
groupname LIKE grpdynp-name_coall, "name of node
fromvalue LIKE setvalues-from, "From-Value of interval
tovalue LIKE setvalues-to, "To-Value of interval
father LIKE grpdynp-name_coall, "name of father node
descript LIKE sethier-descript,"description of this entry
END OF ty_set_parent.
TYPES: BEGIN OF ty_set_level,
level(4) TYPE n, "level in hierarchy
groupname LIKE grpdynp-name_coall, "name of node
fromvalue LIKE setvalues-from, "From-Value of interval
tovalue LIKE setvalues-to, "To-Value of interval
descript LIKE sethier-descript,"description of this entry
END OF ty_set_level.
TYPES: BEGIN OF ty_set,
level(4) TYPE n, "level in hierarchy
groupname LIKE grpdynp-name_coall, "name of node
fromvalue LIKE setvalues-from, "From-Value of interval
tovalue LIKE setvalues-to, "To-Value of interval
father LIKE grpdynp-name_coall, "name of father node
descript LIKE sethier-descript,"description of this entry
END OF ty_set.
DATA: data_tab_parent TYPE TABLE OF ty_set_parent WITH HEADER LINE.
DATA: data_tab_level TYPE TABLE OF ty_set_level WITH HEADER LINE.
DATA: data_tab_set TYPE TABLE OF ty_set,
data_wa_set TYPE ty_set.
* Tables to read sets
DATA: sethier LIKE sethier OCCURS 0 WITH HEADER LINE, "hierar. nodes
setvalues LIKE setvalues OCCURS 0 WITH HEADER LINE, "hier. values
g_setval_index LIKE sy-tabix, "index for setvalues,
g_int TYPE i,
g_setid LIKE sethier-setid,
g_rc TYPE c,
g_file_string TYPE string,
g_old_file LIKE lgrwo-exp_file.
DATA: it_wbs_set TYPE TABLE OF ty_set.
PARAMETERS : s_wbsgrp TYPE grpdynp-name_coall.
START-OF-SELECTION.
PERFORM get_set USING s_wbsgrp '0110'.
it_wbs_set = data_tab_set[].
*---------------------------------------------------------------------*
* FORM fetch_set *
*---------------------------------------------------------------------*
* Read one hierarchy node from database and copy it to data_tab_parent *
*---------------------------------------------------------------------*
* --> p_setid ID of set *
* --> p_father ID of father *
*---------------------------------------------------------------------*
FORM fetch_set USING p_setid LIKE sethier-setid
p_father LIKE sethier-setid.
DATA: l_header LIKE rgsbs,
lt_single LIKE rgsb1 OCCURS 0 WITH HEADER LINE,
lt_basic LIKE rgsbv OCCURS 0 WITH HEADER LINE.
* Read set from DB
CALL FUNCTION 'G_SET_FETCH'
EXPORTING
no_authority_check = 'X'
setnr = p_setid
IMPORTING
set_header = l_header
TABLES
set_lines_basic = lt_basic
set_lines_single = lt_single.
* Copy set into data tab
CLEAR data_tab_parent.
CALL FUNCTION 'G_SET_DECRYPT_SETID'
EXPORTING
setid = p_setid
IMPORTING
shortname = data_tab_parent-groupname.
IF p_father = space.
data_tab_parent-father = c_father_of_top.
ELSE.
CALL FUNCTION 'G_SET_DECRYPT_SETID'
EXPORTING
setid = p_father
IMPORTING
shortname = data_tab_parent-father.
ENDIF.
data_tab_parent-descript = l_header-title.
APPEND data_tab_parent.
* Copy values into data tab
data_tab_parent-father = data_tab_parent-groupname.
CLEAR: data_tab_parent-groupname, data_tab_parent-descript.
LOOP AT lt_basic.
data_tab_parent-fromvalue = lt_basic-from.
data_tab_parent-tovalue = lt_basic-to.
data_tab_parent-descript = lt_basic-title.
APPEND data_tab_parent.
ENDLOOP.
* Copy subsets into data tab
LOOP AT lt_single.
PERFORM fetch_set USING lt_single-setnr p_setid.
ENDLOOP.
ENDFORM. "fetch_set
2012 Feb 20 8:11 AM
*&---------------------------------------------------------------------*
*& Form GET_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GRPNAME text
*----------------------------------------------------------------------*
FORM get_set USING grpname p_setclass.
CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
EXPORTING
setclass = p_setclass
shortname = grpname
old_setid = g_setid
IMPORTING
new_setid = g_setid.
REFRESH data_tab_parent[].
PERFORM fetch_set USING g_setid space.
REFRESH data_tab_level[].
*Read set
REFRESH: sethier, setvalues.
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
no_rw_info = 'X'
setid = g_setid
TABLES
set_hierarchy = sethier
set_values = setvalues.
* Copy set into data_tab_level
REFRESH data_tab_level.
g_setval_index = 1.
LOOP AT sethier.
CLEAR data_tab_level.
data_tab_level-level = sethier-level.
data_tab_level-groupname = sethier-shortname.
data_tab_level-descript = sethier-descript.
APPEND data_tab_level.
CHECK sethier-vcount > 0.
CLEAR data_tab_level.
data_tab_level-level = sethier-level + 1.
g_int = g_setval_index + sethier-vcount - 1.
LOOP AT setvalues FROM g_setval_index TO g_int.
data_tab_level-fromvalue = setvalues-from.
data_tab_level-tovalue = setvalues-to.
data_tab_level-descript = setvalues-descript.
APPEND data_tab_level.
ENDLOOP.
g_setval_index = g_int + 1.
ENDLOOP.
REFRESH data_tab_set[].
LOOP AT data_tab_parent.
CLEAR data_wa_set.
READ TABLE data_tab_level WITH KEY groupname = data_tab_parent-groupname
fromvalue = data_tab_parent-fromvalue
tovalue = data_tab_parent-tovalue.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING data_tab_parent TO data_wa_set.
data_wa_set-level = data_tab_level-level.
APPEND data_wa_set TO data_tab_set.
ENDIF.
ENDLOOP.
ENDFORM. " GET_SETHi Rinik, Even i faced this issue some long before, i tried searching FM or BAPI to retreive sets in a hierarchial way. But i never found anything except the standard report RGSEX001 or just use RGSEX* . then i copied the code and adjusted on my own . Below is my code, u can just use the code and give ur inputs, it will work
**Sorry for Posting Again, I cant make the format correct in One go. I dont know may be problem with editor..
**Mod, Please check it, and delete my rubbish formatted post.
Regards,
Suji
2012 Feb 20 9:24 AM
Use 'K_HIERARCHY_TABLES_READ' fm to get the requested info. Put a break point here and goto tcode KJH3 to see what parameter are passed.
Nabheet
2012 Feb 21 9:23 AM
Hi All,
I have used the FM K_HIERARCHY_TABLES_READ, this function module will list all of the return data.
But a new problem is there, suppose it returns a value like below, it will be fine for single entry but for range....
From val To val
500. 600..
Now how i will be able to know the wbs element which are present within 500 to 600?
Cna anyone help with any feedback.
Thanks in advance.