static void DefaultFinancialDimension(Args _args)
{
DimensionAttributeValue dimAttrBUValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue;
DimensionAttribute dimAttrBU,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;
DimensionAttributeValueSetStorage davss;
RecId defaultDimension;
Inventdim inventdim;
PurchTable purchtable;
purchline purchline;
davss = DimensionAttributeValueSetStorage::find(PurchTable::find("PRQ-000000068").DefaultDimension);
dimAttrBU = DimensionAttribute::findByName('BusinessUnit');
dimAtrrCC = DimensionAttribute::findByName('CostCenter');
dimAtrrDep = DimensionAttribute::findByName('Department');
dimAttrIG = DimensionAttribute::findByName('ItemGroup');
dimAtrrProj = DimensionAttribute::findByName('Project');
dimAttrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrBU, "003", false, true);
dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC, "011", false, true);
dimAtrrDepValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrDep, "024", false, true);
dimAttrIGValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrIG, "AudioRM", false, true);
dimAtrrProjValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrProj, "000006", false, true);
if(dimAttrBUValue || dimAtrrCCValue ||dimAtrrDepValue || dimAttrIGValue || dimAtrrProjValue)
{
davss.addItem(dimAttrBUValue);
davss.addItem(dimAtrrCCValue);
davss.addItem(dimAtrrDepValue);
davss.addItem(dimAttrIGValue);
davss.addItem(dimAtrrProjValue);
purchtable = Purchtable::find("PRQ-000000068", true);
purchtable.DefaultDimension = davss.save();
ttsBegin;
purchtable.selectForUpdate(true);
purchtable.update();
ttsCommit;
while select purchline where purchline.PurchId == purchtable.PurchId
{
inventdim.InventSiteId = 'NonHO';
inventdim.InventLocationId = InventDim::find(purchline.InventDimId).InventLocationId;
inventdim = InventDim::findOrCreate(inventdim);
purchline.InventDimId = InventDim.inventDimId;
purchline.DefaultDimension = davss.save();
purchline.selectForUpdate(true);
ttsBegin;
purchline.update();
ttsCommit;
info(strFmt('%1',purchline.InventTransId));
}
}
}
{
DimensionAttributeValue dimAttrBUValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue;
DimensionAttribute dimAttrBU,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;
DimensionAttributeValueSetStorage davss;
RecId defaultDimension;
Inventdim inventdim;
PurchTable purchtable;
purchline purchline;
davss = DimensionAttributeValueSetStorage::find(PurchTable::find("PRQ-000000068").DefaultDimension);
dimAttrBU = DimensionAttribute::findByName('BusinessUnit');
dimAtrrCC = DimensionAttribute::findByName('CostCenter');
dimAtrrDep = DimensionAttribute::findByName('Department');
dimAttrIG = DimensionAttribute::findByName('ItemGroup');
dimAtrrProj = DimensionAttribute::findByName('Project');
dimAttrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrBU, "003", false, true);
dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC, "011", false, true);
dimAtrrDepValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrDep, "024", false, true);
dimAttrIGValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrIG, "AudioRM", false, true);
dimAtrrProjValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrProj, "000006", false, true);
if(dimAttrBUValue || dimAtrrCCValue ||dimAtrrDepValue || dimAttrIGValue || dimAtrrProjValue)
{
davss.addItem(dimAttrBUValue);
davss.addItem(dimAtrrCCValue);
davss.addItem(dimAtrrDepValue);
davss.addItem(dimAttrIGValue);
davss.addItem(dimAtrrProjValue);
purchtable = Purchtable::find("PRQ-000000068", true);
purchtable.DefaultDimension = davss.save();
ttsBegin;
purchtable.selectForUpdate(true);
purchtable.update();
ttsCommit;
while select purchline where purchline.PurchId == purchtable.PurchId
{
inventdim.InventSiteId = 'NonHO';
inventdim.InventLocationId = InventDim::find(purchline.InventDimId).InventLocationId;
inventdim = InventDim::findOrCreate(inventdim);
purchline.InventDimId = InventDim.inventDimId;
purchline.DefaultDimension = davss.save();
purchline.selectForUpdate(true);
ttsBegin;
purchline.update();
ttsCommit;
info(strFmt('%1',purchline.InventTransId));
}
}
}
No comments:
Post a Comment