Barcodes and QR-codes in SAP hybris
Barcodes are machine readable symbols that store identifying data about the part or product with which they are associated. Basically, it is a paper-based hyperlink that connects the physical world with the online world. This article explains everything you need to know about the barcode reading and generation in hybris, as well as my thoughts about the integrating it into hybris Backoffice. In e-commerce, barcodes are mainly used for:
- inventory management
- ready to pick up e-mails
- discount coupons ready to use in offline retail
www.barcodes4.me/barcode/c128a/Rauf%20Aliev%20barcode.png?width=250&height=100&istextdrawn=1JsBarcode is also a great library. It has a MIT License, so you can use it in the commercial projects as well. Unlike the previous libraries, this one generates vector (SVG) images.
Hybris OOTB solutions for barcodesThere is a module “mobileservices” in hybris. It provides the functionality of decoding barcodes, “Code2Service” (documentation). The module supports QR and DataMatrix barcodes. For DataMatrix — only encoding. Hybris uses ZXing library for generating/decoding QR codes. However, this version (1.3) is too old: it is released in 2013, four year ago. The current version is 3.3.0. It supports an extended set of barcode formats, bugfixed and stable. So consider updating the library comes with hybris with a new version. For Datamatrix codes, hybris uses BarcodeJ. However, hybris uses only a small subset of this library capabilities. I found the following comments in hybris that the datamatrix library “fails to decode non-alphanumeric characters” and “The errors produced, varies with the encoding string. The longer the string, the worse results“. So take it into account.
Security issuesBarcode ticket security is a growing issue (we get asked about it all the time) and there aren’t any standards yet for preventing unscrupulous individuals from altering the tickets that are issued. As the value of barcode entitlements go up, more people will take an interest in copying, altering, or re-generating valuable barcodes. Without the security, the ticket cannot be proof. Ideally, barcodes should contain just a number (order number, coupon number etc.), and their validity is checked from a database of known numbers, which reveals all of the extra order/coupon detail, possibly including ID information about the legitimate user of the ticket which might be checked in high value situations. The problem of this approach is that your checking systems must have up-to-date access to the ticket database, ideally near real-time access. Sometimes it is a challenging issue (for example, for event tickets). If your POS system relies on the scanners being connected to the internet, to access a central database to check every barcode, then you may get issues with speed of validating, and therefore the throughput of your entry systems. Additionally, your whole system could become useless from a single point of failure or connection. So if we go this way, the barcode is no more than a representation of the order number and you need to conduct additional security checks before handover. If you use a self-service terminals, the system can be hacked with a set of pre-printed QR-codes with different order numbers. To avoid attacking I recommend using unique salted hashes instead of simple sequential numbering. If you can put all of the details of the purchase into a QR code, then an offline system can scan it, and instantly know what the entitlement is without the need to access a database. It can work for tickets, for example. However, this approach require Public/Private key cryptography. This approach is good for online ticketing systems. For regular e-commerce it looks like an overkill. Never put the sensitive information into QR code. QR code should contain only a reference where this sensitive information can be retrieved from by the system with the proper permissions. To avoid the replay attack you need to keep a database of issued barcodes and their values. When a barcode is redeemed, the database must invalidate that code. This approach can be implemented via item statuses. It works best if your system is online and synchronous, where codes are atomically applied and cancelled. It is also possible to limit the window during which codes can be re-used in a batch processing based system if the terminals cannot be online, though any use of a code between when it is first redeemed and when that redemption is copied to other systems is a risk. This case is common for coupons issued online and supposed to be redeemed offline. Some codes have strict limitations on the character set and message length. You need to test it well before going live. Finally, you need to have a backup plan for the case when barcode is not readable.
Forms of barcodesOver the years, different forms of barcodes have been developed to help businesses around the world. These include:
- 1-D linear barcodes
- 2-D matrix codes
- Posted codes
- Stacked linear barcodes
1-D linear barcodes
- All the information in the code is organized horizontally in bar and space widths and read left to right by a scanner.
- The height of the code varies based on the space available on a product and the ability of a barcode reader to read a small or large sized barcode.
- multi-width, alphanumeric
- a more recently introduced
- the most robust 1-D barcode type.
- The number 128 refers to the ability to hold any character of the ASCII 128 character set (all digits, characters and punctuation marks).
- Typical usage: Logistics
Code 128: UPC-A
- UPC means Unversal Product Code
- The most common and well-known barcode used in the United States
- Encodes 12 digits of data
- The 1st digit is the number system character followed by a 5-digit manufacturer number, a 5-digit product number and a final check digit.
- UPC-A is primarily used in retail.
Code 128: EAN-13
- European counterpart of the UPC-A symbol.
- Encodes an extra digit of data to make a total of 13.
- The first two digits identify a country and the check digit is the last number of the second group of six digits.
Code 128: UPC-E
- Used in U.S.
- Condensed variation of a UPC-A barcode (eliminating ‘extra’ zeros from the digital data).
- Generally used on very small packaging where space is limited
Code 128: EAN-8
- EAN equivalent of UPC-E (in the sense that it provides a short barcode).
- Set in two groups of four numbers, it is composed of two flag digits, five data digits and one check digit.
- Primarily used on small packaging where space is limited.
Code 39 (aka “3 of 9 code”)
- Variable-length barcode
- Self-checking so a check digit normally isn’t necessary, but is recommended.
- Ability to encode up to 43 numbers, letters and other characters.
- Widely used, especially in non-retail environments
Code 39 Extended version
- Combination of two standard Code 39 characters to encode every one of the 128 ASCII characters.
- Allows for special characters, such as lowercase letters.
- The more special characters that are used, the longer the barcode will become.
- Most barcode readers will not automatically read Extended Code 39 without custom configuration.
- Designed to encode data more compactly and with higher data redundancy than with older multi-length barcode types such as Code 39.
- Discrete, self-checking barcode that allows encoding of up to 16 different characters, plus an additional four special start and stop characters, which include A, B, C and D.
Interleaved 2 of 5
- Encodes any even number of numeric characters.
- Encodes data in the width of both the bars and spaces (resulted in higher density encoding)
MSI/Plessey (aka Modified Plessey)
- Used primarily to mark supermarket shelves for inventory control.
- MSI is a continuous, non-self-checking barcode.
2-D matrix codes
- Data is encoded as black and white ‘cells’ (small squares) arranged in either a square or rectangular pattern.
- Ability to encode larger amounts of data
- The matrix code improves readability and resistance to poor printing
- Include redundant data so even if one or more cells are damaged, the code is still readable.
- Allows encoding of large amounts of data (up to 2,335 alphanumeric or 3,116 numerical characters)
- Uses an error correction system to read codes that are as much as 40% damaged.
- They are made up of black and white cells in a square or rectangular pattern, a finder pattern and a timing pattern.
- Fixed-size code which holds up to 93 data characters.
- Composed of a central bulls-eye locator and offset rows of hexagonal elements.
- Created by United Parcel Service (UPS) to allow quick, automated scanning of packages on high-speed conveyor lines (Barcode readers can read a MaxiCode on a carton traveling at up to 550 feet/minute or 168 meters/minute).
- Contain square blocks of black cells on a white background with finder patterns in the top left, top right, and bottom left corners.
- QR was developed with the intention of being used for tracking parts during vehicle assembly.
- Named after the resemblance of the central finder pattern to an Aztec pyramid, the code is built on a square grid with a bulls-eye pattern at its center for locating the code.
- Data is encoded in concentric square rings around the bulls-eye pattern.
- Aztec codes have the potential to use less space than other matrix barcodes because they do not require a surrounding blank ‘quiet zone’.
- Instead of encoding data in the black bar and white space widths, these primarily use the height of the bars.
- Used primarily for numbers
- The POSTNET (Postal Numeric Encoding Technique) barcode is used by the U.S. Postal Service to automatically sort mail.
- Encodes data in the height of the bars.
Intelligent Mail Barcode (IMB)
- Used to sort and track letters and flats.
- Сarries sender’s information.
Stacked linear barcodes
- Ability to store up to 1,800 printable ASCII characters or 1,100 binary characters per symbol.
- It is also possible to break large amounts of data into several PDF417 codes which are linked together.
- In theory, there is no limit to the amount of data that can be stored in a group of PDF417 symbols.
© Rauf Aliev, June 2017