This post is machine-translated. The original post in german language can be found here.

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

These post applies to following version:
Dynamics AX 2012

 
 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.