How can I get a nodename (parent) from one Hierarchy

Question: Hello !!

I hope someone can help me.

I'm programing a update rule, And I'm using Hierarchy (0Account), I have one nodename (child), and I want to get from this nodename(child) a nodename (top- parent).
How can i do this ? Is there some function which help to obtain this ?

Thanks !!!

Lal

Answer:
You can check in the InfoObject (0ACCOUNT) what tables are used for the hierarchy data storage. You should use the first table name (something like /BI0/HACCOUNT).

The code should be something like:

Select * from /BI0/HACCOUNT up to 1 rows
where nodename = comm_structure-Account.
if sy-subrc = 0.
i_parentid = /BI0/HACCOUNT-parentid.
endif.
Select single * from /BI0/HACCOUNT
where nodeid = i_parentid.

if sy-subrc = 0.
Result = /BI0/HACCOUNT-nodename.
endif.
Copyright ?2007 - 2008 www.jt77.com