首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在ax 2012中传递财务维度组合值

在ax 2012中传递财务维度组合值
EN

Stack Overflow用户
提问于 2015-01-20 22:35:05
回答 1查看 3.7K关注 0票数 2

我需要将普通日记帐(表:分类帐日记帐表)表单的分类帐维度值连同组合值一起传递到LedgerJournalTransDaily(Table:LedgerJournalTrns)表单。例如:

在普通日记账表单中,我创建了一个新的日记账,日记账名称为“分配”(账号维度类似于1003),在财务维度选项卡中,我选择了成本中心(024)、部门(001)、目的(培训),之后我点击了行,然后是一个新的表单LedgerJournalTransDaily。在起始网格一个名为Account Num的字段中,在该段字段中,我需要分类帐维度值以及选定的组合值。如1003-024-001-培训

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2015-04-23 23:12:59

抵销账号是标题表中唯一的分类帐维,因此我假设您想要使用它,但是您可以将此逻辑应用于任何维组合(假设分类帐帐户类型为Ledger)。要将分类帐维与LedgerJournalTable中的分类帐维字段合并,流程如下:

首先,我们将从抵销分类帐维度中检索帐号。您可以使用一个简单的基本AX方法来完成此操作:

代码语言:javascript
运行
复制
accountNum = DimensionStorage::ledgerDimension2AccountNum(journalTable.OffsetLedgerDimension);

接下来,LedgerJournalTable上的财务维度。

背景信息:这些维度存储在引用表DimensionAttributeValueSet的字段DefaultDimension中。这个表本身可能看起来没有什么用处,但它是一个交叉引用。加入DimensionAttributeValueSetItem表,该表的DimensionAttributeValueSet字段等于DimensionAttributeValueSet.RecId。您将看到已选择的尺寸属性及其显示值:

代码语言:javascript
运行
复制
LedgerJournalTable journalTable;
DimensionAttributeValueSet attributeValueSet;
DimensionAttributeValueSetItem attributeValueSetItem;

while select DisplayValue from attributeValueSetItem 
    exists join attributeValueSet
    where attributeValueSet.RecId == attributeValueSetItem.DimensionAttributeValueSet
        exists join journalTable
        where journalTable.DefaultDimension == attributeValueSet.RecId
        && journalTable.RecId               == 52565497166
{
    info(attributeValueSetItem.DisplayValue);
}

现在我们有了DimensionAttributeValueSetItem记录,也有了存储在DimensionAttribute中的DimensionAttributeValue和顶层维度信息。我们需要所有这些桌子!相当激烈,对吧?您可以创建一个庞大的while循环来遍历每个单独的维度,将其添加到一个容器中,并将其与先前检索到的Account Num组合在一起。容器必须非常明确地构建为使用基本的ax维度实用程序方法(或者至少是我所知道的方法)。

下面是一个简单的工作,它有效地完成了我所描述的工作。为了方便起见,我亲手挑选了一本日记。

代码语言:javascript
运行
复制
LedgerJournalTable                  journalTable = LedgerJournalTable::findByRecId(52565497166);
DimensionAttribute                  dimensionAttribute;
DimensionAttributeValue             dimensionAttributeValue;
DimensionAttributeValueSet          attributeValueSet;
DimensionAttributeValueSetItem      attributeValueSetItem;
DimensionAttributeValueCombination  davc;
AccountNum                          accountNum;
container                           newLedgerDimension;
int                                 numOfDims;
int                                 i;
str                                 displayValue;
DimensionDynamicAccount             dynamicDimension;

// Get Account Num.
accountNum = DimensionStorage::ledgerDimension2AccountNum(journalTable.OffsetLedgerDimension);
info(AccountNum);

// Add account to container.
newLedgerDimension = [accountNum];

// Add dimensions to the container.
while select attributeValueSetItem
    join RecId from attributeValueSet
    where attributeValueSet.RecId       == attributeValueSetItem.DimensionAttributeValueSet 
    &&    journalTable.DefaultDimension == attributeValueSet.RecId
        join RecId, DimensionAttribute from dimensionAttributeValue
        where dimensionAttributeValue.RecId == attributeValueSetItem.DimensionAttributeValue
            join RecId, Name from dimensionAttribute
            where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute
{
    // Add the dimension name and dimension value
    newLedgerDimension += [dimensionAttribute.Name, attributeValueSetItem.DisplayValue];

    // Keep track of the number of dimensions.
    ++numOfDims;
}

// Combine the account and dimensions into one value.
for (i=1; i<=(numOfDims+1)*2; i+=2)
{
    displayValue += conPeek(newLedgerDimension, i) + '-';
}

// The display value of the combination must be in the first index of the container.
newLedgerDimension = conIns(newLedgerDimension, 1, displayValue);

// The number of dimensions must be in the third index of the container.
newLedgerDimension = conIns(newLedgerDimension, 3, int2str(numOfDims));

info(displayValue);

// Lastly, create the dimension.
dynamicDimension = AxdDimensionUtil::getLedgerAccountId(newLedgerDimension);

info(int642str(dynamicDimension));

如果一切正常,您已经成功地创建了一个组合!您可以通过查找刚在DimensionAttributeValueCombination中创建的尺寸来进行调整。此组合现在可以是LedgerJournalTrans.LedgerDimension中的RecId

需要注意的是,维度实用程序只会根据您配置的帐户结构应用适用的维度。这是在总账模块->设置->科目表->配置科目结构中配置的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28047920

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档