Showing posts with label code 128. Show all posts
Showing posts with label code 128. Show all posts

Saturday, May 15, 2010

How to use barcodes in your Ax report - Part 2/2

In part 2 of the barcode posts (read part 1 here), we'll have a look at another barcode type.
We gonna see how to use barcodes of type Code 128 in your report. This is a high density barcode type, with checksum digit, supporting alphanumeric symbols. Very commonly used.

We gonna use the same example as in the previous post, an inventory report, with InventTable as the datasource.

We'll start off with our class declaration.
In this, we'll create an object for class BarcodeCode128. This class is used for encoding the barcode, checking/calculating check digit.

public class ReportRun extends ObjectRun
{
   BarcodeCode128 MyBarcode;
}
In the init method of our report, we instantiate the class.

public void init()
{  ;
   MyBarcode= BarcodeCode128::construct();

   super();
}

As opposed to Code 39 (see previous post), we now have to do some actual encoding. But no worries, the barcode class does this for us.
We'll create our display method in which we'll do the encoding:

Display BarcodeStr ShowBarcode()
{
   MyBarCode.string(true,InventTable.ItemId);
   MyBarCode.encode();

   return MyBarCode.barcodeStr();
}
Remember to set the report control properties with the appropriate font, something like this:




And this is what your result looks like when you call the report.


As you can see from the other classes in the AOT named Barcode*, Ax supports barcodes of type EAN, Interleaved 2 of 5, UPC, ...

Tip: This website, a site by Russ Adams, has some real good info on barcodes.