Hello,
use BUPA_ROLES_GET function modul: BUT100 table is read to get the Business Partner role.
For an organizational unit (BUP004), to know its function (company, purchasing organization, purchasing group), you need to get object ID in order to read view HRV5500A.
Get partner guid using BUPA_NUMBERS_GET. Then, with BP guid, use HR_OBJECTBUPA_GETHROBJECT function modul to get object ID.
Regards.
Laurent.