public void lookup(FormControl _formControl, str _filterStr) { ; //super(_formControl, _filterStr); CustRequestItemTable.InventDimId = InventDim::findOrCreate(inventDim).InventDimId; if (CustRequestItemTable.InventDimId != inventDim.InventDimId) { inventDim.data(InventDim::find(CustRequestItemTable.InventDimId)); inventDim_ds.setCurrent(); } YIP_CustRequestItemTable::lookupInventTransIdByItemDim(_formControl, CustRequestItemTable, CustRequestItemTable.joinChild()); } -------------------------- public void modified() { InventTrans inventTransLocal; InventDimParm inventDimParm; InventDim inventDimJoin; InventDim inventDimCriteria, inventDimCur; ; super(); inventDimCriteria = CustRequestItemTable.joinChild(); inventDimCriteria.clearNotActiveDim(CustRequestItemTable.inventTable().DimGroupId); inventDimParm.initFromInventDim(inventDimCriteria); inventDimParm.InventLocationIdFlag = Noyes::No; inventDimCriteria = InventDim::findOrCreate(inventDimCriteria); select firstonly inventTransLocal where inventTransLocal.InventTransId == CustRequestItemTable.InventTransId && inventTransLocal.StatusIssue == StatusIssue::Sold && inventTransLocal.TransType == InventTransType::Sales #InventDimExistsjoin(inventTransLocal.InventDimId,inventDimJoin,inventDimCriteria, inventDimParm); if (!inventTransLocal) { inventDimParm.InventBatchIdFlag = Noyes::No; select firstonly inventTransLocal where inventTransLocal.InventTransId == CustRequestItemTable.InventTransId && inventTransLocal.StatusIssue == StatusIssue::Sold && inventTransLocal.TransType == InventTransType::Sales #InventDimExistsjoin(inventTransLocal.InventDimId,inventDimJoin,inventDimCriteria, inventDimParm); } if (!inventTransLocal) { inventDimParm.ConfigIdFlag = Noyes::No; select firstonly inventTransLocal where inventTransLocal.InventTransId == CustRequestItemTable.InventTransId && inventTransLocal.StatusIssue == StatusIssue::Sold && inventTransLocal.TransType == InventTransType::Sales #InventDimExistsjoin(inventTransLocal.InventDimId,inventDimJoin,inventDimCriteria, inventDimParm); } if (inventTransLocal) { inventDimCur = inventTransLocal.inventDim(); if (inventDimCriteria.InventLocationId) inventDimCur.InventLocationId = inventDimCriteria.InventLocationId; if (inventDimCriteria.inventBatchId) inventDimCur.inventBatchId = inventDimCriteria.inventBatchId; if (inventDimCriteria.configId) inventDimCur.configId = inventDimCriteria.configId; inventDimCur = inventDim::findOrCreate(inventDimCur); CustRequestItemTable.InventDimId = inventDimCur.inventDimId; CustRequestItemTable.ItemId = CustRequestItemTable.ItemId ? CustRequestItemTable.ItemId : inventTransLocal.ItemId; CustRequestItemTable.validateWrite(); } if (CustRequestItemTable.InventDimId != inventDim.InventDimId) { inventDim.data(InventDim::find(CustRequestItemTable.InventDimId)); inventDim_ds.setCurrent(); } } ----------------------------- // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 public static void lookupInventTransIdByItemDim( FormControl _formControl, YIP_CustRequestItemTable _table, InventDim _inventDim) { SysTableLookup lookup = SysTableLookup::newParameters(tablenum(SalesLine), _formControl); Query q = new Query(); queryRun qr; QueryBuildDataSource qbds, qbdsTrans, qbdsDim; QueryBuildRange qbr; SalesLine tmpTable, salesLine; set set = new set(types::String); ; qbds = q.addDataSource(tablenum(SalesLine)); qbds.addRange(fieldnum(SalesLine, ItemId)).value(_table.ItemId); qbr = qbds.addRange(fieldnum(SalesLine, SalesStatus)); qbr.value(queryValue(SalesStatus::Invoiced));//+","+queryValue(SalesStatus::Delivered)); if (_table.CustAccount) qbds.addRange(fieldnum(SalesLine, CustAccount)).value(_table.CustAccount); if (_table.SalesId) qbds.addRange(fieldnum(SalesLine, SalesId)).value(_table.SalesId); if (_inventDim.inventBatchId || _inventDim.configId) { qbdsTrans = qbds.addDataSource(tablenum(InventTrans)); qbdsTrans.addLink(fieldnum(SalesLine, InventTransId), fieldnum(InventTrans, InventTransId)); qbdsDim = qbdsTrans.addDataSource(tablenum(InventDim)); //qbdsDim.addLink(fieldnum(InventTrans, InventDimId), fieldnum(InventDim, InventDimId)); qbdsDim.joinMode(JoinMode::InnerJoin); qbdsDim.relations(true); if (_inventDim.inventBatchId) qbdsDim.addRange(fieldnum(InventDim, InventBatchId)).value(_inventDim.inventBatchId); if (_inventDim.configId) qbdsDim.addRange(fieldnum(InventDim, configId)).value(_inventDim.configId); } tmpTable.setTmp(); qr = new queryRun(q); while (qr.next()) { salesLine = qr.getNo(1); if (!set.in(salesLine.InventTransId)) { tmpTable.SalesId = salesLine.SalesId; tmpTable.InventTransId = salesLine.InventTransId; tmpTable.CustAccount = salesLine.CustAccount; tmpTable.ItemId = salesLine.ItemId; tmpTable.SalesQty = salesLine.SalesQty; tmpTable.SalesPrice = salesLine.SalesPrice; tmpTable.SalesStatus = salesLine.SalesStatus; tmpTable.doinsert(); set.add(salesLine.InventTransId); } } if (set.elements()) { lookup.addLookupfield(fieldnum(SalesLine, InventTransId),true); lookup.addLookupfield(fieldnum(SalesLine, CustAccount)); lookup.addLookupfield(fieldnum(SalesLine, SalesId)); lookup.addLookupfield(fieldnum(SalesLine, ItemId)); lookup.addLookupfield(fieldnum(SalesLine, SalesQty)); lookup.addLookupfield(fieldnum(SalesLine, SalesPrice)); lookup.addLookupfield(fieldnum(SalesLine, SalesStatus)); lookup.parmTmpBuffer(tmpTable); lookup.performFormLookup(); } else { lookup.addLookupfield(fieldnum(SalesLine, InventTransId),true); lookup.addLookupfield(fieldnum(SalesLine, CustAccount)); lookup.addLookupfield(fieldnum(SalesLine, SalesId)); lookup.addLookupfield(fieldnum(SalesLine, ItemId)); lookup.addLookupfield(fieldnum(SalesLine, SalesQty)); lookup.addLookupfield(fieldnum(SalesLine, SalesPrice)); lookup.addLookupfield(fieldnum(SalesLine, SalesStatus)); lookup.parmQuery(q); lookup.performFormLookup(); } }