Inventory by item group aging report

Sir

We are running ax 2009 and we have multiple units. we want to generate this report unit wise while at the moment this is consolidate report. we have defined the units and inventory dimension. How do I generated this report.

may know the meaning of this code also line wise

void calcAll()
{
Query queryInventTable = new Query();
QueryBuildDataSource queryBuildDatasouceInventTable;
Query queryTmpInventAge = this.queryRun().query();
QueryBuildDataSource queryBuildDatasoucetmpInventAge = queryTmpInventAge.dataSourceTable(tablenum(TmpInventAge));
QueryBuildRange rangeItemGroupIdInventTable, rangeItemGroupIdTmpInventAge;
QueryBuildRange rangeItemIdInventTable, rangeItemIdTmpInventAge;
QueryRun _queryRun;
;
queryBuildDatasouceInventTable = queryInventTable.addDataSource(tablenum(InventTable));

if (!queryBuildDatasoucetmpInventAge)
queryBuildDatasoucetmpInventAge = queryTmpInventAge.addDataSource(tablenum(TmpInventAge));

rangeItemGroupIdTmpInventAge = queryBuildDatasoucetmpInventAge.findRange(fieldnum(TmpInventAge, ItemGroupId));
if (rangeItemGroupIdTmpInventAge)
{
rangeItemGroupIdInventTable = queryBuildDatasouceInventTable.findRange(fieldnum(InventTable, ItemGroupId));
if (!rangeItemGroupIdInventTable)
rangeItemGroupIdInventTable = queryBuildDatasouceInventTable.addRange(fieldnum(InventTable, ItemGroupId));
rangeItemGroupIdInventTable.value(rangeItemGroupIdTmpInventAge.value());
}

rangeItemIdTmpInventAge = queryBuildDatasoucetmpInventAge.findRange(fieldnum(TmpInventAge, ItemId));
if (rangeItemIdTmpInventAge)
{
rangeItemIdInventTable = queryBuildDatasouceInventTable.findRange(fieldnum(InventTable, ItemId));
if (!rangeItemIdInventTable)
rangeItemIdInventTable = queryBuildDatasouceInventTable.addRange(fieldnum(InventTable, ItemId));
rangeItemIdInventTable.value(rangeItemIdTmpInventAge.value());
}

_queryRun = new QueryRun(queryInventTable);
while (_queryRun.next())
{
element.calcInventTable(_queryRun.get(tablenum(InventTable)));
}

}