2009-02-18

A few words about sorting codes

In AX each item may be assigned by its own sort code. On the other hand each WMS location has its own sort code and there is a functionality for updating sort codes.

Let's analyse how do they work together.

Take a look at WMSAisle table which has following fields:

  • inventLocationId
  • sortCode
  • sortDescending
  • aisleId
  • aisleNo

A sample of WMSAisle table:

By the way combination inventLocationId and aisleId fields is unique (see \Data Dictionary\Tables\WMSAisle\Indexes\AisleIdx).

Every time when we try to update WMSLocation sort codes (e.g. \Menus\Invent\Periodic\Locations\Sort codes) updateSortCodes() method of WMSAisle table is invoking. The sort codes are updating in two steps:

- initialSortCode seeking;

- updating sort codes;

Determining of initialSortCode

If WMSParameters.manualSortCode is true the initialSortCode is assigned by WMSAisle.sortCode. Else initialSortCode will be equal maximal value of WMSLocation.sortCode for all aisles less than current aisleNo.

To understand how does it work suppose there is an inventLocation 00001 with several aisles (WMSAisle table)

inventLocationId        aisleId         aisleNo
    00001                   1               1
    00001                   2               2
    00001                   3               3
    00001                   4               4
    00001                   5               5
    00001                   6               6
    00001                   7               7
    00001                   8               8
    00001                   9               9

WMSLocation is filtered by inventLocationId = '00001'

inventLocationId        wmsLocationId           sortCode        aisleId
    00001                   1-07-2-1                11              1
    00001                   1-07-2-2                12              1
    00001                   1-07-2-3                13              1
………
    00001                   1-07-2-20               30              1

    00001                   1-07-2-21               31              2
    00001                   1-07-2-22               32              2
………
    00001                   1-07-2-32               42              2

    00001                   1-07-2-33               43              3
    00001                   1-07-2-34               44              3
………
    00001                   1-07-2-39               49              3

………

    00001                   1-07-2-91               101             9
    00001                   1-07-2-92               102             9
………
    00001                   1-07-2-92               112             9
 

We are trying to determine initialSortCode for aisleId = 3. Aisles less 3 are 1 and 2. For these aisles (1 and 2) maximal sortCode is 42. Therefore in our example initialSortCode is 42.

Updating sort codes

Updating sort codes is pretty easy and works according following algorithm:

sortCode = initialSortCode;
WMSLocation.sortCode = sortCode;
sortCode++;

i.e. each record updating aisle WMSLocation.sortCode is incrimenting by 1.

If WMSAisle.sortDescending is true all the records before updating are arranged by descended rack, ascended level and ascended position.

If WMSAisle.sortDescending is false records are arranged by ascended rack, ascended level and ascended position.

It is useful to mention that records with WMSLocation.manualSortCode = true are excluded from initialSortCode seeking and sort codes updating. And now take a look at WMSOrderTrans table (reservation). At Tables\WMSPickingRoute\Methods\makePickingLine WMSPickingRoute.makePickingLine method we may watch on followng lines:

    select firstonly forupdate WMSOrderTransCopy
        index hint RouteIdx
        where WMSOrderTransCopy.routeId         == WMSOrderTrans.routeId    &&
              WMSOrderTransCopy.fullPallet      == NoYes::No                &&
              WMSOrderTransCopy.recId           == WMSOrderTrans.recId;

    WMSOrderTransCopy.routeId                   = this.pickingRouteID;
    WMSOrderTransCopy.sortCode                  = (WMSLocation) ? WMSLocation.sortCode :

WMSOrderTrans.WMSLocation().sortCode;
    WMSOrderTransCopy.itemSortCode              = inventTable.sortCode;
    WMSOrderTransCopy.volume                    = WMSOrderTrans.qty * inventTable.grossVolume();
    WMSOrderTransCopy.expectedExpeditionTime    = expectedPickTime;
    WMSOrderTransCopy.fullPallet                = NoYes::No;

Here WMSLocation.sortCode and inventTable.sortCode are stored. And the result of sorting codes we may watch in WMSPickForm form where records are arranged by itemSortCode and sortCode.

    queryBuildDataSource.addSortField(fieldNum(WMSOrderTrans, routeId));
    queryBuildDataSource.addSortField(fieldNum(WMSOrderTrans, itemSortCode));
    queryBuildDataSource.addSortField(fieldNum(WMSOrderTrans, sortCode));
    queryBuildDataSource.addSortField(fieldNum(WMSOrderTrans, itemId));
    queryBuildDataSource.addSortField(fieldNum(WMSOrderTrans, dataAreaId));

\Forms\WMSPickForm\Data Sources\WMSOrderTrans\Methods\init()

Therefore itemSortCode is more prevalent than Location sortCode as described in Logistic documentation.

Copyright © 2009 Ruslan Goncharov

No comments: