I finally learned...A basic dimension is a default dimension. This is a value that concatenates a number of dimension values and is located in the Dimension Attribute Value Combination Table. If you add a Main Account, then you have a Ledger Dimension. The combination that you may try to retrieve or create MUST be part of the Main Account's Account Structure.
There are 2 approaches to getting a Ledger Dimension
1) Query it with AxdDimensionUtil::getLedgerAccountId
2) Create or retrieve it with DimensionDefaultingService::serviceCreateLedgerDimension
The code to retrieve a Ledger Dimension is:
private DimensionDefault getLedgerDimension(MainAccountNum _mainAccount, Num, str _bu, str _costcenter, str _dept)
{
DimensionDefault result = 0;
int position = 0;
int dimensionCount = 0;
container account;
account += [_mainAccountNum, _mainAccountNum, 0];
if(_bu)
{
account += ['BusinessUnit', _bu];
dimensionCount++;
}
if(_dept)
{
account += ['Department', _dept];
dimensionCount++;
}
if(_costcenter)
{
account += ['CostCenter', _costcenter];
dimensionCount++;
}
account = conPoke(account, 3, dimensionCount);
try
{
result = AxdDimensionUtil::getLedgerAccountId(account);
}
catch
{
return 0;
}
return result;
}
The code to called serviceCreateLedgerDimension requires a Main Account Number and Default Dimension:
private DimensionDefault getLedgerDimensionFromDefaultDimension(MainAccountNum _mainAccountNum, DimensionDefault _defaultDimension)
{
DimensionDefault result = 0;
DimensionDefault ledgerDimension;
container account = [_mainAccountNum,_mainAccountNum, 0];
ledgerDimension = AxdDimensionUtil::getLedgerAccountId(account);
result = DimensionDefaultingService::serviceCreateLedgerDimension(ledgerDimension, _defaultDimension);
return result;
}
No comments:
Post a Comment