web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Suggested Answer

Barcode code 128 optimalisation

(0) ShareShare
ReportReport
Posted on by

I'm printing a barcode to a Printronix printer, using zpl code. The code is 17 characters long and it results in barcode which is too wide. Label designers optimizes these barcodes by deviding them into subsets of type A, B or C. This results in a smaller barcode. Has anyone a generic algorithm in x++ for this problem?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I am wondering if there is anybody out there for a solution?

  • Suggested answer
    Fredrik Sætre Profile Picture
    12,644 on at

    I believe you might want to talk to a developer to make this. I don't know any standard method that would support splitting up ute barcodes.

    But can't you just let ZPL divide the format for you?

  • Community Member Profile Picture
    on at

    Hi,

    A senior developer looked into this. The ZPL engine on the printer (an open source library commonly used) does not do the job nicely like a program like NiceLabel, Zebra Designer or Bartender.

    We now hardcoded the format since we know the pattern of our serial numbers. However, we prefer to have it coded in such a way that our pattern does not matter.

    J.

    ==

    public void printFromInventSerial(InventSerial _inventSerial)
    {
        str             inventSerialId;
        computerName = Microsoft.Dynamics.AX.WHS.DeviceCom.ClientHelper::RetrieveClientName();
        worker = currentWorker();
        select firstOnly1 barCodeSetupId from barCodeSetup where  barCodeSetup.barcodeType == BarcodeType::EAN13;
        barCodeSetupId = barCodeSetup.barcodeSetupId;
    
        //Find record in Document Routing for selection of correct printer/layout
        select firstOnly1 routingTable
            where routingTable.WorkTransType         == WHSWorkTransType::ProdPut &&
                  (!routingTable.ComputerName                                     ||
                    routingTable.ComputerName        == computerName)             &&
                  (!routingTable.Worker                                           ||
                  routingTable.Worker              == worker);
    
        select firstOnly1 inventItemBarcode
            where inventItemBarcode.itemId == _inventSerial.ItemId
            &&    inventItemBarcode.barcodeSetupId == barCodeSetupId;
    
        inventSerialId = _inventSerial.InventSerialId;
        inventSerialId = strReplace(inventSerialId, 'SN-', 'SN->5');
        inventSerialId = strReplace(inventSerialId, '-0', '>6->50');
    //above should not be hardcoded
    
        if (!inventItemBarcode.itemBarCode)
        {
            info(strFmt("@MCR39604",_inventSerial.ItemId, "@SYS63146"+'\"'));
        }
        //Only if routingTable record found, print for all the document routing lines
        if (routingTable && inventItemBarcode.itemBarCode)
        {
            while select LayoutId, PrinterName
                from routingLine
                where routingLine.DocumentRoutingTable == routingTable.RecId
            {
                layoutstr = WHSDocumentRoutingLayout::find(routingLine.LayoutId).zpl;
                finalstr = strReplace(layoutstr, '$ItemId$', strFmt("%1",_inventSerial.ItemId));
                finalstr = strReplace(finalstr,  '$InventSerialId$', strFmt("%1",inventSerialId));
                finalstr = strReplace(finalStr,  '$EAN13$', strFmt("%1",inventItemBarcode.itemBarCode));
    
                Microsoft.Dynamics.AX.WHS.DeviceCom.Printer::SendStringToPrinter(routingLine.PrinterName, finalStr);
            }
        }
    }
  • Fredrik Sætre Profile Picture
    12,644 on at

    Great. Thanks for sharing.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans