Below display method prints Barcode for the item. I tried this AX 2009 morphX Report. Please change the logic accordingly to fit you. I used CODE39 in the else if any item doesn't have any specific setup.
//BP Deviation Documented
display BarCodeString packItemBarCode()
{
BarcodeSetup barCodeSetup;
BarcodeSetupId barcodeSetupId;
str barCodeContents = VendPackingSlipTrans.ItemId;
;
barcodeSetupId = InventItemBarcode::findPurchBarcodeDimension(VendPackingSlipTrans.ItemId,InventDim::find(VendPackingSlipTrans.InventDimId)).barcodeSetupId;
if (barcodeSetupId)
{
barCodeSetup = BarcodeSetup::find(barcodeSetupId);
barCode = barCodeSetup.barcode();
}
if(!barcodeSetupId)
{
barcodeSetupId = InventItemBarcode::findPurchBarcode(VendPackingSlipTrans.ItemId).barcodeSetupId;
if (barcodeSetupId)
{
barCodeSetup = BarcodeSetup::find(barcodeSetupId);
barCode = barCodeSetup.barcode();
}
else
{
select firstonly barCodeSetup
where barCodeSetup.barcodeType == BarCodeType::Code39;
barCode = barCodeSetup.barcode();
}
}
if (barCodeSetup.validateBarcode(strupr(barCodeContents)))
{
barCode.string(true,strupr(barCodeContents),BarCodeContentType::Item);
barCode.encode();
}
else
{
throw(error(strfmt("@SYS41409", barCode.barcodeType(), strupr(barCodeContents))));
}
packItemBarCode.fontSize(barCodeSetup.fontSize);
packItemBarCode.font(barCodeSetup.fontName);
super();
if (!barCode)
return '';
return barCode.barcodeStr();
}
Regards,
Arun S.Keerthi
//BP Deviation Documented
display BarCodeString packItemBarCode()
{
BarcodeSetup barCodeSetup;
BarcodeSetupId barcodeSetupId;
str barCodeContents = VendPackingSlipTrans.ItemId;
;
barcodeSetupId = InventItemBarcode::findPurchBarcodeDimension(VendPackingSlipTrans.ItemId,InventDim::find(VendPackingSlipTrans.InventDimId)).barcodeSetupId;
if (barcodeSetupId)
{
barCodeSetup = BarcodeSetup::find(barcodeSetupId);
barCode = barCodeSetup.barcode();
}
if(!barcodeSetupId)
{
barcodeSetupId = InventItemBarcode::findPurchBarcode(VendPackingSlipTrans.ItemId).barcodeSetupId;
if (barcodeSetupId)
{
barCodeSetup = BarcodeSetup::find(barcodeSetupId);
barCode = barCodeSetup.barcode();
}
else
{
select firstonly barCodeSetup
where barCodeSetup.barcodeType == BarCodeType::Code39;
barCode = barCodeSetup.barcode();
}
}
if (barCodeSetup.validateBarcode(strupr(barCodeContents)))
{
barCode.string(true,strupr(barCodeContents),BarCodeContentType::Item);
barCode.encode();
}
else
{
throw(error(strfmt("@SYS41409", barCode.barcodeType(), strupr(barCodeContents))));
}
packItemBarCode.fontSize(barCodeSetup.fontSize);
packItemBarCode.font(barCodeSetup.fontName);
super();
if (!barCode)
return '';
return barCode.barcodeStr();
}
Regards,
Arun S.Keerthi
No comments:
Post a Comment