D365FFO – AX – X++ – Query On-Hand inventory using specific inventory-dimensions

Using the class InventDimOnhand, you can determine the on-hand inventory of articles and/or specific inventory-dimensions.

The following job determines the inventory for a specific item and a specific inventlocation. This is grouped per color.

static void getInventOnhandExample(Args _args)
{
    ItemId itemId;
    InventDimOnHand inventDimOnHand;
    InventDimParm inventDimParmOnHandLevel;
    InventDimOnHandIterator inventDimOnHandIterator;
    InventDimOnHandMember inventDimOnHandMember;
    InventDim inventDim;
    InventDim inventDimCriteria;
    InventDimParm inventDimParmCriteria;

    // Item: Query specific item
    itemId = "DMO003";
    
    // inventDimCriteria: Apply ranges
    inventDimCriteria.wmsLocationId             = "12-1";
    inventDimCriteria.InventBatchId             = "DMOBatch001";

    // inventDimParmCriteria: should values from inventDimCriteria be used?
    inventDimParmCriteria.ItemIdFlag            = false;
    inventDimParmCriteria.InventSiteIdFlag      = false;
    inventDimParmCriteria.InventLocationIdFlag  = false;
    inventDimParmCriteria.wmsLocationIdFlag     = true;     // wmsLocationId from inventDimCriteria will be used
    inventDimParmCriteria.wmsPalletIdFlag       = false;
    inventDimParmCriteria.InventBatchIdFlag     = false;    // inventBatchId from inventDimCriteria will not be used
    inventDimParmCriteria.InventSerialIdFlag    = false;
    inventDimParmCriteria.ConfigIdFlag          = false;
    inventDimParmCriteria.InventSizeIdFlag      = false;
    inventDimParmCriteria.InventColorIdFlag     = false;
    inventDimParmCriteria.InventStyleIdFlag     = false;

    // inventDimParmOnHandLevel: Which dimensions should be used to group for?
    // inventDimParmOnHandLevel necessary for inventDimOnHandLevel::DimParm
    inventDimParmOnHandLevel.ItemIdFlag            = true;      // necessary
    inventDimParmOnHandLevel.InventSiteIdFlag      = false;
    inventDimParmOnHandLevel.InventLocationIdFlag  = false;
    inventDimParmOnHandLevel.wmsLocationIdFlag     = false;
    inventDimParmOnHandLevel.wmsPalletIdFlag       = false;
    inventDimParmOnHandLevel.InventBatchIdFlag     = false;
    inventDimParmOnHandLevel.InventSerialIdFlag    = false;
    inventDimParmOnHandLevel.ConfigIdFlag          = false;
    inventDimParmOnHandLevel.InventSizeIdFlag      = false;
    inventDimParmOnHandLevel.InventColorIdFlag     = true;      // group by color
    inventDimParmOnHandLevel.InventStyleIdFlag     = false;

    inventDimOnHand = InventDimOnHand::newAvailPhysical(itemId,
                                                        inventDimCriteria,
                                                        inventDimParmCriteria,
                                                        InventDimOnHandLevel::DimParm,
                                                        inventDimParmOnHandLevel);

    inventDimOnHandIterator = inventDimOnHand.onHandIterator();
    while (inventDimOnHandIterator.more())
    {
        inventDimOnHandMember = inventDimOnHandIterator.value();

        inventDim = InventDim::find(inventDimOnHandMember.parmInventDimId());

        info(con2Str([  inventDimOnHandMember.parmItemId(),
                        inventDim.InventSiteId,
                        inventDim.InventLocationId,
                        inventDim.wmsLocationId,
                        inventDim.wmsPalletId,
                        inventDim.InventBatchId,
                        inventDim.InventSerialId,
                        inventDim.ConfigId,
                        inventDim.InventSizeId,
                        inventDim.InventColorId,
                        inventDim.InventStyleId,
                        inventDimOnHandMember.parmInventQty()]));

        inventDimOnHandIterator.next();
    }
}

The output of the above job looks is an infolog like the following:

DMO003,,,12-1,,,,,,Cherry,,54
DMO003,,,12-1,,,,,,Black,,100

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...