Ax2012 Enus Deviv 06 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 48
At a glance
Powered by AI
The key takeaways from this chapter are that reservations are used to commit inventory to transactions, different types of reservations include reserved physical and reserve ordered, and the inventTrans table stores transaction details while inventSum stores summarized data.

Reservations are used to commit inventory quantities to transactions like sales orders. When inventory is reserved, it is deducted from the available quantity. There are different types of reservations like manual, automatic, and explosion reservations.

The two main types of reservations are reserved physical, where the inventory is physically set aside, and reserve ordered, where items are on order but reserved for a transaction. Reservations can be made manually, automatically, or through explosion.

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

CHAPTER 6: USE AND DESIGN OF THE INVENTORY AND WAREHOUSE MANAGEMENT MODULE
Objectives
The objectives are: Describe how reservations and marking are used in the system. Review the inventory transactions and on hand inquiries. Describe the data model for inventory transactions and on hand inventory. Review the structure of the InventOnHand Class. Explain how inventory journals are used. Discuss the inventory journals data model and the structure of the InventJournalCheckPost classes. Describe how quarantine management and quality management are used in the system. Explain inventory blocking. Describe other functionality that is available in the Inventory and warehouse management module.

Introduction
The following sections explain the functionality offered by the Inventory and warehouse management module by describing a series of tasks that are performed by using the module. The following main tasks are supported by the Inventory and warehouse management module. Reservations and marking of inventory Maintenance of item transaction history and on hand inventory Inventory journal transactions such as cycle counts and adjustments Quarantine and quality management Other

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-1

Development IV in Microsoft Dynamics AX 2012

Reservations and Marking


When you enter a sales order line, you can make a commitment against the current stock or an expected future arrival. The reserved quantity will be deducted from the available quantity. This guarantees that the sales order line can be delivered as promised. This concept is known as reservation. When an item is delivered to a customer, the cost value of the item is used to calculate the sales contribution margin. You can allocate a single sale of an item against a specific stock lot to make sure that this calculation is completed correctly. This concept is known as marking. Marking is used on items where the average cost could be misleading because of large fluctuations in the costs of individual stock lots. Marking is a more detailed specification within the combinations of the dimensions set up as financial dimensions. You cannot mark across financial dimensions.

Reservations Overview
There are two basic types of reservations in Microsoft Dynamics AX 2012 reserved physical and reserve ordered. A physical reservation is a hard allocation or reservation. When a transaction is physically reserved, the item is available in the warehouse and it is specifically set aside for the transaction(s) that it is reserved against. The reserve ordered type reservation is a soft allocation. This means the items are currently on order and those specific ordered items are reserved for a specific transaction. When the items are available in inventory, the reservation is changed from reserve ordered to reserved physical. For example, you have created a sales order for 100 widgets. The widgets are not available in inventory. However there are several open purchase orders for the item so that you can make an ordered reservation for the widgets against the sales order. After the widgets are received, the reservation can be updated to a physical reservation. There are three methods for making reservations in Microsoft Dynamics AX 2012. Manual: This type of reservations requires a user to manually select the items to be reserved. Automatic: This type of reservation is created by the system when you are creating transactions. Explosion: This type of reservation is designed specifically for Bill of Materials (BOM) products. The reservation is "exploded" or "expanded" to the line of the BOM not just the header.

6-2

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
Reservations Data Model
The data model for reserved inventory is the same as other types of inventory transactions. When inventory is reserved, the inventory transaction (InventTrans table record) is updated with an Issue status to indicate that the quantities are physically reserved or reserve ordered. Additionally, the InventDimFixed field is updated with the inventDimID for the dimension combination that the inventory is reserved against. The InventSum table is used to make sure that the reserved quantities are available. This requires that negative physical inventory is not allowed and it is controlled by the item model group that is specified on each released product. The control of the availability only considers the dimensions that are marked as part of the physical inventory. NOTE: For more information about the inventory transaction data model, refer to the "Inquiries and Transactions" topic in this course.

Inquiries and Transactions


You can use the Inventory and warehouse module to make inquiries on the actual status and on historic transactions.

On hand
The quantity on hand (available quantity) is a key figure when you make decisions related to a specific item. This information can be supplemented by expected stock movements because of future purchases, production, or sales. One of the main purposes of the Inventory and warehouse management module is to supply this important information; many of the other functions described are intended to maintain this information.

Transactions
Historic transactions are an important source of information because they show all item movements. By knowing the current quantity of an item, and its historic transactions, you can calculate the quantity in stock for any historic date. You can also print an inventory list for a given date, even if the quantities have changed because of transactions after this date.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-3

Development IV in Microsoft Dynamics AX 2012


Inventory Transactions
Many different actions in the system can trigger how you can create inventory transactions. The four primary transactions include the following. Purchase: When purchase orders are created, the expected receipt is recorded in the inventory transactions. The status is changed when the product receipt and invoice are updated. Production: When a production order is created and estimated, the expected receipt and consumption are recorded in the inventory transactions. The status is changed when the raw materials are consumed and when the goods are reported as finished. Project: The Project management and accounting module has several functions to register the consumption of items. A project can be related with a purchase order that contains items bought for the specific project. The project can also have related sales orders to manage the items sold to the customer as a part of the project. The consumption of items can also be registered by using an inventory journal or by creating an item requirement. Sales: When a sales order is created, the expected withdrawal is recorded in the inventory transaction. If the quantity is reserved, this is reflected in the status of the inventory transaction. Item status is changed as picking lists, packing slips, and invoices are updated.

Inventory Transactions Data Model


The InventTrans table is one of the largest tables in Microsoft Dynamics AX, and it keeps growing because of too much redundant data. Microsoft Dynamics AX 2012 begins changing this trend by refactoring parts of the table. Refactoring helps reduce the amount of data that is stored (disk space) and help parts of the table to avoid redundant data and the inherent risk of inconsistent data. The earlier versions of Microsoft Dynamics AX used the InventTransId field name to identify sets of inventory transactions in the InventTrans table to then identify the origin of inventory transactions in the originating tables, such as the SalesLine, PurchLine, ProdTable, or InventJournalTrans table. However, the InventTransId is not the ID for inventory transactions. This field identified the set of inventory transactions related to the inventory transaction originating record. Microsoft Dynamics AX 2012 introduces a new table named InventTransOrigin that uses the RecId as the primary key, and the InventTransId is the alternative or natural key. The new table stores data that is common to all the transactions related to the same inventory transaction originating record.

6-4

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
The following figure shows the data model for inventory transactions.

FIGURE 6.1 INVENTORY TRANSACTIONS DATA MODEL

InventTrans Relationships
The split of the InventTrans table affects code that uses the relationships between the inventory transaction originating tables and the inventory transaction table. The InventTransId field is removed from the InventTrans table and is replaced by the InventTransOrigin field to reference the InventTransOrigin table. Some inventory transaction originating tables keep the InventTransId field; however, the field cannot be used to reference the InventTrans table. All inventory transaction originating records must first be referenced by a record in the InventTransOrigin table that references the InventTrans table. The following code example shows how to do this.
while select inventTransOriginSalesLine where inventTransOriginSalesLine.SalesLineDataAreaId == salesLine.dataAreaId && inventTransOriginSalesLine.SalesLineInventTransId == salesLine.InventTransId join inventTrans where inventTrans.InventTransOrigin == inventTransOriginSalesLine.InventTransOrigin { info(inventTrans.toString()); }

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-5

Development IV in Microsoft Dynamics AX 2012


This change also affects other objects that used the InventTransId field to find, collect, or summarize data from the InventTrans table. Existing tables such as SalesLine still have an InventTransId field. However, we strongly recommend that you use the InventTrans <OriginatingTable> (InventTransOriginSalesLine) table to reference the InventTransOrigin table instead of using the InventTransId field of the <OrginatingTable> (SalesLine) table. In a future release of Microsoft Dynamics AX, the InventTransId fields will be removed from the inventory transaction originating tables. If you rely on those InventTransId fields, you will have to update your code when you upgrade.

InventMovement Class
The InventMovement class is used to wrap a record that is responsible for generating inventory transactions. Sales line, production table, and inventory journal line are examples of tables that hold this type of records. The concept is to make a common presentation of the data attributes and ignore the source. The InventMovement class is extended to cover additional functionality for each source. The following figure shows the class hierarchy for the InventMovement class.

FIGURE 6.2 INVENTMOVEMENT TYPE HIERARCHY BROWSER

The InventUpdate object requires an InventMovement object to specify which data to update. You can use the static method InventMovement::construct() to initialize the object for the actual record.

6-6

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
InventUpdate Class
You can use the InventUpdate class to make a specific change to the state of the data. Reservation, Pick, and Delivery are examples of state changes covered by this class. InventUpdate is extended to cover each update. The following figure shows the class hierarchy for the InventUpdate class.

FIGURE 6.3 INVENTUPDATE TYPE HIERARCHY BROWSER

The InventUpdate object is initialized with a specified InventMovement object. The specification of dimension values is specified as additional parameters, when the InventUpdate object is instantiated. When the object is initialized the object method updateNow() performs the update. Each InventUpd_ class has a series of static methods with a prefix new. They are used to initialize the object that has a specific set of parameters. The following pattern is typically used when you work with InventUpdate.
inventUpd_Reservation = InventUpd_Reservation::newMovement(movement, reservation, mayBeReduced); inventUpd_Reservation.updateNow();

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-7

Development IV in Microsoft Dynamics AX 2012


Inventory Statuses
The inventSum table contains the sum of all inventTrans for each combination of ItemId and InventDimId. InventTrans has two fields that specify the status of the transactionStatusReceipt and StatusIssue. InventSum has several fields that specify the quantity of items of a different status.

FIGURE 6.4 INVENTSUM AND INVENTTRANS STATUS AND QUANTITY FIELD RELATIONSHIPS

Designs that use InventSum are preferred for performance reasons, because it prevents the summing of transactions during both the calculation of available quantities and the control of negative inventory. InventSum contains the sum of all inventory transactions. To calculate the inventory status on a date in the past, you first have to adjust the figures found in InventSum with the transactions updated after the date in question. The information in InventSum is updated every time that a transaction is committed. When you are in a transaction, the table will not reflect the changes that you made in the current transaction. If the InventOnHand class is used to fetch the data from InventSum, the changes from the current transaction will be included. Each record in InventTrans contains several dates. DateExpected: Expected date of the physical movement. DateInvent: Date the transaction is registered or picked on. DatePhysical: Date of the physical movement (product receipt, packing slip, or report as finished).

6-8

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
DateFinancial: Date of the financial movement (vendor invoice, sales order invoice, or ending of a production order). DateStatus: Date the inventory status (status issue or status receipt) is last updated. DateClosed: Date the transactions are financially closed on.

InventOnHand Class
The InventSum table contains consolidated figures for each item and dimension combination. The content of this table is redundant to the data in InventTrans. The reason for this design is to increase performance when calculating quantity on hand. InventOnHand class is used to wrap the InventSum table and should be used to retrieve the information. The class has several different static methods that are used to initialize the object. You can use the static method InventOnHand::newItemDim to retrieve the consolidated quantities for the specified dimension values. The following code sample shows how to call this method.
ItemId itemId; InventBatchId inventBatchId; InventDim inventDimCriteria; InventDimParm inventDimParm; InventOnHand inventOnHand; inventDimCriteria.clear(); inventDimCriteria.inventBatchId = inventBatchId; inventDimParm.clear(); inventDimParm.InventBatchIdFlag = NoYes::Yes; InventOnHand = InventOnHand::newItemDim(itemId, inventDimCriteria, inventDimParm); info(strFmt(The quantity available is %1, inventOnHand.availPhysical()));

InventDimOnHand Class
You can use the InventOnHand class to calculate consolidated figures for one specification of an item ID and a dimension combination. You can use the InventDimOnHand class to have individual figures for a more detailed specification, than the one being used to limit the query. The following sample shows how to obtain the physical quantity available for each item included on a specific inventLocationId and wmsLocationId.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-9

Development IV in Microsoft Dynamics AX 2012


InventDimOnHand inventDimOnHand; InventDimOnHandIterator inventDimOnHandIterator; InventDimOnHandMember inventDimOnHandMember; InventDim inventDimCriteria; InventDimParm inventDimParmCriteria; InventDimParm inventDimParmOnHand; inventDimCriteria.clear(); inventDimCriteria.InventLocationId = inventLocationId; inventDimCriteria.wmsLocationId = wmsLocationId; inventDimParmCriteria.initFromInventDim(inventDimCriteria); inventDimParmOnHand.clear(); inventDimParmOnHand.ItemIdFlag = NoYes::Yes; inventDimOnHand = InventDimOnHand::newAvailPhysical( '', inventDimCriteria, inventDimParmCriteria, InventDimOnHandLevel::SpecPositive, inventDimParmOnHand); inventDimOnHandIterator = inventDimOnHand.onHandIterator(); while (inventDimOnHandIterator.more()) { inventDimOnHandMember = inventDimOnHandIterator.value(); itemId = inventDimOnHandMember.parmItemId(); qty = inventDimOnHandMember.parmInventQty(); ... ... inventDimOnHandIterator.next(); }

Inventory Costing and Valuation


Another important task for the Inventory and warehouse management module is to establish an accounting relationship between sales revenue and the cost of goods sold. Microsoft Dynamics AX 2012 supports the following accepted accounting models. First in, First out (FIFO) Last in, First out (LIFO) Average cost (Weighted average) Standard cost

6-10

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
The costing method is determined by settings on the item model group for each product. Any number of costing methods can be used in a single installation. When a method other than standard costing is used, the system records transactions at the weighted average in real time. Then, a process that is known as Inventory close must be run periodically to make adjustments from the weighted average to the actual costing method. Additionally, the process makes settlements between the receipts and invoices. After this process is complete the inventory is stopped up to the date that inventory is closed for. This means that no additional transactions can be posted with a date earlier than the specified date. When the inventory close process is run, the system updates the transactions (inventTrans table records) with a new status in the ValueOpen field, records the closed date, and records any adjustments for each inventory transaction.

InventSettlement
When a withdrawal from inventory is updated financially, it will be assigned a cost value that is based on the current status of the inventory. Later, financial receipt updates could affect the originally calculated cost value. There is no automatic recalculation of the cost of goods sold for the update of the receipt.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-11

Development IV in Microsoft Dynamics AX 2012


However, a periodic run of the inventory close process will reevaluate the assigned cost value. The original cost value is specified in the InventTrans.CostAmountPosted field. The adjustment will not change this original value. However, the change will be specified in the InventTrans.CostAmountAdjustment field. If the transaction is affected by more than one adjustment, this field will contain the consolidated adjustment. Each adjustment is logged in the InventSettlement table. The following figure shows the relationship between inventory transactions and settlements.

FIGURE 6.5 INVENTSETTLEMENT OBJECT MODEL

The InventTrans.costValue() method returns the current cost value that is the sum of the CostAmountPosted and CostAmountAdjustment fields. The InventSum.PostedValue field contains the consolidated cost value and includes all adjustments.

6-12

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
Inventory and Warehouse Management Integrations
The Inventory and warehouse management module is used to keep track of physical items. The following figure shows the interface with the other modules in Microsoft Dynamics AX 2012.

FIGURE 6.6 INVENTORY AND WAREHOUSE MANAGEMENT INTERACTIONS WITH OTHER MODULES

Items are bought through the Procurement and sourcing module or produced in the Production control module. Items are consumed by sales orders, projects or production orders. The Ledger module keeps track of inventory value and consumption costing.

Inventory Journals
The primary way that inventory is updated in Microsoft Dynamics AX is through sales orders, purchase orders, and production orders. Inventory journals are an alternative that you can use to make manual updates to the inventory. Several types of journals can be used to make updates. Each inventory journal consists of a header and lines. The header defines the journal information that is configured on the journal name. These inventory journal names resemble the journal names and types that are defined in the General ledger module. The journal lines are used to define the items, dimensions, and quantities. Each type of journal has small differences. However, the main principle is that the journal has inventory transactions in the inventTrans table that are used to add or remove inventory.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-13

Development IV in Microsoft Dynamics AX 2012


Journal Types
The four primary journal types are described in the following sections.

Movement
A movement is an update of a receipt or withdrawal of a specified quantity without a related purchase, production, or sales order. This type of journal offers additional control so that users can specify a main account that the inventory cost is offset to.

Inventory Adjustment
An adjustment is made when a deviation is found between the physical inventory and the quantity registered in Microsoft Dynamics AX 2012. A loss could also be relevant if some items in stock are damaged or destroyed.

Counting
Counting is a special version of an adjustment, because the quantity entered is the physical quantity counted. In a typical inventory adjustment journal, the change in quantity is entered.

Transfer
A transfer is used when a lot is moved from one warehouse to another. The same function is also used to change other inventory dimensions, such as batch ID, serial ID, pallet, or warehouse location. Additional journal types are available for item arrivals, production input, and tag counting. For more information about other journal types, refer to the Help.

6-14

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
Inventory Journal Data Model
The following figure displays the data model that is used for inventory journals.

FIGURE 6.7 INVENTORY JOURNALS DATA MODEL

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-15

Development IV in Microsoft Dynamics AX 2012


InventJournalCheckPost Class
The InventJournalCheckPost class prepares for the validation and posting of an inventory journal. It uses the baseEnum InventJournalType to construct an instance of the correct type. The JournalCheckPost class actually does the validation and posting. The JournalCheckPost.postJournal() method selects the lines of the correct type of journal. For each journal line the postTrans() method is called. The class can be activated directly from X++ by using the following lines of code.
JournalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable); JournalCheckPost.run();

6-16

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

Lab 6.1 - Import Beginning Balances


This lab demonstrates how to programmatically create a new movement journal by importing a comma separated value (CSV) file. Estimated time to complete: 25 minutes Scenario Simon, the Business System Developer, must upload the beginning inventory on hand balances for the products that Contoso sells. The information is currently in a spreadsheet and must be imported. Simon must create a new class that includes a dialog box that has a field that allows the user to browse to the desired file, and a drop-down box to select the journal name to be used for the import. The import tool should be fixed to only allow the import of movement journals. The journal should not be posted automatically to allow the user to review the journal before he or she manually posts the journal.

Challenge Yourself!
Use the provided information to create a new class that has a dialog box that has two parameters for selecting a file and a journal name. Add logic to the OK button in the dialog box to open the selected file and create a new movement journal header by using the journal name that is specified in the dialog box. Each line of the spreadsheet must be imported into the journal lines. When the file is finished processing, the users should receive an Infolog informing them of the journal number.

Need a Little Help?


1. Create a new project to store the objects that you create or modify as a part of this workshop. 2. Create a new class. 3. Add methods to the class for a dialog box. For an example of how to create a dialog box in a class, refer to the Tutorial_RunBaseBatch class. 4. Add a progress indicator to the class. For an example of how to implement a progress indicator, refer to the Tutorial_Progress class. 5. Add validation to the class to verify that the two fields in the dialog box are populated with a value. 6. Add methods to the class to open an excel file and read in the contents of the file. Use the SysExcelApplications and SysExcelWorkbooks classes to open and process the file. 7. Add a method to correctly close the Excel file when you are finished.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-17

Development IV in Microsoft Dynamics AX 2012


8. Add methods to the class to create a new journal header and journal lines. For a sample of code that creates movement journals, refer to the TutorialJournalCreateExample. 9. Create a menu item to open the new dialog box, and put the menu item in the Periodic folder of the Inventory and warehouse management module. 10. Create a new journal name to be used for the import in the tutorial_JournalName form. 11. Test the import by importing the AX2012_ENUS_DEVIV_06_01_LAB_SAMPLEFILE.xls file from the Hyper-V training image.

Step by Step
TIP: The code samples for this lab can be found in the AX2012_ENUS_DEVIV_06_01_LAB_CODE.txt file. You can copy and paste these code samples into the correct methods. Follow these steps to create a new project. 1. 2. 3. 4. 5. 6. Open the Development workspace. Open the Projects window. Right-click the Shared node and then click New > Project. Right-click the new project and select Rename. Enter a name for the project such as ImportBeginningBalancesLab. Double-click the project to open it, and then close the Projects window.

To create a new class that is copied from the Run Base Batch Tutorial, follow these steps. 1. In the AOT window, browse to Classes > Tutorial_RunbaseBatch. 2. Right-click the class and click Duplicate. 3. Right-click the CopyOfTutorial_RunbaseBatch class that is created and click Rename. 4. Enter a name for the class such as ImportBeginningBalances. 5. Save the class. 6. Drag the new class into the project created earlier. 7. Save the project.

6-18

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
To update the code in the class for the dialog to importing beginning balances, follow these steps. 1. Locate the ImportBeginningBalances class and then right-click and choose View Code. 2. In the classDeclaration method, add variables for the packed variables, Microsoft Office Excel objects, and the dialog fields. Use the following code sample to guide you. class ImportBeginningBalances extends RunBaseBatch { // Packed variables FilenameOpen fileNameOpen; TutorialJournalNameId inventJournalNameId; // Excel objects SysExcelApplication SysExcelWorkbooks SysExcelWorksheets SysExcelWorksheet SysExcelCells // Dialog fields DialogField DialogField oSysExcelApplication; oSysExcelWorkbooks; oSysExcelWorksheets; oSysExcelWorksheet; oSysExcelCells; dlgFileNameOpen; dlgInventJournalNameId;

#define.CurrentVersion(1) #define.Version1(1) #localmacro.CurrentList fileNameOpen, inventJournalNameId #endmacro } 3. Modify the construct method to create a new instance of the ImportBeginningBalances class. Use the following code sample to guide you. server static ImportBeginningBalances construct() { return new ImportBeginningBalances(); } 4. Update the description of the class. Use the following code sample to guide you.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-19

Development IV in Microsoft Dynamics AX 2012


static ClassDescription description() { return "Import Beginning Balances"; } 5. Change the main method to call the construct of the ImportBeginningBalances class. Use the following code sample to guide you. static void main(Args args) { ImportBeginningBalances ImportBeginningBalances; ; ImportBeginningBalances = ImportBeginningBalances::construct(); if (ImportBeginningBalances.prompt()) ImportBeginningBalances.run(); } 6. Next, modify the dialog method to include the fileNameOpen and inventJournalNameId fields. Use the following code sample to guide you. public Object dialog() { DialogRunbase dialog = super(); #resAppl dlgFilenameOpen = dialog.addFieldValue( extendedTypeStr(FilenameOpen), FilenameOpen); dlgInventJournalNameId = dialog.addFieldValue( extendedTypeStr(TutorialJournalNameId), InventJournalNameId); return dialog; } 7. Next modify the getFromDialog method to set the value of the fileNameOpen and inventJournalName variables. Use the following code to guide you. public boolean getFromDialog() { fileNameOpen = dlgFileNameOpen.value(); inventJournalNameId = dlgInventJournalNameId.value();

6-20

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
return super(); } To add validation, a progress indicator, and logic to import the file, follow these steps. 1. To add validation to the class, modify the validate method. Use the following code sample to guide you. public boolean validate(Object _calledFrom = null) { boolean ret = true; //Add validation to the class to verify that the two fields on the dialog box are populated with a value. if (!fileNameOpen) { ret = checkFailed("Invalid file name."); } if (!inventJournalNameId) { ret = checkFailed("Invalid invent journal name Id."); } return ret; } 2. Add the following code that is used to initialize the objects for importing a spreadsheet in the init method. public boolean init() { ; // If spreadsheet document doesn't exist, then quit if (! winAPI::fileExists(fileNameOpen)) { throw error(strfmt("File '%1' doesn't exist or is currently open.", fileNameOpen)); } // Start excel & turn off alerts oSysExcelApplication = SysExcelApplication::construct(); oSysExcelApplication.displayAlerts(false); oSysExcelWorkbooks = oSysExcelApplication.workbooks(); // Try to open the file try { oSysExcelWorkbooks.open(fileNameOpen); }

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-21

Development IV in Microsoft Dynamics AX 2012


catch { throw error(strfmt("@SYS76826", fileNameOpen)); } oSysExcelWorksheets = oSysExcelApplication.worksheets(); return true; } 3. Create a new method called startProgress that will initiate the progress bar. Use the following code sample to guide you. void startProgress() { #avifiles SysOperationProgress oProgress; oProgress = new SysOperationProgress(); oProgress.setAnimation(#aviupdate); oProgress.setCaption(ImportBeginningBalances::description()); oProgress.update(true); } 4. Create a new method called readAll that opens the file and reads the records. Use the following code sample to guide you. private void readAll( ) { // Macro for file type (extension) #define.SP_FILE_TYPE ("xls") // Macros for input and output sheet #define.SP_OUTPUT_WORKSHEET ("Data") // Macros for read #define.SP_START_ROW (2) #define.SP_END_ROW (10) #define.SP_READ_TRANSDATE_COLUMN (1) #define.SP_READ_ITEMID_COLUMN (2) #define.SP_READ_COST_COLUMN (3) int startRow = #SP_START_ROW; InventDim tInventDim; TutorialJournalTable journalTable; TutorialJournalTrans journalTrans; TutorialJournalTableData journalTableData = JournalTableData::newTable(journalTable); TutorialJournalTransData journalTransData =
6-22

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
journalTableData.journalStatic().newJournalTransData(journalTrans,journalTa bleData); // Try to open Outputs worksheet oSysExcelWorksheet = oSysExcelWorksheets.itemFromName(#SP_OUTPUT_WORKSHEET); if (oSysExcelWorksheet == null) { throw error(strfmt("No 'Outputs' worksheet in file '%1'.", fileNameOpen)); } // Try reading values from outputs worksheet try { // Init journalTable journalTable.JournalId = journalTableData.nextJournalId(); journalTable.JournalType = InventJournalType::Movement; journalTable.JournalNameId = inventJournalNameId; journalTableData.initFromJournalName(journalTableData.journalStatic().findJ ournalName(journalTable.JournalNameId)); oSysExcelCells = oSysExcelWorksheet.cells(); while (startRow <= #SP_END_ROW) { journalTrans.clear(); journalTransData.initFromJournalTable(); journalTrans.TransDate = oSysExcelCells.item(StartRow, #SP_READ_TRANSDATE_COLUMN).value().date(); journalTrans.ExItemId = this.cell2String(StartRow, #SP_READ_ITEMID_COLUMN); journalTrans.ExCostAmount = oSysExcelCells.item(StartRow, #SP_READ_COST_COLUMN).value().double(); journalTransData.create(); StartRow ++; } journalTable.insert(); } catch { throw error("Reading values from Excel file failed."); } }

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-23

Development IV in Microsoft Dynamics AX 2012


5. Create a new method called cell2String that converts the value passed in to a string. Use the following code sample to guide you. private str cell2String(int _row, int _column) { str ret; if (! oSysExcelCells) { ret = ''; } else { switch (oSysExcelCells.item(_row, _column).value().variantType()) { case COMVariantType::VT_BSTR: // String type ret = strltrim(strrtrim(oSysExcelCells.item(_row, _column).value().bstr())); break; case COMVariantType::VT_R8: // Real type ret = strltrim(strrtrim(num2str(oSysExcelCells.item(_row, _column).value().double(),0,0,0,0))); break; default : ret = ''; break; } } return ret; } 6. Create a new method called exitExcel that correctly closes Microsoft Office Excel. Use the following code sample to guide you. private void exitExcel() { if (oSysExcelApplication) { // Although displayAlerts is called in init it appears necessary to // call it again. Otherwise if the application is not saved a dialog // will pop up asking if the file should be saved. oSysExcelApplication.displayAlerts(false); oSysExcelApplication.quit(); } }

6-24

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
7. Modify the run method to execute the logic you created in the startProgress, init, readAll, and exitExcel methods. Use the following code sample to guide you. /// <summary> /// Contains the code that does the actual job of the class. /// </summary> public void run() { #OCCRetryCount if (! this.validate()) throw error(""); try { ttsbegin; this.startProgress(); this.init(); this.readAll(); this.exitExcel(); ttscommit; } catch (Exception::Deadlock) { retry; } catch (Exception::UpdateConflict) { if (appl.ttsLevel() == 0) { if (xSession::currentRetryCount() >= #RetryNum) { this.exitExcel(); throw Exception::UpdateConflictNotRecovered; } else { retry; } } else { this.exitExcel(); throw Exception::UpdateConflict; } } catch (Exception::Error) {
6-25

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Development IV in Microsoft Dynamics AX 2012


error("Import failed!"); this.exitExcel(); } } 8. Save and compile the class, and then close the Code Editor window.

Test
To create a new menu item and put it on the main menu in the Inventory and warehouse management module under the Periodic folder, follow these steps. 1. In the AOT window, expand Menu Items. 2. Right-click Action, and then click New Menu Item. 3. In the Properties window, set the following values. a. Name = ImportBeginningBalances b. Label = Import beginning balances c. HelpText = Tutorial to import beginning balances into a movement journal. d. ObjectType = Class e. Object = ImportBeginningBalances 4. Save the menu item. 5. Drag the new menu item into the project that you created earlier. 6. In the AOT window, browse to Menus > InventoryAndWarehouseManagement. 7. Drag the menu into the project that you created earlier. 8. In the Project window, browse to the Periodic folder of the InventoryAndWarehouseManagement menu. 9. Drag the ImportBeginningBalances menu item into the Periodic folder and place it below the Inventory blocking menu item. 10. Save the menu and the project. To create a new journal name to be used for the import, follow these steps. 1. In the AOT window, browse to Forms > tutorial_JournalName. 2. Right-click the form and then click Open. 3. Create a new record and enter the following information. a. Name = IMov b. Description = Inventory Movement c. Journal type = Movement d. Voucher series = Inve_72 4. Close the Journal names form.

6-26

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
To test the new menu item and import process, follow these steps. 1. Close the Microsoft Dynamics AX 2012 client. 2. Open a new Microsoft Dynamics AX 2012 client. 3. Open Inventory and warehouse management > Periodic > Import beginning balances. 4. Verify that your dialog box looks similar to the following figure.

FIGURE 6.8 IMPORT BEGINNING BALANCES DIALOG BOX

5. Click the yellow folder icon and browse to the AX2012_ENUS_DEVIV_06_01_LAB_SAMPLEFILE.xlsx file. 6. Click Open in the Windows Explorer window to open the file. 7. In the Name drop-down box, select IMov. 8. Click OK. 9. Notice the progress indicator while file imports. When the process is finished the progress bar will disappear to indicate the process is finished. To view the journal that was imported, follow these steps. 1. Open the Development Workspace. 2. In the AOT window, browse to Forms > tutorial_JournalTable. 3. Right-click the form and select Open.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-27

Development IV in Microsoft Dynamics AX 2012


4. Notice the journal header that is imported, and then click Lines. 5. Notice the journal lines that are imported. Your data should look similar to the following figure.

FIGURE 6.9 JOURNAL AND JOURNAL LINES FORMS

TIP: You can repeat the test as many times as you would like. The journal number and voucher numbers will automatically increment during each import. TIP: You can import the AX2012_ENUS_DEVIV_06_01_LAB_SOL.xpo file to verify and compare your solution. NOTE: This lab uses the Microsoft Dynamics AX 2012 Tutorial tables, classes, and forms. In a more realistic implementation, you should create your own tables, forms, and classes.

6-28

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

Quarantine and Quality Management


Microsoft Dynamics AX 2012 includes functionality to help you manage the quality of the products that you purchase or sell. This includes quarantine management, quality management with tests, and inventory blocking.

Quarantine Orders
The quarantine function is used to block a specific lot. When the quarantine is started, the quantity is removed from available inventory. Later, when the quarantine is ended, the quantity is returned to available inventory. One use of this function is to block a received lot until it has passed quality assurance. The InventMov_Quarantine class is used when you work with inventory quarantine orders to control items that are in the InventQuarantineOrder table quarantine. Quarantine orders differ from other types of orders such as purchase orders or sales orders because they do not have a header and line data structure.

Quality Orders
You can use quality orders to identify the tests and to record test results and test quantity for a specific item. The tests are copied from the test group that is assigned to the quality order. Tests can be added, deleted, or changed. A quality order can be manually created or automatically generated based on rules that are defined in the Quality associations form found in Inventory and warehouse management > Setup > Quality control. A quality order is associated with an item in a sales order, a purchase order, a quarantine order, a production order, a production order routing operation, or an on-hand inventory balance. Items that are specified for inspection in a quality order are automatically blocked from issue or consumption. Each quality order is stored in the InventQualityOrder table. The lines of the quality order represent each test to be performed and stored in the InventQualityOrderLine table. Each test or quality order line can have test results recorded for it that are stored in the InventQualityOrdersLineResults table. The InventQualityManagementCreate class provides the facilities for quality management order generation.

Inventory Blocking
Inventory blocking is part of the quality inspection process. During the quality inspection, items are automatically blocked from consumption or issue. Also, you can manually block items that you want to prevent from being issued or consumed.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-29

Development IV in Microsoft Dynamics AX 2012


Inventory blocking methods Inventory items can be blocked three waysmanually, by creating a quality order, or by using a process that generates a quality order. Block items manually The quantity of an item can be blocked by creating a transaction in the Inventory blocking form found in Inventory and warehouse management > Periodic. Only items that are available as on-hand inventory can be blocked. For manually blocked quantities, you must consider if expected receipts should be included in planning activities as an expected on-hand quantity. Expected receipts are blocked items that are expected to be available as on-hand inventory after inspection. By default, the Expected receipts check box is selected for items that are blocked through a quality order. You can cancel blocking of a manually blocked quantity by deleting the transaction in the Inventory blocking form. Block items by creating a quality order Items can be specified for inspection by creating a quality order in the Quality orders form found in Inventory and warehouse management > Periodic > Quality management. When you create a quality order, the quantity of an item that you specify is blocked. NOTE: The sampling plan (created in Inventory and warehouse management > Setup > Quality control > Item sampling) that is associated with a quality order controls the quantity of an item that should be inspected. The quantity of blocked items, on the other hand, is not controlled by the sampling plan. Regardless of the quantity that is sent for inspection, as specified by the sampling plan, the quantity of the item that is entered on the quality order is the quantity that is blocked. Block items by a process that generates a quality order A quantity of an item that is specified for inspection through a quality process is automatically blocked. So when a quality order is generated automatically, the item sampling plan that is associated with the quality order controls the quantity of items that is blocked and not only the quantity of items that will be inspected. NOTE: If the Full blocking check box in the Item sampling form is selected, the full quantity of, for example, a purchase order line is blocked during inspection regardless of the item sampling quantity.

6-30

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
The InventMov_Blocking class is a specialized InventMovement class version responsible for handling inventory blockings. The InventBlockingTableType class wraps various properties of the different inventory blocking types and callers. The InventBlockingQualityOrderSync class provides methods to synchronize inventory blocking and related quality orders.

Other Functionality
The Inventory and warehouse management module has many additional features. The following topics review the forecasting and transfer order functionality.

Forecasts
Forecasts are used to enter sales and purchases expected in the future. By forecasting you can plan for the future beyond the period covered by received sales orders and created purchase orders. For example, forecasts are necessary when a manufacturing companys production lead time is longer than the orderto-delivery time that it offers customers. A forecast model is used to name and identify a specific forecast. You can define a forecast model in two levels. A forecast model can include one or more submodels. This allows you to aggregate the individual forecasts. When you run forecast scheduling for a top-level forecast model, the program calculates gross requirements for all models that are designated as submodels. All forecast models must be defined before you can designate one or more models as submodels of a forecast model. A forecast model that is used as a submodel cannot contain other submodels. A forecast submodel uses its own parameters, not those of the toplevel forecast model.

There are several types of forecasts available in Microsoft Dynamics AX 2012 including demand, supply, item, and expense forecasts.

Transfer Orders
A transfer between two warehouses can be updated by using a transfer journal as mentioned earlier. However, when a journal is updated, the issue and receipt are updated at the same time. If there is a time lag between the issue and the receipt because of transport time, this can be reflected by creating a transfer order. Transfer orders differ from transfer journals because shipping and receiving actions must be completed. They also allow for multiple shipments and receipts against the same order.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-31

Development IV in Microsoft Dynamics AX 2012


Before shipping a transfer order, you can also do the following. Select the transfer order lines that you want to ship. Reserve items for transfer. In the Transfer orders form, click Inventory > Reservation and then select the items that you want to reserve for transfer. Pick items for transfer. In the Transfer orders form, click Inventory > Pick and then select the items that you want to pick for transfer. In the Pick list, select items for transfer by their serial number. You can also print a picking list and register picking list. Specify the quantity that you want to ship for each transfer order line by entering a quantity in the Ship now field. To ship this quantity, open the Shipment form and select Ship now in the Update list. Print the transfer order by clicking Print and selecting Transfer overview.

6-32

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

Lab 6.2 - Inventory Blocking


This lab demonstrates how to modify the inventory blocking functionality to support the clearing of blocked inventory instead of deleting the inventory blocking record. Estimated time to complete: 25 minutes Scenario Contoso has to keep a history of all inventory blocking records for auditing. In Microsoft Dynamics AX 2012, an inventory blocking record must be deleted to clear or release the hold on the inventory. Simon, the Business Systems Developer, must add new fields to track the date, time, and the user who clears the inventory blocking. Additionally, the Delete button on the Inventory blocking form must be modified to copy the data into a new Inventory blocking history table. He must then create a new form and menu item to access the inventory blocking history. The new Inventory blocking history form will be located in Inventory and warehouse management > Inquiries > Quality management.

Challenge Yourself!
Use the provided information to create a new table to track the history of cleared inventory blocking records. Add new fields to this table to store the user ID and the cleared date and time. Modify the functionality of the Delete button on the Inventory blocking form to copy the blocking record to the new inventory blocking history table.

Need a Little Help?


1. Create a new table for inventory blocking history. Make sure that you include new fields with extended data types for the user ID, cleared flag, and the cleared date and time. 2. Create a new form for the inventory blocking history. 3. Create a new menu item for the new inventory blocking history, and add the menu item to the main menu under Inventory and warehouse management > Inquiries > Quality management. 4. Create a new method in the InventBlockingTableType class to copy the inventory blocking record to the inventory blocking history table. 5. Modify the delete method in the InventBlockingTableType class to call the new method that you created in step 4. 6. Test the new functionality to verify that the records are copied to the new inventory blocking history table.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-33

Development IV in Microsoft Dynamics AX 2012


Step by Step: Create the Table
Follow these steps to create a new project. 1. 2. 3. 4. 5. 6. Open the Development workspace. Open the Projects window. Right-click the Shared node and then click New > Project. Right-click the new project and select Rename. Enter a name for the project such as InventoryBlockingLab. Double-click the project to open it, and then close the Projects window.

To create new extended data types for the new inventory blocking history table, follow these steps. 1. In the AOT window, browse to Data Dictionary > Extended Data Types. 2. Right-click Extended Data Types, and then click New > Enum. 3. In the Properties window for the new enum, set the following values. a. Name = InventBlockingClearedFlag b. Label = Cleared c. HelpText = Inventory blocking is cleared when selected. d. Extends = NoYesId e. EnumType = NoYes 4. Save the extended data type, and then drag it into the project that you created earlier. 5. Right-click Extended Data Types, and then click New > UtcDateTime. 6. In the Properties window for the new extended data type, set the following values. a. Name = ClearedDateTime b. Label = Cleared date time c. HelpText = Date and time the inventory blocking was cleared. 7. Save the extended data type, and then drag it into the project that you created earlier. 8. Save the project.

6-34

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
To create a new inventory blocking history table, follow these steps. 1. In the AOT window, browse to Data Dictionary > Tables > InventBlocking. 2. Right-click the InventBlocking table and then click Duplicate. 3. In the Properties window, set the following values. a. Name = InventBlockingHistory b. Label = Inventory blocking history c. CreatedDateTime = No d. CreatedBy = No 4. Save the table, and then drag it into the project that you created earlier. 5. Save the project. 6. Expand the Fields node of the InventBlockingHistory table. 7. Drag the InventBlockingClearedFlag and ClearedDateTime extended data types into the Fields node. 8. Set the AllowEdit property on each of the fields to No. 9. Right-click the Fields node and then click New > String. 10. In the Properties window, set the following values. a. Name = ClearedBy b. Label = Cleared by c. HelpText = User that cleared the inventory blocking. d. AllowEdit = No e. ExtendedDataType = UserId 11. Right-click the Fields node and then click New > String. 12. In the Properties window, set the following values. a. Name = origCreatedBy b. Label = Created by c. HelpText = User that created the inventory blocking. d. AllowEdit = No e. ExtendedDataType = UserId 13. Right-click the Fields node and then click New > UtcDateTime. 14. In the Properties window, set the following values. a. Name = origCreatedDateTime b. AllowEdit = No c. ExtendedDataType = CreatedDateTime 15. Right-click the Field Groups node and then click New Group.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-35

Development IV in Microsoft Dynamics AX 2012


16. In the Properties window, set the following values. a. Name = InventBlockingClear b. Label = Cleared 17. Drag the InventBlockingClearedFlag, ClearedBy, and ClearedDateTime fields into the new group. 18. Expand the History field group, and then delete each of the fields from the field group. 19. Drag the origCreatedBy and origCreatedDateTime fields into the History field group node. 20. Save the table and the project.

Step by Step: Create the Form


To create a new form for the inventory blocking history, follow these steps. 1. In the AOT window, browse to Forms > InventBlocking. 2. Right-click the InventBlocking form and then click Duplicate. 3. Right-click the CopyOfInventBlocking form and then click Rename. 4. Set the name to InventBlockingHistory. 5. Save the form, and then drag it into the project that you created earlier. 6. In the form, expand Methods. Remove the inventDimSetupObject and updateDesign methods. 7. Modify the classDeclaration of the form to only inlcude the vertical splitter. Use the following code sample to guide you. public class FormRun extends ObjectRun { SysFormSplitter_X verticalSplitter; } 8. Modify the init method of the form to only call the super and initialize the vertical splitter. Use the following code sample to guide you. public void init() { super(); //Initialize splitter verticalSplitter = new SysFormSplitter_X(vSplitter, gridContainer, element); } 9. In the form, browse to Data Source > InventBlocking > Methods, and then remove the write, init, validateWrite, and active methods.

6-36

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
10. Right-click the InventBlockingForm query under the Data Sources node and select Delete. 11. Select Permanately delete, and then click OK, to confirm the deletion. 12. Select the InventBlocking data source, and set the following properties. a. Table = InventBlockingHistory. b. AllowEdit = No c. AllowCreate = No d. AllowDelete = No 13. Select the Design node of the form and set the Caption property to Invent blocking history. 14. In the form, browse to Designs > Design > ActionPane:ActionPane > ActionPaneTab:ActionPaneTab, and then remove the ButtonGroup:RecordBasics. 15. In the form, browse to Designs > Design > Group:Body > Group:DetailsContainer > Tab:DetailsTab > TabPage:General, and then set the Columns property to 3. 16. Right-click the top node of the InventBlockingHistory form and select Restore. 17. Drag the InventBlockingClear field group from the Fields node of the InventBlocking data source on the form into the TabPage:General section and put it below the Group:History group. 18. Save the form. 19. In the Project window, select the InventBlockingHistory table, and set the FormRef property to InventBlockingHistory. To create a new menu item and to add the menu item to the menu, follow these steps. 1. In the AOT window, expand Menu Items. 2. Right-click Display, and then click New Menu Item. 3. In the Properties window, set the following values. a. Name = InventBlockingHistory b. Label = Inventory blocking history c. HelpText = View inventory blocking history. d. ObjectType = Form e. Object = InventBlockingHistory 4. Save the menu item. 5. Drag the new menu item into the project that you created earlier.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-37

Development IV in Microsoft Dynamics AX 2012


6. In the AOT window, browse to Menus > InventoryAndWarehouseManagement. 7. Drag the menu into the project that you created earlier. 8. In the Project window, browse to the Inquiries > Quality management folder of the InventoryAndWarehouseManagement menu. 9. Drag the InventBlockingHistory menu item into the Quality management folder and place it below the Related operation time sheets menu item. 10. Save the menu and the project.

Step by Step: Create the Logic


To create the logic for copying the inventory blocking data, to the inventory blocking history table, follow these steps. TIP: The code samples for this lab can be found in the AX2012_ENUS_DEVIV_06_02_LAB _CODE.txt file. You can copy and paste these code samples into the correct methods. In the Project window, locate the InventBlockingHistory table. 1. Delete all of the methods from the Methods node of the table. (These methods were copied from the InventBlocking table, and are not needed on the new InventBlockingHistory table.) 2. Create a new method on the table called initFromInventBlocking. This method should set all of the fields in the history table from the original table. Use the following code sample to guide you. /// <summary> /// Initializes the current <c>InventBlockingHistory</c> record from an InventBlocking record. /// </summary> public void initFromInventBlocking(InventBlocking _InventBlocking) { this.ItemId = _InventBlocking.ItemId; this.Qty = _InventBlocking.Qty; this.InventTransIdIssue = _InventBlocking.InventTransIdIssue; this.InventTransIdReceipt = _InventBlocking.InventTransIdReceipt; this.InventDimId = _InventBlocking.InventDimId; this.ExpectedReceiptDate = _InventBlocking.ExpectedReceiptDate; this.ExpectReceipt = _InventBlocking.ExpectReceipt; this.Description = _InventBlocking.Description; this.BlockingType = _InventBlocking.BlockingType; this.origCreatedBy = _InventBlocking.createdBy; this.origCreatedDateTime = _InventBlocking.createdDateTime; }

6-38

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
3. Create a new find method on the table that is used to find inventory blocking history table records. Use the following code sample to guide you. /// <summary> /// Finds the specified record in the <c>InventBlockingHistory</c> table. /// </summary> /// <param name="_inventBlockingHistory"> /// The ID of the record to find. /// </param> /// <param name="_forUpdate"> /// A Boolean value that indicates whether to read the record for update; optional. /// </param> /// <returns> /// A record in the <c>InventBlocking</c> table if it exists; otherwise, an empty record. /// </returns> public static InventBlockingHistory find( RecId _inventBlockingHistory, boolean _forUpdate = false) { InventBlockingHistory inventBlockingHistory; inventBlockingHistory.selectForUpdate(_forUpdate); select firstonly inventBlockingHistory where inventBlockingHistory.RecId == _inventBlockingHistory; return inventBlockingHistory; } 4. Create a new method on the table that overrides the initValue method. This method should set the values for the new fields that were added to the table. Use the following code sample to guide you. /// <summary> /// Initializes default inventory blocking history values. /// </summary> public void initValue() { this.InventBlockingClearedFlag = NoYes::Yes; this.ClearedBy = curUserId(); this.ClearedDateTime = DateTimeUtil::utcNow(); } 5. In the AOT window, browse to Classes > InventBlockingTableType. 6. Drag the class into the project that you created earlier.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-39

Development IV in Microsoft Dynamics AX 2012


7. Create a new method in the class called writeInventBlockingHistory, and then add logic to the method to call the table methods for initializing and copying the data. /// <summary> /// Lab 6.2 Write History Table /// </summary> private void writeInventBlockingHistory() { inventBlockingHistory inventBlockingHistory; inventBlockingHistory.initFromInventBlocking(inventBlocking); inventBlockingHistory.initValue(); inventBlockingHistory.insert(); } 8. Modify the delete method of the InventBlockingTableType class to call the new writeInventBlockingHistory method. Use the following code sample to guide you. /// <summary> /// Deletes the inventory blocking record and corresponding inventory transactions. /// </summary> public void delete() { // Delete issue transaction this.deleteBlockingTransaction(); // Delete receipt transaction if exists if (inventBlocking.InventTransIdReceipt) { this.deleteBlockingTransaction(InventMovSubType::TransferReceipt); } //Lab 6.2 Write History Table this.writeInventBlockingHistory(); inventBlocking.doDelete(); } 9. Save the class and the project.

Step by Step: Test the Solution


To test the new inventory blocking history functionality, follow these steps. 1. Close the Microsoft Dynamics AX 2012 client. 2. Open a new Microsoft Dynamics AX 2012 client.

6-40

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
3. Open Inventory and warehouse management > Periodic > Inventory blocking. 4. Create a new record by clicking New. 5. Select an item number such as 1005. 6. Enter a description such as Test. 7. Select a configuration such as HD, a size such as 50, and a color such as 02. 8. Save the record by pressing Ctrl+S. 9. Click Delete. 10. Close the Inventory blocking form. 11. Open Inventory and warehouse management > Inquiries > Quality management > Inventory blocking history. 12. Notice the inventory blocking record that you just created. Your results should look similar to the following figure.

FIGURE 6.10 INVENTORY BLOCKING HISTORY FORM

TIP: You can repeat the test as many times as you would like by using different item numbers and dimensions. The only requirement is that the item and dimension combination that you select must be on hand. TIP: You can import the AX2012_ENUS_DEVIV_06_02_LAB_SOL.xpo file to verify and compare your solution.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-41

Development IV in Microsoft Dynamics AX 2012

Summary
The Inventory and warehouse management module in Microsoft Dynamics AX 2012 integrates with many other modules and is the central module for processing inventory transactions. The module includes functionality for recording and updating the inventory transactions and keeping track of the on hand quantities for every item and itemdimension combination. The inventory closing process provides functionality to revalue the inventory from the weighted average to the selected inventory costing method that is specified on each item. Inventory journals can be used to make manual adjustments to the inventory values by adding, removing, or counting the current on hand inventory values. You can also make transfers by using an inventory journal or by creating a transfer order. Finally, quarantine and quality management features can be used to record test results and prevent items from being processed because of quality issues.

6-42

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

Test Your Knowledge


Test your knowledge with the following questions. 1. Describe the difference between the inventTrans table and the inventSum table.

2. Match the inventory statuses with the correct inventory status field. Categories (Inventory Statuses): 1. Status Issue 2. Status Receipt _____ Item 1: Ordered _____ Item 2: OnOrder _____ Item 3: ReservOrdered _____ Item 4: Received _____ Item 5: Purchased _____ Item 6: Deducted _____ Item 7: Picked _____ Item 8: Sold 3. TRUE or FALSE? The InventJournalCheckPost class handles the validation and posting of a purchase order. ( ) TRUE ( ) FALSE

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-43

Development IV in Microsoft Dynamics AX 2012


4. Which of the following stores the original cost value for an inventory transaction in the InventTrans table? ( ) InventTrans.CostValue() method ( ) InventTrans.CostAmountAdjusted field ( ) InventTrans.CostAmountPhysical field ( ) InventTrans.CostAmountFinancial field 5. Which of the following are types of reservations available in Microsoft Dynamics AX 2012? (Select all that apply) ( ) Reserved physical ( ) Reserve ordered ( ) Sales reservation ( ) Purchase reservation

6-44

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module

Quick Interaction: Lessons Learned


Take a moment and write down three key points you have learned from this chapter 1.

2.

3.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-45

Development IV in Microsoft Dynamics AX 2012

Solutions
Test Your Knowledge
1. Describe the difference between the inventTrans table and the inventSum table. MODEL ANSWER: The inventTrans table stores the details of every inventory issue and receipt, whereas the inventSum table stores the summation of all inventTrans records grouped by the inventory dimension combinations which are identified by the inventDimID. 2. Match the inventory statuses with the correct inventory status field. Categories (Inventory Statuses): 1. Status Issue 2. Status Receipt 2 1 1 2 2 1 1 1 Item 1: Ordered Item 2: OnOrder Item 3: ReservOrdered Item 4: Received Item 5: Purchased Item 6: Deducted Item 7: Picked Item 8: Sold

3. TRUE or FALSE? The InventJournalCheckPost class handles the validation and posting of a purchase order. ( ) TRUE () FALSE 4. Which of the following stores the original cost value for an inventory transaction in the InventTrans table? ( ) InventTrans.CostValue() method ( ) InventTrans.CostAmountAdjusted field ( ) InventTrans.CostAmountPhysical field () InventTrans.CostAmountFinancial field

6-46

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 6: Use and Design of the Inventory and Warehouse Management Module
5. Which of the following are types of reservations available in Microsoft Dynamics AX 2012? (Select all that apply) () Reserved physical () Reserve ordered ( ) Sales reservation ( ) Purchase reservation

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

6-47

Development IV in Microsoft Dynamics AX 2012

6-48

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

You might also like