Jan*_*sen 10 axapta dynamics-ax-2012
我的问题是设置从外部源读取的一些维度值.
鉴于AX 2009声明:
ledgerJournalTrans.Dimension = ledgerTable.Dimension;
ledgerJournalTrans.Dimension[1] = "abc";
Run Code Online (Sandbox Code Playgroud)
与AX 2012相同的方法是什么?
这将导致假设存在"部门"维度作为第一维度.
dla*_*oye 16
首先,AX 2009中的遗留维度已经完全重做并在AX 2012中被替换.新的LedgerDimension是帐户和基于帐户结构和高级规则结构所需的旧维度值的组合.要了解有关AX 2012中新维度框架的更多信息,请阅读有关新维度框架的白皮书.
假设Department是第一个维度,并且两个维度都使用LedgerDimensionAccount EDT简化了这个场景,但是新维度框架非常灵活,因此这个假设可能不正确.即使是这样,只是为Department指定一个新值可能需要组合的结构需要大幅改变,因为可以设置高级规则结构.
老实说,我只考虑下面的代码只是演示一些基础知识是如何工作的,而不是应该在生产中使用的东西.如上所述,如果LedgerTable上的Dimension字段已使用存储完整组合的LedgerDimensionAccount EDT替换为LedgerDimension字段,则此代码应完成您想要的操作.
DimensionStorage dimensionStorage;
DimensionAttribute deparmentDimensionAttribute;
DimensionAttributeValue newDepartmentValue;
// Find the deparment dimension attribute
deparmentDimensionAttribute = DimensionAttribute::findByName("Department");
// Find the new department value we want to put in the new combination.
newDepartmentValue = DimensionAttributeValue::findByDimensionAttributeAndValue(deparmentDimensionAttribute, "abc");
// Load a DimensionStorage instance with the old combination and update the first segment with new value
dimensionStorage = DimensionStorage::findById(ledgerTable.LedgerDimension);
dimensionStorage.setSegment(1,DimensionStorageSegment::constructFromValue("abc", newDepartmentValue));
ledgerJournalTrans.LedgerDimension = dimensionStorage.save();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43541 次 |
| 最近记录: |