Select * from objMainAccount
inner join from objDimensionAttributeValueCombination
where objDimensionAttributeValueCombination.MainAccount == objMainAccount.RecId
&& objDimensionAttributeValueCombination.RecId == objGeneralJournalAccountEntry.LedgerDimension
static void Job38(Args _args)
{
GeneralJournalAccountEntry generalJournalAccountEntry; //Table that stores ledger transactions
BudgetTransactionLine BudgetTransactionLine;
//DimensionAttributeValueCombination dimAttrValueComb;
DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
DimensionAttribute dimAttr; //Main dimension attribute table
int i;
while select BudgetTransactionLine
{
//dimAttrValueComb = DimensionAttributeValueCombination::find(BudgetTransactionLine.LedgerDimension);
// setPrefix(int2str(i) + ". " + DimensionAttributeValueCombination::find(BudgetTransactionLine.LedgerDimension).DisplayValue);
select DisplayValue from dimAttrView
where dimAttrView.ValueCombinationRecId == BudgetTransactionLine.LedgerDimension join BackingEntityType from dimAttr
where dimAttr.RecId == dimAttrView.DimensionAttribute && dimAttr.BackingEntityType== tableName2id("DimAttributeOMDepartment");
info(strFmt("Department: %1,Combination: %2", dimAttrView.DisplayValue));//,dimAttrValueComb.DisplayValue));
// info(strfmt("%1" , dimAttrValueComb.DisplayValue));
// dimensionStorage = DimensionStorage::findById(gjAccEntry.LedgerDimension);
}
// setPrefix("Breakup for " + dimAttrValueComb.DisplayValue);
}
https://erpdax.wordpress.com/tag/cost-centre/ ( very important helpful link)
Dimension values from Ledger Dimension
Below code will get you the Default Dimension by passing the Ledger Dimension
public str getBusinessUnit(RecId _ledgerDimension){// DimensionAttributeValueCombination stores the combinations of dimension values// Any tables that uses dimension combinations for main account and dimensions// Has a reference to this table’s recidDimensionAttributeValueCombination dimAttrValueComb;//GeneralJournalAccountEntry is one such tables that refrences DimensionAttributeValueCombinationGeneralJournalAccountEntry gjAccEntry;// Class Dimension storage is used to store and manipulate the values of combinationDimensionStorage dimensionStorage;// Class DimensionStorageSegment will get specfic segments based on hierarchiesDimensionStorageSegment segment;int segmentCount, segmentIndex;int hierarchyCount, hierarchyIndex;str segmentName, segmentDescription;SysDim segmentValue;;dimAttrValueComb = DimensionAttributeValueCombination::find(_ledgerDimension);// Get dimension storagedimensionStorage = DimensionStorage::findById(_ledgerDimension);if (dimensionStorage == null){throw error("@SYS83964");}// Get hierarchy counthierarchyCount = dimensionStorage.hierarchyCount();//Loop through hierarchies to get individual segmentsfor(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++){//Get segment count for hierarchysegmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);//Loop through segments and display required valuesfor (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++){// Get segmentsegment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);// Get the segment informationif (segment.parmDimensionAttributeValueId() != 0){// Get segment namesegmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;//Get segment value (id of the dimension)segmentValue = segment.parmDisplayValue();if(segmentName =="CostCenter") //Give the Dimension Name to that Dimension Value{return segmentValue;}}}}return "";}Getting Dimension values from Default Dimension
From the below we can get all the Default Dimension values:
Method 1:
DimensionAttributeValueSetStorage dimStorage;Counter i;str dimensionValue;RefRecId defaultdim;DirPartyName dimensionValue1;defaultdim = 5637176154; //this number is basically from field DefaultDimensiondimStorage = DimensionAttributeValueSetStorage::find(defaultdim);for (i=1 ; i&lt;= dimStorage.elements() ; i++){if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name=='BusinessUnit') //Give the Attribute you want to get the value for.{dimensionValue = dimStorage.getDisplayValueByIndex(i);dimensionValue1 = DirPartyTable::findRec(VendTable::find(dimensionValue).Party).Name;//To get the Vend Namebreak;}}info(strFmt("Business Unit: %1",dimensionValue));
Method 2:
DimensionAttributeValueSet dimAttrValueSet;DimensionAttributeValueSetItem dimAttrValueSetItem;DimensionAttributeValue dimAttrValue;DimensionAttribute dimAttribute;RefRecID dimensionSetRecID;Name attributeName;;dimensionSetRecID = 5637176154; //this number is basically from field DefaultDimensionattributeName = 'BusinessUnit'; //put here the name of dimensiondimAttrValueSet = DimensionAttributeValueSet::find(dimensionSetRecID); select dimAttrValueSetItemwhere dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecIdjoin dimAttrValuewhere dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValuejoin dimAttributewhere dimAttribute.RecId == dimAttrValue.DimensionAttribute&amp;&amp; dimAttribute.Name == attributeName;info(strFmt("Business Unit: %1----%2",dimAttrValue.getValue(),dimAttrValue.getName()));
OR
Passing current record buffer
[SysClientCacheDataMethodAttribute(true)]display DimensionValue BusinessUnit(InventJournalTrans _inventJournalTrans)//Passing current record buffer{ DimensionAttributeValueSetStorage dimStorage;Counter i;DimensionValue dimensionValue;RefRecId defaultdim; defaultdim = _inventJournalTrans.DefaultDimension; //this number is basically from field DefaultDimensiondimStorage = DimensionAttributeValueSetStorage::find(defaultdim); for (i=1 ; i&lt;= dimStorage.elements() ; i++){if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name=='BusinessUnit') //Give the Attribute you want to get the value for.{dimensionValue = dimStorage.getDisplayValueByIndex(i);break;}}return dimensionValue;
}
OR
Adding the Code at Global Class
Eg: To use this method:tempTable.DimensionValue= getDefaultDimensionValue("BusinessUnit",prodTable.DefaultDimension);//To Get the default dimension value by using default dimension idstatic str 50 getDefaultDimensionValue(str _dimName,DimensionDefault _defaultDimension){ DimensionAttributeValueSetStorage dimStorage; CustTable custTable; Counter i; str returnValue; dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension); for (i=1 ; i<= dimStorage.elements() ; i++) { if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == _dimName) { returnValue = dimStorage.getDisplayValueByIndex(i); break; } } return returnValue;}