Yes. the above code is for BPC.
For BW hierarchy info object, please use the following ..
* Constants declaration
CONSTANTS: lc_iobj_hier TYPE rsiobjnm VALUE 'IOBJ_HIER', ---> change this to your Hier Info object name
lc_hier_node TYPE rshienm VALUE 'HIER_NODEID', ---> change to the hierarchy node value you want to select data
lc_a TYPE rsobjvers VALUE 'A',
lc_e TYPE sy-langu VALUE 'E',
lc_02 TYPE rstlevel VALUE '02',
lc_03 TYPE rstlevel VALUE '03',
lc_i TYPE char1 VALUE 'I',
lc_eq TYPE char2 VALUE 'EQ'.
*internal tables declaration
DATA: lt_hier_name TYPE rssh_t_hiedir,
lt_hier TYPE TABLE OF /bic/hhier_iobj.
*work area declaration
DATA: lw_hier_name TYPE rshiedir,
lw_hier TYPE /bic/hhierobj.
1.First get the heirarchy ID's of the Info object IOBJ_HIER are fetched
CALL FUNCTION 'RSSH_HIER_OF_IOBJ_GET'
EXPORTING
i_objvers = lc_a " Active version
i_iobjnm = lc_iobj_hier " Info object Name
i_langu = lc_e
IMPORTING
e_t_rshiedir = lt_hier_name.
CLEAR lw_hier_name.
*
READ TABLE lt_hier_name INTO lw_hier_name
WITH KEY hienm = <pass hierarch node ID > "lc_hier_node
*
2. *The hierarchy table values for the Infoobject HIER_IOBJ
*for which the hierarchy version is Active is fetched.
*
IF sy-subrc IS INITIAL
AND lt_hier[] IS INITIAL.
*
SELECT * FROM /bic/hhier_iobj
INTO TABLE lt_hier
WHERE hieid EQ lw_hier_name-hieid
AND objvers EQ lc_a.
IF sy-subrc IS INITIAL.
SORT ltl_hier
BY iobjnm
nodename
tlevel.
ENDIF. "" SELECT subrc initial ?
ENDIF. "" READ subrc initial ?
Use the above code and modify according to your requirement. Change HIER_OBJ to the hierachy info object technical name where in you want to retreive the data
Thanks,
Uma