public static DimensionDynamicAccount CrearCombinacion(DimensionDisplayValue _DimensionDisplayValue)
{
DimensionStorage DimensionStorage;
DimensionAttributeValue dimAttributeValue;
DimensionStorageSegment DimensionStorageSegment;
MainAccount MainAccount;
recid dimHierarchyId;
recid mainAccountRecId;
DimensionValue _DimensionValue;
container cont;
int i;
container dimensiones=["MainAccount","División","Sucursal","CentroCosto"];
;
cont=str2con(_DimensionDisplayValue,"-");
////declarar el objecto
DimensionStorage=DimensionStorage::construct(0,LedgerDimensionType::Account);
for(i=1;i<=conLen(cont);i++)
{
try
{
_DimensionValue=conPeek(cont,i);
if(i==1)
{
dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(
DimensionAttribute::findByName(conPeek(dimensiones,i)),
_DimensionValue,
false,
true);
mainAccountRecId= DimensionAttributeValue::find(dimAttributeValue.RecId).EntityInstance;
dimHierarchyId = DimensionHierarchy::getAccountStructure(mainAccountRecId);
DimensionStorage.addHierarchy(dimHierarchyId);
DimensionStorageSegment=DimensionStorageSegment::constructFromValue(dimAttributeValue.CachedDisplayValue,dimAttributeValue);
DimensionStorage.setSegment(i,DimensionStorageSegment);
}
else
{
if(_DimensionValue!="")
{
dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(
DimensionAttribute::findByName(conPeek(dimensiones,i)),
_DimensionValue,
false,
true);
DimensionStorageSegment=DimensionStorageSegment::constructFromValue(dimAttributeValue.CachedDisplayValue,dimAttributeValue);
DimensionStorage.setSegment(i,DimensionStorageSegment);
}
else
{
DimensionStorageSegment=DimensionStorageSegment::emptySegment();
DimensionStorage.setSegment(i,DimensionStorageSegment);
}
}
}
catch
{
return 0;
}
}
return DimensionStorage.save();
}
No hay comentarios:
Publicar un comentario