Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

In Critical on hand inventory report want to add maximum quantity same as minimum

(2) ShareShare
ReportReport
Posted on by 1,883
Hi Experts,
 
I want to add maximum quantity in critical on hand inventory report. Difficulty is where I should put code and what in class InventSumCriticalInt and how to add my new report to user interface(subcribe new report design).
 
 
Thanks,
Faiz
 
 
  • Verified answer
    faiz7049 Profile Picture
    faiz7049 1,883 on at
    In Critical on hand inventory report want to add maximum quantity same as minimum
    This thread is closed. I created separate report based on min max from reqItemTable.
     
    Thank you.
    Faiz 
  • faiz7049 Profile Picture
    faiz7049 1,883 on at
    In Critical on hand inventory report want to add maximum quantity same as minimum
    Hi Experts,
     
    Please could you check my below extension code. What is missing in it.
     
    [ExtensionOf(classStr(InventSumCriticalInit))]
    
    final public class SFA_InventSumCriticalInit_Extension
    {
    
                public void processInventSumCriticalRecords()
            {
                next processInventSumCriticalRecords();
            
                QueryRun queryRun = new QueryRun(this.criticalOnHandQuery);
                ReqItemTable reqItemTable;
                InventDim inventDim;
                ItemId itemId;
                InventDimParm inventDimParm;
                InventDimGroupSetup inventDimGroupSetup;
                ReqSetup reqSetup;
    
                while (queryRun.next())
                {
                    if (queryRun.changed(tableNum(ReqItemTable)))
                    {
                        reqItemTable = queryRun.get(tableNum(ReqItemTable));
                        if (itemId != reqItemTable.ItemId)
                        {
                            itemId = reqItemTable.ItemId;
    
                            reqSetup = ReqSetup::newItemId(itemId);
                            inventDimGroupSetup = InventDimGroupSetup::newItemId(itemId);
                            inventDimParm.initCovPrDimension(inventDimGroupSetup);
                        }
                    }
    
                    inventDim = queryRun.get(tableNum(InventDim));
    
                    // Custom logic to include maximum quantity
                    this.insertPhysicalOnhandBelowMinimumQuantity_Extended(
                    reqSetup,
                    itemId,
                    inventDim,
                    inventDimParm,
                    inventDimGroupSetup);
                }
            }
    
            private void insertPhysicalOnhandBelowMinimumQuantity_Extended(
            ReqSetup _reqSetup,
            ItemId _itemId,
            InventDim _inventDim,
            InventDimParm _inventDimParm,
            InventDimGroupSetup _inventDimGroupSetup)
            {
               InventDim inventDimCoverage = InventDim::find(_inventDim.reqCovDimId(_inventDimGroupSetup));
               
                InventQtyMaxOnhand maximumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).maxInventOnHand(); // Fetch max quantity
                  
                    this.initTmpTable_Extended(maximumOnHandQuantity);
                    this.insertTmpTable();
             }
    
            protected void initTmpTable_Extended(InventQtyMaxOnhand _maximumOnHandQuantity) // Add max quantity parameter
            {
              
              
                inventSumCriticalTmp.QtyMaxOnhand = _maximumOnHandQuantity; // Store max quantity
              
            }
    
    }
     
  • faiz7049 Profile Picture
    faiz7049 1,883 on at
    In Critical on hand inventory report want to add maximum quantity same as minimum
    Hi Experts,

    Maximum quantity is not showing in Critical on hand inventory report. Could you please help my extension code.
     


    ​​​​​​​
  • faiz7049 Profile Picture
    faiz7049 1,883 on at
    In Critical on hand inventory report want to add maximum quantity same as minimum
    Hi Experts,
     
    Could you please check my approach is correct in below X++ code.
     
    [ExtensionOf(classStr(InventSumCriticalInit))]
    
    final public class SFA_InventSumCriticalInit_Extension
    {
    
            public void processInventSumCriticalRecords()
            {
                next processInventSumCriticalRecords();
            
                QueryRun queryRun = new QueryRun(this.criticalOnHandQuery);
                ReqItemTable reqItemTable;
                InventDim inventDim;
                ItemId itemId;
                InventDimParm inventDimParm;
                InventDimGroupSetup inventDimGroupSetup;
                ReqSetup reqSetup;
    
                while (queryRun.next())
                {
                    if (queryRun.changed(tableNum(ReqItemTable)))
                    {
                        reqItemTable = queryRun.get(tableNum(ReqItemTable));
                        if (itemId != reqItemTable.ItemId)
                        {
                            itemId = reqItemTable.ItemId;
    
                            reqSetup = ReqSetup::newItemId(itemId);
                            inventDimGroupSetup = InventDimGroupSetup::newItemId(itemId);
                            inventDimParm.initCovPrDimension(inventDimGroupSetup);
                        }
                    }
    
                    inventDim = queryRun.get(tableNum(InventDim));
    
                    // Custom logic to include maximum quantity
                    this.insertPhysicalOnhandBelowMinimumQuantity_Extended(
                    reqSetup,
                    itemId,
                    inventDim,
                    inventDimParm,
                    inventDimGroupSetup);
                }
            }
    
            private void insertPhysicalOnhandBelowMinimumQuantity_Extended(
            ReqSetup _reqSetup,
            ItemId _itemId,
            InventDim _inventDim,
            InventDimParm _inventDimParm,
            InventDimGroupSetup _inventDimGroupSetup)
            {
                InventDim inventDimCoverage = InventDim::find(_inventDim.reqCovDimId(_inventDimGroupSetup));
                InventQtyMinOnhand minimumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).minInventOnHand();
                InventQtyMaxOnhand maximumOnHandQuantity = ReqSetupDim::newCovInventDimId(_reqSetup, inventDimCoverage.InventDimId).maxInventOnHand(); // Fetch max quantity
    
                InventSum inventSumOnHand  = InventOnHandQty::newItemDim(_itemId, inventDimCoverage, _inventDimParm).inventSum();
    
                if (inventSumOnHand.physicalInventCalculated() < minimumOnHandQuantity)
                {
                    this.initTmpTable_Extended(inventSumOnHand, _inventDim, minimumOnHandQuantity, maximumOnHandQuantity);
                    this.insertTmpTable();
                }
            }
    
            protected void initTmpTable_Extended(
            InventSum _inventSumOnHand,
            InventDim _inventDim,
            InventQtyMinOnhand _minimumOnHandQuantity,
            InventQtyMaxOnhand _maximumOnHandQuantity) // Add max quantity parameter
            {
                InventIAvailability inventAvailability = InventAvailabilityProvider::findBySumDim(_inventSumOnHand, _inventDim).parmInventAvailability();
                inventSumCriticalTmp.QtyMinOnhand = _minimumOnHandQuantity;
                inventSumCriticalTmp.QtyMaxOnhand = _maximumOnHandQuantity; // Store max quantity
                inventSumCriticalTmp.ItemId = _inventSumOnHand.ItemId;
                inventSumCriticalTmp.InventDimFieldsMap::initAllDimensionsFrom(_inventDim);
                inventSumCriticalTmp.Ordered = inventAvailability.ordered();
                inventSumCriticalTmp.ItemName = _inventSumOnHand.itemName();
                inventSumCriticalTmp.PhysicalInvent = _inventSumOnHand.physicalInventCalculated();
            }
        }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans