最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

验证财务维度组合/Validate financial dimension combination

网络文摘 William 828浏览 0评论
Hi Folks,
Often we need to create Journals via X++ code as part of customization or integration and dimension is always the tricky part of this. How to validate the dimension combination value as per rules set in the system.
I am sharing a code sample to do the same, check this code and you may need to replace some dimension names or add/remove dimensions as per your requirement. The below code sample will validate
1. Main account
2. Individual dimension value
3. Deactivated dimension values
4. Dimension combination
MainAccount mainAccount;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttribute dimensionAttribute;
container dimCon = str2con(myTable.AccountDisplayValue, "-"); // This will break dimension combinaiton into different fields
LedgerAccountValidationContract validationContract;
LedgerAccountContract accountContract;
DimensionAttributeValueContract valueContract;
FinancialDimensionValidationService service;
List listValueContract = new List(Types::Class);
// division
if(conPeek(dimCon, 2) != "") // Use this code to pick dimension as per appear in combination, eg. Division is the dimension which appears at position 2 in dimension value
{
valueContract = new DimensionAttributeValueContract();
valueContract.parmName("Division"); //Dimension name
valueContract.parmValue(conPeek(dimCon, 2)); //Position within dimension value
listValueContract.addEnd(valueContract);
}
// Cost centre
if(conPeek(dimCon, 3) != "")
{
valueContract = new DimensionAttributeValueContract();
valueContract.parmName("CostCentre");
valueContract.parmValue(conPeek(dimCon, 3));
listValueContract.addEnd(valueContract);
}
// Business unit
if(conPeek(dimCon, 4) != "")
{
valueContract = new DimensionAttributeValueContract();
valueContract.parmName("BusinessUnit");
valueContract.parmValue(conPeek(dimCon, 4));
listValueContract.addEnd(valueContract);
}
accountContract = new LedgerAccountContract();
accountContract.parmMainAccount(conPeek(dimCon, 1));
accountContract.parmValues(listValueContract);
validationContract = new LedgerAccountValidationContract();
validationContract.parmLedgerAccount(accountContract);
validationContract.parmValidDate(systemDateGet());
service = new FinancialDimensionValidationService();
if (!service.validateLedgerAccount(validationContract))
{
ret = false;
erroMessages = strFmt("Dimension combination is in valid");
}
-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址