public static void main(Args args)
{
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
ledgerRecid Recid;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider();
LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
DimensionAttributeValueContract ValueContract;
List ListValueContract = new List(Types::Class);
str dimValue;
MainAccountnum mainAccount;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionStorage dimStorage;
container conAttr = ["BusinessUnit", "Department"];
container conValue = ["001","022"];
mainAccount = "110110";
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
// The last parameter is “true”. A dimensionAttributeValue record will be created if not //found.
dimensionAttributeValue =dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
result = valueSetStorage.save();
LedgerAccountContract.parmMainAccount(mainAccount);
LedgerAccountContract.parmValues(ListValueContract);
dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
Recid = LedgerDimensionFacade::ServiceCreateLedgerDimension(dimensionAttributeValueCombination.RecId, result);
info(strfmt("Ledger dimension : %1", Recid));
}
OutPut : 68719651020.
No comments:
Post a Comment