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