Sei sulla pagina 1di 3

How to: Use availability service

Further reading
Microsoft Dynamics AX 2012 for Developers [AX 2012] Inventory and warehouse management [AX 2012]

Tutorial
AX Retail provides the availability service as part of the Commerce Runtime (CRT).

Create item inventory


You can create item inventory by posting to Item Journals under Inventory and warehouse management. For example, see Register item receipts with an item arrival journal [AX 2012].

Replicate to CRT
1. Open Retail/Periodic/Calculate inventory. Click OK. 2. Open Retail/Periodic/Distribution schedule. 3. Select A-1130_OC, click Run directly, click Yes.

4. Open Microsoft SQL Server Management Studio. 5. Connect to Store Connect Message DB server. Run the following query, and verify the job (JobId = A-1130_OC) is completed successfully (Status = 1)
select * from AxRetailMsg.dbo.OutgoingMessages order by PackageNo desc

6. Connect to CRT DB server. Run the following query, and verify the availability data.

select * from AxRetailSP.dbo.ITEMAVAILABILITYVIEW

Consume availability
The availability service is exposed at three layers in CRT: Service, Workflow and Client APIs. The core functionalities of the availability service are exposed in service APIs.

Warehouse preferences
The CRT checkout process uses the notion of a preferred warehouse when creating a sales order in AX, since a corresponding sales warehouse needs to be specified for each line item. The preferred warehouse is also used for other purposes such as determining the item origin when computing shipping charges. The warehouse preferences are computed in a manner that is consistent with how a warehouse is determined, when creating a sales order directly. Default sales warehouse for the customer, product and channel are all taken into account by the service when deciding which one to use as the preferred warehouse.

Total item availabilities


The GetItemAvailableQuantitiesByItems API provides a sum of available quantities for an item across all warehouses. This service method is augmented in the workflow to provide total availabilities for listings in the sales unit of measure.

Item inventory across multiple warehouses


The GetItemAvailabilitiesByItemQuantities provides a means to query available quantitates for a list of items and requested quantities, across multiple warehouses. For items with sufficient quantities available in one warehouse, the topmost warehouse is returned, order by preferences descending, then available quantities descending, and RecId ascending. Otherwise, the top N warehouses are returned, order by available quantities descending, then preferences descending, and RecId ascending, where N is passed in as a parameter. In case of the standard workflow implementation, N is set as the maximum number of line items that an item occurs in the online shopping cart. If you want to split one shopping cart line into multiple lines to spread the order into multiple warehouses and fulfill the order as much as possible, you can create your own workflow using this API and set N to a higher value.

Item inventory in given warehouses


The GetItemAvailabilitiesByItemWarehouses API provides the ability to query item inventory in given warehouses. This service method is used in the standard workflow for pickup in store scenario, where the warehouse is already specified.

Item inventory across all warehouses


The GetItemAvailabilitiesByItems API provides the ability to query item inventory across various warehouses. This service method expects an item identifier as input and returns a list of warehouses with corresponding inventory numbers for that item. Additionally, the result also includes flags to indicate the warehouse preferences. This method contains the broadest result set, since all warehouses

are included. This method should be used when other methods cannot satisfy your need. You should use pagination to minimize the perf impact.

Reserve/Release items
The available quantities are automatically deducted when a sales order is created in CRT. This will help ensure the availability number is up to date and reduce the cases of overbooking. If you want more certainty on avoiding overbooking, you should consider to use the reserve/release items APIs. These methods will not reserve the items in AX, but it will reduce the availability number in CRT immediately without submitting the sales orders. For example, if you are selling some high price, limited quantity, hot items, you may choose to create your own workflow where you call reserve items after all other validations but right before you call authorize payments. That way, the customer does not end up in the situation where the payment is authorized (and may take time to cancel/expire) but the item is unavailable.

Notifications
The availability service may generate the following notifications. The default notification handlers just ignore the notifications and continue. You can replace them with your own handlers if you want.
EmptyInventoryUnitOfMeasureNotification Indicates that no inventory unit of measure for the given item were found.

This is mostly an AX configuration issue.


EmptySalesUnitOfMeasureNotification Indicates that no sales unit of measure for the given sales line were found.

This is mostly an AX configuration issue.


InsufficientQuantityAvailableNotification Indicates that not enough quantity available for the given sales line.

You may provide your own custom handler, e.g., to block checkout if back order is not allowed, or the item is discontinued.
InventoryNotFoundNotification Indicates that no inventory for the given sales line were found.

You may provide your own custom handler, e.g., to block checkout if pre-order is not allowed.
UnableToConvertUnitOfMeasureNotification Indicates that unable to convert quantity between unit of measures for an item.

This is mostly an AX configuration issue.


UnableToDetermineQuantityNotification Indicates that quantity cannot be retrieved from inventory database.

This is possibly a database connectivity issue. You may provide your own custom handler, e.g., to warn you if this occurs persistently or too frequent.

Potrebbero piacerti anche