更新default dimension 里面的一个field
static void Job34(Args _args)
{
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
DimensionAttributeValueSetStorage davss;
RecId defaultDimension;
VendTable vendTable;
ttsBegin;
select forUpdate vendTable where vendTable.AccountNum == 'CPMUNC-1AP01';
davss = DimensionAttributeValueSetStorage::find(vendTable.DefaultDimension);
dimAttr = DimensionAttribute::findByName("A_Country");
dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, "HKG", false, true);
if(dimAttrValue)
{
davss.addItem(dimAttrValue);
vendTable.DefaultDimension = davss.save();
vendTable.update();
}
ttsCommit;
info("Done");
}
// get default dimension
DimensionDefault getNewDefaultDim(DimensionDefault _defaultDimension, str _orgIdx)
{
#define.DimName("A")
#define.DimValue("B")
DimensionAttributeValueSetStorage dimStorageLocal;
DimensionAttribute DimensionAttribute;
DimensionAttributeValue dimAttributeValue;
Name dimName=#DimName;
str dimValue=#DimValue;
dimStorageLocal = DimensionAttributeValueSetStorage::find(_defaultDimension);
DimensionAttribute = DimensionAttribute::findByName(dimName);
if(dimValue)
{
dimValue = subStr(_orgIdx,4,3) +"~"+subStr(_orgIdx,7,3)+"~"+ dimValue;
dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute, dimValue, true, true);
dimStorageLocal.addItem(dimAttributeValue);
}
else
dimStorageLocal.removeDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
return dimStorageLocal.save();
}
网友评论