InventoryOnHand AX report with ItemName & Warehouse info.
Today we’ll create a report look like standard Dynamics AX 2009 “InventOnhand” report but with some modifications which are adding ItemName & Warehouse info.
First: Create new report:
Second: Data query:
Third: Data Method:
We need to get the ItemName for the ItemId field in InventDim (make sure) table, so we’ll write some X++ code in data method, let’s start coding:
Then we need to get the Inventory ID and name for the InventLocationId field in InventDim (make sure) table, so we’ll write some X++ code in data method, let’s start coding:
Note: in the code above I didn’t use TableClass::find() method to get information from InventLocation Table, because there are two methods implemented in InvenDim TableClass to get the warehouse information.
Fourth: Design:
First: Create new report:
Second: Data query:
- We need basic information from InventSum & InventDim tables.
- In AOT right click on Tables and choose New window.
- Drag InventSum table into report’s DataSource.
- Drag InvnetDim table into InventSum’s DataSource.
- Create relation between two tables by adding new relation under InventDim DataSource and choose new relation.
- In relation choose InventDimId column in two tables.
Third: Data Method:
We need to get the ItemName for the ItemId field in InventDim (make sure) table, so we’ll write some X++ code in data method, let’s start coding:
- Right click on Report’s Method node and choose New method.
- Rename method to ItemName, make it return str (String) value with size 40 and Display property.
- Inside method we’ll write code to get the ItemName from InventTable for the ItemId in InventSum table.
1
2
3
4
5
6
7
8
9
| //Get Item Name display str 40 ItemName() { str result; InventTable inventTable = InventTable::find(InventSum.ItemId); ; result = inventTable.itemName(); return result; } |
Syntax:
1
1
2
| //ItemId from the InevntSum Table DataSource TableClass tableObject = TableClass::find(InventSum.ItemId); |
- Right click on Report’s Method node and choose New method.
- Rename method to WarehouseName, make it return str (String) value with size 45 and Display property.
- Inside method we’ll write code to get the Inventory ID and name from InventLocation for the InventLocationId in InventDim table.
1
2
3
4
5
6
7
8
9
10
| //Get Warehouse Id and Name display str 45 WarehouseName() { str result; ; result = inventDim.inventLocation().InventLocationId + " " + inventDim.inventLocation().Name; return result; } |
Fourth: Design:
- Right click on Design and choose new design.
- Right click on AutoDesignSpecs and choose Generate specs from Query.
- Drag required field from DataSource & drop them on InventSum_Body.
- Right click on InventSum_Body New –> String, Give it name for example ItemName.
- Right click on ItemName and choose properties.
- In properties window add Label for the field “Item Name” & DataMethod = ItemName.
- Repeat steps 4,5, & 6 but for Warehouse; give it name “Warehouse”, Label = “Warehouse”, & DataMethod = WarehouseName.
- Save report and run it.
No comments:
Post a Comment