Clear Release variant first and them master variant.
static void ClearReleaseVarient(Args _args)
{
EcoResDistinctProductVariant EcoResDistinctProductVariant, variant;
EcoResProductVariantDimensionValue EcoResProductVariantDimensionValue;
EcoResProductTranslation ecoResProductTranslation_Variant;
EcoResProductVariantColor ecoResProductVariantColor;
EcoResProductVariantStyle ecoResProductVariantStyle;
EcoResProductVariantSize ecoResProductVariantSize;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
InventDimCombination InventDimCombination,InventDimCombination1,InventDimCombination2;
InventItemBarcode inventBarcode;
InventTrans InventTrans;
InventDimCombination InventDimCombinationCheckother;
DataArea dataArea;
boolean checkdelete;
/* EcoResSize size;
EcoResColor color;
EcoResStyle style;
EcoResProductMaster productmaster;
, dimFromCombination;
EcoResConfiguration config;
InventTable inventTable;
,ecoResProducttest;
container con;
int conin;*/
InventDim inventDim,inventDimcheck;
EcoResProduct ecoResProduct;
FromTime startTime;
int seconds = 1,counts;
CommaIo file;
container line;
#define.ExampleFile(FileNameSave)
FileIoPermission perm;
CompanyInfo CompanyInfo;
#File
str elapsed;
;
startTime = timeNow();
while select crossCompany InventDimCombination order by ItemId asc
where InventDimCombination.ItemId =="A01112Y07521"
notexists join inventBarcode
where inventBarcode.RetailVariantId == InventDimCombination.RetailVariantId
notexists join InventTrans
where InventTrans.ItemId == InventDimCombination.ItemId
&& InventTrans.inventDimId == InventDimCombination.InventDimId
{
counts++;
select ecoResProduct
where ecoResProduct.DisplayProductNumber == InventDimCombination.ItemId
&& (ecoResProduct.Division == ProductTypeSetup::findByDivision("20").RecId
|| ecoResProduct.Division == ProductTypeSetup::findByDivision("29").RecId)
&& EcoResProduct.ProductCreationType == ProductCreationType::GlobalProduct;
if(ecoResProduct)
{
if(InventDimCombination.validateDelete())
{
select forUpdate * from InventDimCombination1 where InventDimCombination1.RecId == InventDimCombination.RecId;
InventDimCombination1.delete();
}
}
else
{
inventDim = inventDim::find(InventDimCombination.InventDimId);
info(strFmt("Item %1, Size %2, Color %3, Config %4, Season %5 has transactions", InventDimCombination.ItemId, inventDim.InventSizeId, inventDim.InventColorId, inventDim.configId, inventDim.InventStyleId));
}
}
elapsed = timeConsumed(startTime, timeNow());
info(strFmt("Time elapsed: %1 and number of records deleted %2", elapsed,counts));
}
-------------------------------------------------------------------------------------------------------------------
static void ClearProductMastervarient(Args _args)
{
EcoResDistinctProductVariant EcoResDistinctProductVariant, variant;
EcoResProductVariantDimensionValue EcoResProductVariantDimensionValue;
EcoResProductTranslation ecoResProductTranslation_Variant;
EcoResProductVariantColor ecoResProductVariantColor;
EcoResProductVariantStyle ecoResProductVariantStyle;
EcoResProductVariantSize ecoResProductVariantSize;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
DimensionAttributeValues DimensionAttributeValues;
InventDimCombination InventDimCombination,InventDimCombination1,InventDimCombination2;
InventItemBarcode inventBarcode;
InventTrans InventTrans;
InventDimCombination InventDimCombinationCheckother;
DataArea dataArea;
boolean checkdelete;
/* EcoResSize size;
EcoResColor color;
EcoResStyle style;
EcoResProductMaster productmaster;
, dimFromCombination;
EcoResConfiguration config;
InventTable inventTable;
,ecoResProducttest;
container con;
int conin;*/
InventDim inventDim,inventDimcheck;
EcoResProduct ecoResProduct;
FromTime startTime;
int seconds = 1,counts;
CommaIo file;
container line;
#define.ExampleFile(FileNameSave)
FileIoPermission perm;
CompanyInfo CompanyInfo;
#File
str elapsed;
;
startTime = timeNow();
while select ecoResProduct
where
ecoResProduct.DisplayProductNumber == "A01112Y07521"
&& (ecoResProduct.Division == ProductTypeSetup::findByDivision("20").RecId
|| ecoResProduct.Division == ProductTypeSetup::findByDivision("29").RecId)
&& EcoResProduct.ProductCreationType == ProductCreationType::GlobalProduct
{
while select EcoResDistinctProductVariant order by RecId asc
where EcoResDistinctProductVariant.DisplayProductNumber like ecoResProduct.DisplayProductNumber +"*"
{
select crossCompany InventDimCombination
where InventDimCombination.DistinctProductVariant == EcoResDistinctProductVariant.RecId
&& InventDimCombination.ItemId == ecoResProduct.DisplayProductNumber;
if(!InventDimCombination)
{
ttsBegin;
// select forUpdate * from ecoResProductTranslation_Variant where ecoResProductTranslation_Variant.Product ==ecoResProduct.RecId;
// ecoResProductTranslation_Variant.delete();
select forUpdate * from EcoResProductVariantColor where EcoResProductVariantColor.DistinctProductVariant == EcoResDistinctProductVariant.RecId;
EcoResProductVariantColor.delete();
select forUpdate * from EcoResProductVariantStyle where EcoResProductVariantStyle.DistinctProductVariant == EcoResDistinctProductVariant.RecId;
EcoResProductVariantStyle.delete();
select forUpdate * from EcoResProductVariantSize where EcoResProductVariantSize.DistinctProductVariant == EcoResDistinctProductVariant.RecId;
EcoResProductVariantSize.delete();
select forUpdate * from EcoResProductVariantConfiguration where EcoResProductVariantConfiguration.DistinctProductVariant == EcoResDistinctProductVariant.RecId;
EcoResProductVariantConfiguration.delete();
select forUpdate * from DimensionAttributeValues where DimensionAttributeValues.EcoResDistinctProductVariant == EcoResDistinctProductVariant.RecId;
DimensionAttributeValues.delete();
InventDimCombination1=null;
select forUpdate * from variant where variant.RecId == EcoResDistinctProductVariant.RecId;
variant.delete();
ttsCommit;
}
}
}
elapsed = timeConsumed(startTime, timeNow());
info(strFmt("Time elapsed: %1 and number of records deleted %2", elapsed,counts));
}