Ho preso come riferimento quello che lo standard fà quì:
\Classes\ReqCalc\covCreatePlannedOrder()
server void CONcreatePlannedOrderFromJFlex(
InventLocationId _fromInventLocationId = '',
InventLocationId _toInventLocationId = ''
)
{
ReqCalcExplodePo reqCalcExplodePo;
ReqTrans reqTransPo;
ReqTrans transferDemand;
InventDim inventDimDemand;
ReqPlanData reqPlanData;
InventDim inventDim;
inventSite inventSite;
InventDimGroupId dimGroupId;
;
inventDim.InventSiteId = (select firstonly SiteId from inventSite).siteId;
inventDim = InventDim::findOrCreate(inventDim);
this.ReqPlanId = cONJFLEXParameters.ReqPlanId;
this.RefType = ReqPO::reqPoType2ReqRefType(ReqPoType::Purch);
this.ReqDateDlv = today();
this.initFromItemId("lillilor");
this.Qty = 10;
this.VendId = "lillilor";
dimGroupId = InventTable::find("lillilor").DimGroupId;
inventDim.clearNotCovPrDim(dimGroupId);
if (! this.validateWrite())
throw Exception::Error;
ttsbegin;
this.initPurchQty();
reqPlanData = ReqPlanData::newReqPlanId(this.ReqPlanId);
this.RefId = NumberSeq::newGetNumFromCode(reqPlanData.sequencePlannedOrder()).num();
this.CovInventDimId = InventDim::findOrCreate(inventDim).InventDimId;
/*
Must BOM and Route be created
*/
if (this.RefType == ReqRefType::BOMPlannedOrder)
{
if (reqPlanData.mustTransBeExploded(this.reqSetupDim(),this))
this.setBOMCreated( this.ItemBomId ? true : false);
if (reqPlanData.mustTransBeScheduled(this.reqSetupDim(),this))
this.setRouteCreated(this.ItemRouteId ? true : false);
}
this.insert();
reqTransPo.ReqDateDlvOrig = this.ReqDateDlv;
reqTransPo.Level = this.reqSetup().itemLevel();
reqTransPo.insertFromReqPo(this,false,reqPlanData);
if (this.RefType == ReqRefType::BOMPlannedOrder || this.RefType == ReqRefType::TransferPlannedOrder)
{
if (this.RefType == ReqRefType::TransferPlannedOrder)
{
transferDemand = reqTransPo.reqTransTransferDemand(true);
if (transferDemand.RecId)
{
inventDimDemand = transferDemand.inventDim();
inventDimDemand.InventLocationId = _fromInventLocationId;
inventDimDemand.initFromInventLocation(inventDimDemand.inventLocation(), dimGroupId);
transferDemand.CovInventDimId = InventDim::findOrCreate(inventDimDemand).InventDimId;
transferDemand.update();
}
}
reqCalcExplodePo = ReqCalcExplode::newReqTrans(reqTransPo,null);
reqCalcExplodePo.run();
reqCalcExplodePo.refreshUpdatedReqPo(this);
}
ttscommit;
}
Riferimeti:
https://community.dynamics.com/ax/f/33/t/136809
Nessun commento:
Posta un commento