//Auto Generate Barcode in ax 2012
public static void main(Args _args)
{
InventItemBarcode barcode, argBarcode;
InventDim inventDim, barcodeInventDim;
EcoResDistinctProductVariant EcoResDistinctProductVariant;
InventDimCombination InventDimCombination, comb;
InventTable inventTable;
str itemBarcode;
InventTable = _args.record();
while select EcoResDistinctProductVariant where EcoResDistinctProductVariant.ProductMaster == InventTable.product
join InventDimCombination where InventDimCombination.DistinctProductVariant == EcoResDistinctProductVariant.RecId
join inventDim where inventDim.inventDimId == InventDimCombination.InventDimId
{
itemBarcode = "";
if (InventDimCombination)
{
barcodeInventDim.clear();
barcodeInventDim.InventSizeId = InventDimCombination.inventDim().InventSizeId;
barcodeInventDim.InventColorId = InventDimCombination.inventDim().InventColorId;
barcodeInventDim.InventStyleId = InventDimCombination.inventDim().InventStyleId;
barcodeInventDim.configId = InventDimCombination.inventDim().ConfigId;
barcodeInventDim = inventDim::findOrCreate(barcodeInventDim);
barcode.clear();
barcode.initValue();
barcode.itemId = InventTable.ItemId;
barcode.initFromItemId();
barcode.RetailVariantId = InventDimCombination.RetailVariantId;
barcode.inventDimId = barcodeInventDim.inventDimId;
barcode.barcodeSetupId = EcoResProductParameters::find().Fcc_BarcodeSetupId;
barcode.useForInput = NoYes::Yes;
barcode.useForPrinting = NoYes::Yes;
barcode.description = InventDimCombination.defaultProductName();
if(barcodeInventDim.InventSizeId != "" && barcodeInventDim.InventColorId != "")
{
itemBarcode = strFmt("%1-%2-%3",inventTable.ItemId,barcodeInventDim.InventSizeId, barcodeInventDim.InventColorId);
}
else
if (barcodeInventDim.InventSizeId != "" && barcodeInventDim.InventColorId == "")
{
itemBarcode = strFmt("%1-%2",inventTable.ItemId,barcodeInventDim.InventSizeId);
}
else
if (barcodeInventDim.InventSizeId == "" && barcodeInventDim.InventColorId != "")
{
itemBarcode = strFmt("%1-%2",inventTable.ItemId,barcodeInventDim.InventColorId);
}
barcode.itemBarCode = itemBarcode;
if (barcode.validateWrite())
barcode.insert();
}
}
}
public static void main(Args _args)
{
InventItemBarcode barcode, argBarcode;
InventDim inventDim, barcodeInventDim;
EcoResDistinctProductVariant EcoResDistinctProductVariant;
InventDimCombination InventDimCombination, comb;
InventTable inventTable;
str itemBarcode;
InventTable = _args.record();
while select EcoResDistinctProductVariant where EcoResDistinctProductVariant.ProductMaster == InventTable.product
join InventDimCombination where InventDimCombination.DistinctProductVariant == EcoResDistinctProductVariant.RecId
join inventDim where inventDim.inventDimId == InventDimCombination.InventDimId
{
itemBarcode = "";
if (InventDimCombination)
{
barcodeInventDim.clear();
barcodeInventDim.InventSizeId = InventDimCombination.inventDim().InventSizeId;
barcodeInventDim.InventColorId = InventDimCombination.inventDim().InventColorId;
barcodeInventDim.InventStyleId = InventDimCombination.inventDim().InventStyleId;
barcodeInventDim.configId = InventDimCombination.inventDim().ConfigId;
barcodeInventDim = inventDim::findOrCreate(barcodeInventDim);
barcode.clear();
barcode.initValue();
barcode.itemId = InventTable.ItemId;
barcode.initFromItemId();
barcode.RetailVariantId = InventDimCombination.RetailVariantId;
barcode.inventDimId = barcodeInventDim.inventDimId;
barcode.barcodeSetupId = EcoResProductParameters::find().Fcc_BarcodeSetupId;
barcode.useForInput = NoYes::Yes;
barcode.useForPrinting = NoYes::Yes;
barcode.description = InventDimCombination.defaultProductName();
if(barcodeInventDim.InventSizeId != "" && barcodeInventDim.InventColorId != "")
{
itemBarcode = strFmt("%1-%2-%3",inventTable.ItemId,barcodeInventDim.InventSizeId, barcodeInventDim.InventColorId);
}
else
if (barcodeInventDim.InventSizeId != "" && barcodeInventDim.InventColorId == "")
{
itemBarcode = strFmt("%1-%2",inventTable.ItemId,barcodeInventDim.InventSizeId);
}
else
if (barcodeInventDim.InventSizeId == "" && barcodeInventDim.InventColorId != "")
{
itemBarcode = strFmt("%1-%2",inventTable.ItemId,barcodeInventDim.InventColorId);
}
barcode.itemBarCode = itemBarcode;
if (barcode.validateWrite())
barcode.insert();
}
}
}
No comments:
Post a Comment