Use this code to update the Financial dimensions for an employee
static void setDefaultDimension(Args _args)
{
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
HcmEmployment empl,hcmEmployment;
HcmWorker work;
utcdatetime _validFrom = DateTimeUtil::utcNow();
CompanyInfo CompanyInfo = CompanyInfo::find();
;
ttsbegin ;
select work where work.PersonnelNumber =="000042";
select firstonly ValidTimeState(_validFrom) hcmEmployment
where hcmEmployment.Worker == work.RecId
&& hcmEmployment.LegalEntity == companyInfo.RecId;
struct = new Struct();
struct.add('costcenter', "ou_3566");
ledgerDimension = conNull();
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
hcmEmployment.selectForUpdate(true);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
hcmEmployment.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
hcmEmployment.DefaultDimension = DimensionDefault;
hcmEmployment.ValidFrom = DateTimeUtil::utcNow();
//hcmEmployment.ValidTo = DateTimeUtil::maxValue();
hcmEmployment.update();
ttsCommit;
}
static void setDefaultDimension(Args _args)
{
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
HcmEmployment empl,hcmEmployment;
HcmWorker work;
utcdatetime _validFrom = DateTimeUtil::utcNow();
CompanyInfo CompanyInfo = CompanyInfo::find();
;
ttsbegin ;
select work where work.PersonnelNumber =="000042";
select firstonly ValidTimeState(_validFrom) hcmEmployment
where hcmEmployment.Worker == work.RecId
&& hcmEmployment.LegalEntity == companyInfo.RecId;
struct = new Struct();
struct.add('costcenter', "ou_3566");
ledgerDimension = conNull();
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
hcmEmployment.selectForUpdate(true);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
hcmEmployment.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
hcmEmployment.DefaultDimension = DimensionDefault;
hcmEmployment.ValidFrom = DateTimeUtil::utcNow();
//hcmEmployment.ValidTo = DateTimeUtil::maxValue();
hcmEmployment.update();
ttsCommit;
}
No comments:
Post a Comment