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.
Display str ShowBarcode()
ReplyDeleteshould read
Display BarCodeString ShowBarcode()
That Shouldn't be a problem....
ReplyDeleteBarCodeString is a string datatype....
Not a practical problem at first glance, but a really bad practice to use str. BarCodeString is limited to 70 chars as an EDT. The type "str" is "unlimited" (http://msdn.microsoft.com/en-US/library/aa889472.aspx). I fully agree with mp.
ReplyDeleteHi all,
ReplyDeleteAs this appears to be a hot topic, I've applied the EDT. Now fully according to best practice :-)
Willy
Hi,
ReplyDeleteHow to print 2D (matrix) barcode with Dynamics ax 2009??
can you help me
Thanks
what if i want to print barcode for a real type field?
ReplyDeletefor example: Table: ProdTable, Fieldname: qtycalc
can anyone help me?
convert number to str
ReplyDeleteBarCode.string(true,Num2str(qtyCalc,0,2,1,3));
How do i get Txt under the barcode ?
ReplyDeleteNice post. You can visit following link to get Ax 2012 technical code and error solutions
ReplyDeleteAx 2012 Development and Coding
Hi
ReplyDeleteCan anyone help me how can I enable the barcode field in the transaction windows? I have created 2 variants for one item based on the color and size dimensions.
Thanks in advance
Hi, I am facing an issue where barcode machine is not reading "_"(underscore) character. Is it something to do with handgun or barcode type i am using. I am using code 39 and code 128 for this.
ReplyDeleteHi Vishal.
DeleteI am also facing this issue. Did you find a solution for this?
//Richard Hellstenius
Hi Vishal, have you solved the problem with de underscore? I have the same problem.
ReplyDeleteCool article! This one also was helpful for me to understand how printing barcodes works in AX, why we actually need Barcode classes, how to print 2D barcodes in AX, etc.:
ReplyDeletehttp://ax.docentric.com/barcodes-microsoft-dynamics-ax/
Subscribe to learn this new technique in Ax . Give like comments and share
ReplyDeletehttps://youtu.be/8dXjRzSk910
One of the best article ever seen on upc code.Love the concept and idea you presented in your article.Very helpful article.
ReplyDeleteThanks!