Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

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

  • Fredrik Sætre Profile Picture
    12,644 on at
    RE: Barcode code 128 optimalisation

    Great. Thanks for sharing.

  • Community Member Profile Picture
    on at
    RE: Barcode code 128 optimalisation

    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);
            }
        }
    }
  • Suggested answer
    Fredrik Sætre Profile Picture
    12,644 on at
    RE: Barcode code 128 optimalisation

    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
    RE: Barcode code 128 optimalisation

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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,033 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,854 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans