Financial Dimension Update through Job
Scenario:
We are going to update financial dimension (specific values)in sales quotation without affecting other dimesnion values.
Code:
static void AbsSalesQuotationDimension_Upd(Args
_args)
{
int j, k;
Struct
struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
SalesQuotationTable salesquotbl;
DimensionAttributeValueSetStorage
dimStorage;
DimensionAttribute
DimensionAttribute;
Counter
i;
DimensionAttribute
dimAttr;
DimensionAttributeValue
dimAttrValue;
Common
common;
DictTable
dictTable;
DimensionValue
activity, country, department, project, property, unit;
str Name;
str value;
SalesQuotationLine sqline;
//department = '111';
ttsBegin;
while select forupdate
salesquotbl where
salesquotbl.QuotationStatus == SalesQuotationStatus::Created
{
activity = '';
country = '';
department = '';
project = '';
property = '';
unit = '';
ledgerDimension = conNull();
k = 1;
j = 0;
DimensionDefault = 0;
struct = new
Struct();
dimStorage =
DimensionAttributeValueSetStorage::find(salesquotbl.DefaultDimension);
for
(i=1 ; i<= dimStorage.elements() ;
i++)
{
select
firstonly dimAttrValue
where
dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join
dimAttr
where
dimAttr.RecId == dimAttrValue.DimensionAttribute;
if
(dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common =
dictTable.makeRecord();
if (common.TableId)
{
select common where
common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
name =
common.(dimAttr.NameAttribute);
value =
common.(dimAttr.ValueAttribute);
if (dimAttr.Name == 'Activities')
{
activity = value;
}
if
(dimAttr.Name == 'Country')
{
country =
value;
}
else if
(dimAttr.Name == 'Departments')
{
department = '111'; //value;
}
else if
(dimAttr.Name == 'Project_ID')
{
project = value;
}
else if
(dimAttr.Name == 'Property_id')
{
property = value;
}
else if
(dimAttr.Name == 'Unit_ID')
{
unit = value;
}
}
}
}
//for
if
(activity)
{
struct.add('Activities', activity);
}
if
(country)
{
struct.add('Country', country);
}
if
(department)
{
struct.add('Departments', department);
}
if
(project)
{
struct.add('Project_ID', project);
}
if
(property)
{
struct.add('Property_id', property);
}
if
(unit)
{
struct.add('Unit_ID', unit);
}
j = struct.fields();
ledgerDimension +=
struct.fields();
for
(k =1; k <= j; k++)
{
ledgerDimension +=
struct.fieldName(k);
ledgerDimension +=
struct.valueIndex(k);
}
DimensionDefault =
AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
salesquotbl.DefaultDimension =
DimensionDefault;
salesquotbl.update();
update_recordSet
sqline
setting
DefaultDimension = salesquotbl.DefaultDimension
where
salesquotbl.QuotationId == sqline.QuotationId;
}
ttsCommit;
}
Happy coding!