HcmWorker hcmWorker;
HcmEmployment hcmEmployment,hcmEmploymentup;
DimensionAttributeValueSetStorage dimStorage = new DimensionAttributeValueSetStorage();
DimensionAttribute dimAttrC,dimAtrrCC;
DimensionAttributeValue dimAttrCValue,dimAtrrCCValue;
DimensionDefault defaultDimension;
int i;
str costcenter1,costcenter2, name1,name2;
dimStorage = DimensionAttributeValueSetStorage::find(this.NewDefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
if(i==1)
{
name1 = DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name; // cost center
costcenter1 = dimStorage.getDisplayValueByIndex(i);
}
else
{
name2 = DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name; // class
costcenter2 = dimStorage.getDisplayValueByIndex(i);
}
}
select firstonly hcmWorker where hcmWorker.PersonnelNumber == this.PersonnelNumber;
select firstonly hcmEmployment where hcmEmployment.Worker == hcmWorker.RecId;
defaultDimension = hcmEmployment.DefaultDimension;
dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);
dimAttrC = DimensionAttribute::findByName(name2);
dimAtrrCC = DimensionAttribute::findByName(name1);
dimAttrCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrC,costcenter2 , false, true);
dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC,costcenter1 , false, true);
dimStorage.addItem(dimAttrCValue);
dimStorage.addItem(dimAtrrCCValue);
select forupdate hcmEmploymentup where hcmEmploymentup.worker == hcmWorker.RecId;
if(hcmEmploymentup)
{
ttsbegin;
hcmEmploymentup.defaultDimension = dimStorage.save();
hcmEmploymentup.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
hcmEmploymentup.ValidFrom = DateTimeUtil::getSystemDateTime();
hcmEmploymentup.ValidTo =DateTimeUtil::maxValue();
hcmEmploymentup.update();
ttscommit;
}