How to update the Item variants Color, size, style in Ax 2012

Hello All,

iam facing one issue while updating the item master variants( Color, Size, style) based on product dimension group, the values are not getting updated facing the below error.

Cannot edit a record in Product masters (EcoResProductMaster).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

below is the code, please help me if any thing wrong in the code

static void Job_VariantsUpdate(Args _args)
{
EcoResProduct ecoResProduct;
EcoResProductDimensionGroupProduct ecoResProductDimensionGroupProduct;// record
EcoResProductMaster ecoResProductMaster;
EcoResProductDimensionGroup ecoResProductDimensionGroup;
EcoResProductDimensionGroupFldSetup ecoResProductDimensionGroupFldSetup;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
Name name;
// ttsBegin;
//ecoResProductMaster.selectForUpdate(true);

while select ecoResProductMaster
where ecoResProductMaster.DisplayProductNumber == “Item001”
join ecoResProductDimensionGroupProduct
where ecoResProductDimensionGroupProduct.Product == ecoResProductMaster.RecId
join ecoResProductDimensionGroup
where ecoResProductDimensionGroup.RecId == ecoResProductDimensionGroupProduct.ProductDimensionGroup
join ecoResProductDimensionGroupFldSetup
where ecoResProductDimensionGroupFldSetup.ProductDimensionGroup == ecoResProductDimensionGroup.RecId
{
name = fieldId2pname(tableNum(InventDim), ecoResProductDimensionGroupFldSetup.DimensionFieldId);

if (name == “Size” && ecoResProductDimensionGroupFldSetup.IsActive == NoYes::Yes)
{
ttsBegin;
ecoResProductMaster.selectForUpdate(true);
ecoResProductMaster.RetailSizeGroupId = “Size”;
ecoResProductMaster.update();
ttsCommit;
}

if (name == “Color” && ecoResProductDimensionGroupFldSetup.IsActive == NoYes::Yes)
{
ttsBegin;
ecoResProductMaster.selectForUpdate(true);
ecoResProductMaster.RetailColorGroupId =“Color”;
ecoResProductMaster.update();
ttsCommit;
}

if (name == “Style” && ecoResProductDimensionGroupFldSetup.IsActive == NoYes::Yes)
{
ttsBegin;
ecoResProductMaster.selectForUpdate(true);
ecoResProductMaster.RetailStyleGroupId = “Style”;
ecoResProductMaster.update();
ttsCommit;
}
}
info(“done”);
}