Saturday, 11 January 2014

Barcodes in SSRS Reports

Barcode in SSRS Reports

Barcode logic

We can fetch barcode to SSRS through 2 ways.
Approach 1:Simple way: Use font with font name Prefixed with BC in text box property of report design


Approach 2:To convert the text to barcode with AX framework; and to fetch font and size properties from AX.

Example of Report in standard AX where they have used approach 2

WMSPickingList

Code Snippet for Sample Report which uses Barcode with Approach 2

Here we go! All we need is a string field.
Steps in short : Get a table which has string field declare it in DP. Fetch the barcode font and size from the parameter table if you need the one selected by end user. Encode your string to barcode in DP. Simply send it to report. In Design update the font tab controls with user entered font name and font size. There comes the bar code.
Steps in detail with code snippet:

·        Declare Barcode specific EDT, table and class in Class declaration


·        Define initBarcode where the record from Barcode setup is selected based on inventory parameter.


Inventory parameter table is just an example whereas the base table for bar code types are available in Organization Administration ->Setup ->Barcode.


·        Define process report and call initBarcode method.


·        Convert string to barcode using encode method of barcode class in barcode method.






·        Rest is inserting into table and getting from table methods.







·        In Design for the text box where you need to print the barcode use barcode font name and size fields in text box properties->Font tab controls just as in Approach 1 where you used to select font manually.