Getting Required display value from offset main account in ax2012

 static void getoffsetacount(Args _args)

{

 DimensionStorage dimensionStorage;

 DimensionStorageSegment segment;

 int segmentCount, segmentIndex;

 int hierarchyCount, hierarchyIndex;

 str segmentName, segmentDescription;

 SysDim segmentValue;

    LEDGERJOURNALTRANS ledgerJournalTrans;

select ledgerJournalTrans where ledgerJournalTrans.RecId ==35637324216;

  //ledgerJournalTrans =LedgerJournalTrans::find('00078','GNJL000861',false);

 dimensionStorage = DimensionStorage::findById(ledgerJournalTrans.OffsetLedgerDimension);

 if (dimensionStorage == null)

 {

 throw error("@SYS83964");

 }


 hierarchyCount = dimensionStorage.hierarchyCount();

 //Loop through hierarchies to get individual segments

 for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)

 {

 segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);


 //Loop through segments and display required values

 for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)

 {

 // Get segment

 segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);


 // Get the segment information

 if (segment.parmDimensionAttributeValueId() != 0 &&

 DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId())

 .DimensionAttribute).Name == "Department")

 {

 segmentValue = segment.parmDisplayValue();

 segmentDescription = segment.getName();

 }

 }

 }

    info(strFmt("Department : %1 %2", segmentValue ,segmentDescription));



// return segmentValue + " (" + segmentDescription + ")";

}

No comments:

Post a Comment