web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to get all production number without passing any parameter?

(0) ShareShare
ReportReport
Posted on by 210

 public void PlantProduction()
    {
        Query                   query;
        QueryRun                queryrun;
        QueryBuildDataSource    qbdsProdTable;
        QueryBuildDataSource    qbdsProdJournalTable;
        QueryBuildDataSource    qbdsProdJournalRoute;
        QueryBuildDataSource    qbdsProdJournalBom;
        QueryBuildDataSource    qbdsProdTableJour;
        QueryBuildDataSource    qbdsProdJournalProd;
        QueryBuildDataSource    qbdsInventDim;

        QueryBuildRange         qbrInventDim;
        QueryBuildRange         qbrProdTableDate;        
        QueryBuildRange         qbrProdJournalTable;
        QueryBuildRange         qbrProdJournalRoute;
        QueryBuildRange         qbrProdJournalBom;        
        QueryBuildRange         qbrProdTableJour;
        ProdId                  prodId;
        SchedFromDate           schedFromDate, schedToDate;
        InventSiteId            plant;

        TPO_PlantProductionContract     contract;
        contract            =   this.parmDataContract();
        prodId              =   contract.parmProductionNum();
        SchedFromDate       =   contract.parmStartDate();
        schedToDate         =   contract.parmToDate();


        query                   =   new query();            
        qbdsProdTable           =   query.addDataSource(tableNum(ProdTable));
        qbdsProdTable.addRange(fieldNum(ProdTable, ProdId)).value(prodId);
        qbrProdTableDate = qbdsProdTable.addRange(fieldNum(ProdTable, SchedDate));
        qbrProdTableDate.value(queryRange(SchedFromDate, schedToDate));

        qbdsProdJournalRoute    =   qbdsProdTable.addDataSource(tableNum(ProdJournalRoute));
        qbdsProdJournalRoute.addLink(fieldnum(ProdTable, ProdId),fieldnum(ProdJournalRoute, ProdId));
        qbrProdJournalRoute = qbdsProdJournalRoute.addRange(fieldNum(ProdJournalRoute, OprNum));        
        qbrProdJournalRoute = qbdsProdJournalRoute.addRange(fieldNum(ProdJournalRoute, OprPriority));
        qbrProdJournalRoute.value(strFmt('(ItemType == %1)', any2int(RouteOprPriority::Primary)));
        qbrProdJournalRoute.value(strFmt('(ItemType == %1)', any2int(WrkCtrType::Machine)));

        qbdsProdJournalRoute.relations(true);
        qbdsProdJournalRoute.joinMode(joinmode::OuterJoin);

        qbdsProdJournalProd     =   qbdsProdTable.addDataSource(tableNum(ProdJournalProd));
        qbdsProdJournalProd.addLink(fieldnum(ProdTable, ProdId),fieldnum(ProdJournalProd, ProdId));
        qbdsProdJournalProd.relations(true);
        qbdsProdJournalProd.joinMode(joinmode::OuterJoin);

        qbdsProdJournalTable     =   qbdsProdTable.addDataSource(tableNum(ProdJournalTable));
        qbdsProdJournalTable.addLink(fieldnum(ProdTable, ProdId),fieldnum(ProdJournalTable, ProdId));
        qbdsProdJournalTable.relations(true);
        qbdsProdJournalTable.joinMode(joinmode::OuterJoin);

        qbdsProdJournalBom      =   qbdsProdTable.addDataSource(tableNum(ProdJournalBOM));
        qbdsProdJournalBom.addLink(fieldnum(ProdTable, ProdId),fieldnum(ProdJournalBOM, ProdId));
        qbrProdJournalBom = qbdsProdJournalBom.addRange(fieldNum(ProdJournalTable, JournalNameId));
      //  qbrProdJournalBom.value(strFmt('(ItemType == %1)', any2int(JournalNameId Scrap)));
        qbdsProdJournalBom.relations(true);
        qbdsProdJournalBom.joinMode(joinmode::OuterJoin);         
       
       
        queryrun                    = new queryrun(query);
        while(queryrun.next())
        {
            prodtable           =   queryrun.get(tableNum(ProdTable));
            this.PlantProductionTmp();
            prodJournalTable    =   QueryRun.get(tableNum(ProdJournalTable));
            this.prodJournalTableTmp();
            prodJournalRoute    =   QueryRun.get(tableNum(ProdJournalRoute));
            this.prodRouteJournalTmp();
            prodJournalBOM      =   QueryRun.get(tableNum(ProdJournalBOM));
            this.prodJournalBOMTmp();         
        }

    }

    public void PlantProductionTmp()
    {
        plantProductionTmp.clear();
        plantProductionTmp.ProductionNum    =   prodtable.ProdId;
        plantProductionTmp.StartDate        =   prodtable.SchedDate;
        plantProductionTmp.EndDate          =   prodtable.SchedEnd;
        plantProductionTmp.DimId            =   prodtable.InventDimId;
        plantProductionTmp.Plant            =   InventDim::find(plantProductionTmp.DimId).InventSiteId;
        plantProductionTmp.RouteId          =   prodtable.RouteId;
        plantProductionTmp.PODate           =   prodtable.DlvDate;
        plantProductionTmp.ItemId           =   prodtable.ItemId;
        plantProductionTmp.Name             =   prodtable.Name;
        plantProductionTmp.ProdQty          =   prodtable.QtySched;
        plantProductionTmp.insert();

    }

    public void prodRouteJournalTmp()
    {
        prodJournalRouteTmp.JournalId       =   prodJournalRoute.JournalId;
        prodJournalRouteTmp.Section         =   prodJournalRoute.OprId;
        prodJournalRouteTmp.LineNum         =   prodJournalRoute.LineNum;
        prodJournalRouteTmp.ResourceName    =   WrkCtrTable::find(ProdJournalRoute::find(prodJournalRouteTmp.JournalId, prodJournalRouteTmp.LineNum).WrkCtrId).Name;
        prodJournalRouteTmp.ProdId          =   prodJournalRoute.ProdId;
        prodJournalRouteTmp.insert();
    }

    public void prodJournalTableTmp()
    {
        prodJournalTableTmp.JournalId   =   prodJournalTable.JournalId;
        prodJournalTableTmp.TPO_Shift   =   prodJournalTable.TPO_Shift;
        prodJournalTableTmp.ProdId      =   prodJournalTable.ProdId;                  
        prodJournalTableTmp.insert();
    }

    public void prodJournalBOMTmp()
    {
        ProdJournalBOMTmp.Consumption           =   prodJournalBOM.BOMConsump;
        ProdJournalBOMTmp.ProcessWastePerctge   =  ((ProdJournalBOMTmp.Consumption) / (plantProductionTmp.ProdQty)) *100;
        ProdJournalBOMTmp.ProdId                =   prodJournalBOM.ProdId;
        ProdJournalBOMTmp.insert();
    }

}

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,782 Super User 2025 Season 2 on at
    RE: How to get all production number without passing any parameter?

    Hi Vikash,

    You have a title which shows a question. Then in the body, you only pasted some coding. Where exactly do you need help? What is the business requirement that you need to fulfill?

  • vikash_ Profile Picture
    210 on at
    RE: How to get all production number without passing any parameter?

    1184.abc.PNG
    This is my front end contract parameter, I want to get all the production number if I don't pass any value in the parameter.

  • Suggested answer
    Sefa Duman Profile Picture
    1,167 on at
    RE: How to get all production number without passing any parameter?

    Hi Vikash,

    You can use if statement before add range statement. If statement evaluate if production number comes from parameter.

    If(prodId)

    "qbdsProdTable.addRange(fieldNum(ProdTable, ProdId)).value(prodId);" this code will remain in if statement, and must be removed else part. You should write the code on both if and else statements.

    Best regards,

    Sefa Duman

  • Blue Wang Profile Picture
    on at
    RE: How to get all production number without passing any parameter?

    Hi Vikash,

    Have you set your parameters as optional ?

  • vikash_ Profile Picture
    210 on at
    RE: How to get all production number without passing any parameter?

    Hi Blue,

    Yes, i have Parameters as optional.

  • Blue Wang Profile Picture
    on at
    RE: How to get all production number without passing any parameter?

    HI Vikash,

    OK, then I think you can try to set the condition in processReport () and execute the while select statement with no parameter condition ,get records and insert them into the temp table.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 765 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 743

#3
Sumit Singh Profile Picture

Sumit Singh 551

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans