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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Encoding upca barcode gives random characters

(0) ShareShare
ReportReport
Posted on by 1,645

I am encoding item numbers into bar code in Dynamics AX 2012. I have an item number 765811249511 which when encoded into UPCA gives the encoded characters as ".765811/B:?:." which I think is not right as barcode scanner is not scanning the barcode. Kindly suggest any solution.

*This post is locked for comments

I have the same question (0)
  • Gustavo Bagno Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    Hi.

    Can you show us the code snippet you are using?

    Plus, is it really the UPCA encoding you are looking for?  UPC-A is an outdated version of EAN-13 Barcode type, which is now widely accepted.

    The string you are sending has 12 characters. Although the UPC-A's lenght is 12 characters, the last one is the check-digit. Which means, you need to send a 11 characters string in order for the AX class to work properly, since the 12th character will be added by the encoding class; and of course, the barcode encryption classes may not be 100% reliable.

    But in any case, make sure your string control that is representing the final bar code is set with  "BC UPC HD Wide" Font.

    Or you can always use a DLL to encode your barcodes.

    Let me know if any of the above works for you.

    Thanks.

  • AlokShrestha Profile Picture
    1,645 on at
    RE: Encoding upca barcode gives random characters

    This is the built in method in BarcodeUPCA class that I am using to encode the barcode.

    BarCodeString encodeString(BarCodeString _stringIn)

    {

       int             len = strLen(_stringIn);

       int             addtotal = 0;

       int             checkval = 0;

       int             i;

       int             charVal;

       BarCodeString   result;

       if (len != this.strlen() - 1)

       {

           return '';

       }

       // step through the text in string and perform character mapping

       for (i = 1; i<=len; i++)

       {

           charVal = char2num(_stringIn, i);

           if (charVal >= 48 && charVal <= 57)

           {

               if (i mod 2 == 0)

               {

                   checkval = charVal - 48;

               }

               else

               {

                   checkval = 3 * (charVal - 48);

               }

               addTotal += checkval;

               if (i <= 6)

               {

                   result += num2char(charVal);

               }

               else

               {

                   result += num2char(charVal + 10);

               }

           }

           // add middle guard bars

           if (i == 6)

           {

               result += num2char(47);

           }

       }

       // caluculate check digit

       if (addtotal mod 10 == 0)

       {

         checkval = 0;

       }

       else

       {

         checkval = 10 - (addtotal mod 10);

       }

       barcodeStrHR = _stringIn + num2str(checkVal,1,0,0,0);

       // add start, check char, stop code and 0 terminate out string

       result = '.' + result + num2char(checkval + 58) + '.';

       return result;

    }

    I have tried to encode with 11 digits and 12 digits but both of them gives the random number not the 11 digits appended by a checksum. I have used the same font as you mentioned. Probably the problem is with the above method only. If not I will lastly use the DLL as you suggested. Any idea on using DLL in case?

  • Gustavo Bagno Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    Well...there are plenty DLLs out in the market, just pick the cheapest one, since they all do the same thing.

    If you can find it for free, even better!

    But I assure you that the DLL way out is good. We use it here to print QR Codes (they can handle more data within the image).

    If you are interested in using QR Code, I can point you to a OpenSource free DLL that works like a charm!

    Cheers!

  • AlokShrestha Profile Picture
    1,645 on at
    RE: Encoding upca barcode gives random characters

    We gave a thought of using DLLs but the same thing is working well with X++ reporting but not with SSRS reporting so we have reported an incident with Microsoft Support. I will get back if I hear something positive from then. Just point me out to the OpenSource DLL in case. Thanks.

  • Gustavo Bagno Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    The DLL is called ThoughtWorks QRCode.

    WIth the SSRS issue, you may have to redesign the report, and have the encoded string coming from a data method or something similar. That should work on SSRS.

  • Community Member Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    hey, you may have a look at this upc-a barcode , and the barcode image setting

  • nathansy Profile Picture
    5 on at
    RE: Encoding upca barcode gives random characters

    As for creating barcode in SSRS, I used this barcode generator app before. It is excellent from my own experience. It supports to create various barcode types, inlcuding upc-a, qr code, code 39, code 128, ean 8, ean 128, pdf417, and data matrix, etc.

  • Community Member Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    [quote user="nathansy"]

    As for creating barcode in SSRS, I used this barcode generator app before. It is excellent from my own experience. It supports to create various barcode types, including upc-a, qr code, code 39, code 128, ean 8, ean 128, pdf417, and data matrix, etc.

    [/quote]

    glad to see the resource you shared here! thanx , i think it is useful for me

  • Verified answer
    AlokShrestha Profile Picture
    1,645 on at
    RE: Encoding upca barcode gives random characters

    The encoding was correct but the barcode scanner that I was using was not scanning the barcode. What I did is I got another barcode scanner and it scanned it perfectly. So, my suggestion if anyone faces same problem is to try scanning with different scanner.

  • Community Member Profile Picture
    on at
    RE: Encoding upca barcode gives random characters

    Alternatively, here's a guide to create UPCA barcodes, which I think is very cool because it can automatically calculate check digit, and also allow for 2-digit / 5-digit addon symbol

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans