Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to get all production number without passing any parameter?

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();
    }

}

  • Blue Wang Profile Picture
    Blue Wang 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.

  • vikash_ Profile Picture
    vikash_ 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
    Blue Wang on at
    RE: How to get all production number without passing any parameter?

    Hi Vikash,

    Have you set your parameters as optional ?

  • Suggested answer
    Sefa Duman Profile Picture
    Sefa Duman 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

  • vikash_ Profile Picture
    vikash_ 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.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 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?

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans