在AX 2012中传递财务维度组合值 [英] Passing Financial Dimension combination values in ax 2012
问题描述
我需要将常规日记帐(Table:LedgerJournalTable)表格的Ledger维度值连同组合值一起传递给LedgerJournalTransDaily(Table:LedgerJournalTrns)表格. 例如:
I need to pass Ledger Dimension value for General Journal (Table:LedgerJournalTable) form to LedgerJournalTransDaily(Table:LedgerJournalTrns) form along with combination values. EX:
在普通日记帐"表单中,我将创建一个日记帐名称为"Alloc"的新日记帐(分类帐维度类似于1003),在财务维度"选项卡中,我选择成本中心"(024),部门"(001),目的"(培训)之后,我点击了几行,然后点击了一个新表格LedgerJournalTransDaily.在来自网格的一个称为帐户编号"的字段中,在该细分字段中,我需要分类帐维值以及所选的组合值.就像1003-024-001-培训
In General Journal form I am creating a new journal with the journal name "Alloc"(ledger dimension is like 1003), and in Financial dimension tab I am selecting Cost centre(024), department(001), purpose(training) after that I am clicking on lines, then a new form LedgerJournalTransDaily. In the from grid one filed called Account Num, in that segment field I need ledger dimension value along with selected combination value. like 1003-024-001-Training
预先感谢
推荐答案
抵销科目编号是抬头表上唯一的分类帐维,因此,我假设您要使用该逻辑,但是您可以将此逻辑应用于任何维组合(假设分类帐科目类型为分类帐).要将分类帐维与LedgerJournalTable的分类帐维字段组合在一起,过程如下:
The Offset Account Num is the only ledger dimension on the header table, so I'll assume you want to use that, however you can apply this logic with any dimension combination (assuming the ledger account type is Ledger). To combine the ledger dimension with the ledger dimensions fields from LedgerJournalTable, The process is as follows:
首先,我们将从偏移分类帐维中检索帐户编号".您可以使用简单的基本AX方法来做到这一点:
First we'll retrieve the Account Num from the offset ledger dimension. You can do this with a simple base AX method:
accountNum = DimensionStorage::ledgerDimension2AccountNum(journalTable.OffsetLedgerDimension);
接下来,LedgerJournalTable
上的财务维度.
Next, the financial dimensions on the LedgerJournalTable
.
背景信息:这些尺寸存储在字段DefaultDimension
中,该字段引用表DimensionAttributeValueSet
.该表本身似乎似乎没有用,但它是一个交叉引用.连接DimensionAttributeValueSetItem
表,其中DimensionAttributeValueSet
字段等于DimensionAttributeValueSet.RecId
.您将看到已选择的尺寸属性及其显示值:
Background info: these dimensions are stored in the field DefaultDimension
, which references the table DimensionAttributeValueSet
. This table in itself may not seem useful, but it is a cross-reference. Join the DimensionAttributeValueSetItem
table where its DimensionAttributeValueSet
field equals DimensionAttributeValueSet.RecId
. You will see the dimension attributes and their display values that have been selected:
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
记录,现在我们还具有DimensionAttributeValue
和存储在DimensionAttribute
中的顶层尺寸信息.我们需要所有这些表!很激烈吧?您可以创建一个庞大的while循环以遍历每个单独的维度,将其添加到容器中,然后将其与先前获取的Account Num组合.必须非常专门地构建容器,以与基本斧头尺寸实用程序方法(或至少我所知道的方法)一起使用.
Now we have the DimensionAttributeValueSetItem
records, we also now have the DimensionAttributeValue
and the top tier dimension information stored in DimensionAttribute
. We need all these tables! Pretty intense right? You can create a hefty while loop to go through each individual dimension, add it to a container, and combine it with the Account Num retrieved earlier. The container has to be built very specifically to work with the base ax dimension utility methods (or at least the ones I am aware of).
以下是一项简单的工作,可以有效地完成我所描述的工作.为了方便起见,我亲自挑选了日记.
Below is a simple job that effectively does what I have described. I've hand-picked a journal for convenience.
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
If all works out, you have successfully created a combination! You can varify by finding the dimension you just created in DimensionAttributeValueCombination
. This combination can now be the RecId in LedgerJournalTrans.LedgerDimension
应注意,维度实用程序将仅应用基于您配置的帐户结构适用的维度.在总帐"模块>设置>帐户图表>配置帐户结构中进行配置.
It should be noted that the dimension utility will only apply dimensions that are applicable based on your configured account structure. This is configured in General Ledger module > Setup > Chart of accounts > Configure account structures.
这篇关于在AX 2012中传递财务维度组合值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!