美文网首页
Ax set default dimension

Ax set default dimension

作者: axxxxxxxx | 来源:发表于2018-04-17 13:49 被阅读0次

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

    相关文章

      网友评论

          本文标题:Ax set default dimension

          本文链接:https://www.haomeiwen.com/subject/udvukftx.html