You can write following Code to check BOM Hierarchy in axapta.
BOMHierarchyCheckJob _BOMHierarchyCheckJob;
BOM BOM;
;
while select BOM
{
_BOMHierarchyCheckJob = BOMHierarchyCheckJob::newBOM(BOM);
_BOMHierarchyCheckJob.run();
}