Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Barcode code 128 optimalisation

Posted on by Microsoft Employee

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?

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

    Great. Thanks for sharing.

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    Fredrik Sætre 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
    Community Member Microsoft Employee on at
    RE: Barcode code 128 optimalisation

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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans