How to find BOM Unit and Inventory Unit for item in Ax 2012

To find BOM Unit and Inventory Unit for item you can get idea from below code sample.This code you can try in your job code editor in axapta.

 InventTable     inventTable;  
   InventUnitId    inventoryUnit,BOMUnit;  
   BOM         bom;  
   ItemId       curItem;  
   ;  
   while select BOM  
     order by itemid  
     where BOM.BOMQty  
   {  
     if(curItem != BOM.ItemId)  
     {  
       curItem = BOM.ItemId;  
       inventTable = InventTable::find(bom.ItemId);  
       inventoryUnit = inventTable.InventUnitId();  
       BOMUnit = bom.UnitId;  
       if(!UnitOfMeasureConverter::canBeConverted(UnitOfMeasure::findBySymbol(inventoryUnit).RecId,  
                       UnitOfMeasure::findBySymbol(BOMUnit).RecId,  
                       inventTable.Product))  
       {  
         if(inventoryUnit != BOMUnit)  
         {  
           info(strFmt("item %1 has bom unit %2, inventory unit %3",inventTable.itemId,BOMUnit,inventoryUnit));  
         }  
       }  
     }  
   }