IBM i Global

 View Only
Expand all | Collapse all

rpgle barcode via o'specs help

  • 1.  rpgle barcode via o'specs help

    Posted Fri August 12, 2022 09:29 AM
    Hi,

    This really isn't in my wheelhouse but am being asked to produce a barcode from an RPGLE program.  We have some programs that do this but the "how" isn't obvious to me by looking at the code.

    Hoping somebody can point me to a manual or tutorial where this is referenced.  Below is some of the code in an already working program....
    (I see nothing in the control CL doing anything fancy, and the O'specs are minimal)

    IF SIZE = 1
    EVAL DATA1='~CC¬
    EVAL DATA2='
    EXCEPT DETAIL
    ENDIF
    IF SIZE = 2 OR SIZE = 3
    EVAL DATA1='~CC¬XZ
    EVAL DATA2='
    EXCEPT DETAIL
    ENDIF

    EVAL DATA1='¬XA¬JMA¬FS¬XZ
    EVAL DATA2='
    EXCEPT DETAIL

    EVAL DATA1='¬XA¬MTT¬FS¬XZ
    EVAL DATA2='
    EXCEPT DETAIL

    EVAL DATA1='¬XA¬MNY¬FS¬XZ
    EVAL DATA2='

    (Ospec)...
    *******************************************OUTPUT SPECS******
    OPRINTER E DETAIL 1
    O DATA1 29
    O DATA2 66

    (try a snip since the copy and paste removed formatting)


    ------------------------------
    Kevin Barkema
    ------------------------------


  • 2.  RE: rpgle barcode via o'specs help

    IBM Champion
    Posted Mon August 15, 2022 07:46 AM
    Hi Kevin,

    Cool project! What are the barcodes for? 

    I've done integrations like this several times and I'd strongly recommend delegating this to an Open Source system like Node.js or Python.

    Those systems have free pre-built modules that will take care of this entire task for you, often with a single line of code. I've seen a lot of people implement this, and generally the packages have saved them a lot of headaches and development time and prevented production bugs.

    For example, if you're generating 1d barcodes you could use this popular package:
    https://npmjs.com/package/jsbarcode

    Or if you wanted to generate 2d qr codes you could swap it out for this package:
    https://www.npmjs.com/package/qrcode

    There are also some packages you could string together to then print your barcode from a zebra printer or embed it within a pdf.

    Let me know if you have any questions, I'm always happy to help!

    ------------------------------
    Aaron Magid
    VP, Open Source Technologies
    Eradani
    510-295-9297
    aaron@eradani.com
    ------------------------------



  • 3.  RE: rpgle barcode via o'specs help

    IBM Champion
    Posted Wed August 17, 2022 07:34 AM
    By the way, this module can generate ZPL for you that handles barcodes, shapes, text, fonts, styles, images, and pretty much anything else you could want to print. You would not need to learn ZPL or write and maintain your own printer driver:

    https://www.npmjs.com/package/jszpl


    ------------------------------
    Aaron Magid
    VP, Open Source Technologies
    Eradani
    510-295-9297
    aaron@eradani.com
    ------------------------------



  • 4.  RE: rpgle barcode via o'specs help

    IBM Champion
    Posted Mon August 15, 2022 10:35 AM

    There is clearly something missing from the code you show - unless the output target is maybe a barcode printer?  In that case the "tutorial" will be a generic one for the specific printer. 

    RPG normally produces barcodes via an externally defined printer file - details of the relevant keyword here: https://www.ibm.com/docs/en/i/7.1?topic=80-barcode-bar-code-keyword-in-printer-files



    ------------------------------
    Jon Paris
    ------------------------------



  • 5.  RE: rpgle barcode via o'specs help

    Posted Mon August 15, 2022 11:29 AM
    Looks like a barcode printer language, perhaps ZPL or EPL2.  Start with the make and model of the printer that is being used and you should be able to google your way to the printer language manual that will help you interpret that.

    These were very common in warehouse environments for shipping labels, etc.

    Beware that there might be some EBCDIC/ASCII conversion going on that alters some of the characters, so if you find something with that CC or XA command, you're probably on the right track.

    The other suggestions of third party barcode projects or the barcode DDS keyword are good ones. if the printer supports it, but its arguable which is more understandable for the next guy.  In any case, when you figure it out, add a few comments so the next guy isn't in the same boat.




    ------------------------------
    Vincent Greene
    IT Consultant
    Lab Services Power Systems Delivery Practice
    IBM
    Vincent.Greene@ibm.com


    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    ------------------------------



  • 6.  RE: rpgle barcode via o'specs help

    Posted Mon August 15, 2022 11:30 AM
    Hi Kevin - I'm assuming these barcodes are being printed on a thermal label printer... something like a Zebra.

    The RPG program is generating codes that the printers will interpret and print as barcodes.  You can accomplish the same thing by sending a raw TXT file to the printer with those same codes.

    You can google ZPL (Zebra programming language) for more details.

    ------------------------------
    ed komeshak
    ------------------------------



  • 7.  RE: rpgle barcode via o'specs help

    Posted Mon August 15, 2022 11:31 AM
    Hi Kevin - I'm guessing these labels are being printed on a thermal-label printer... like a Zebra.

    The RPG is generating codes specific to these types of printers.  There is nothing specific on the server side (RPG, CL, etc) that is generating the barcode.  You can simulate the same thing by just sending a raw TXT file to the printer with those codes. 

    You can google ZPL (Zebra Programming Language) for details

    ------------------------------
    ed komeshak
    ------------------------------



  • 8.  RE: rpgle barcode via o'specs help

    Posted Tue August 16, 2022 08:10 AM
    As an aside, I (re)found a site that would render the ZPL barcode for you.

    http://labelary.com/viewer.html

    ------------------------------
    Bryan Dietz
    ------------------------------



  • 9.  RE: rpgle barcode via o'specs help

    Posted Tue August 16, 2022 01:08 PM
    Have to agree with some of the other posters, although, I'll say in a different way ...

    Almost all printers allow what are called escape sequences  to do stuff like bold, different size fonts and other stuff. However, with the advent of wiziwig applications like Word, we never see this "raw' behavior anymore and many haven't a clue it exists. You didn't say your printer vendor but many guessed zebra as it is a common label printer for this kind of stuff. I see what looks like DATA1 being the leadin and DATA2 having a value with an appended sequence so I'm 99.9% sure this is what is going on.

    So it sure looks like the original developer was using raw sequences to activate barcode mode and then turning it off. If no change in printer or type of bar code (ie upc vs qr) ... use the same sequences and give it a try in your new app. If a change in printer or type of barcode ... dig out the manuals ... the real manuals, not the one that says thank you for your purchase, plug in cable and have a nice day.

    Terry

    ------------------------------
    Terry Schwarz
    ------------------------------



  • 10.  RE: rpgle barcode via o'specs help

    Posted Thu August 18, 2022 08:51 AM
    I just finished a barcode project and it helped me to think of it this way -- a barcode is just text printed with a different font. So you need to handle it like you would change any other font. We did end up exporting the data for printing at a third party so I can't help with any specifics. We also did the barcode reading with open source (node.js) because we took a PC network off-site, although it can be done in RPG.  Again, a barcode scanner is just like a keyboard. Those two concepts helped me get my head wrapped around the project.

    ------------------------------
    Lori Austin
    ------------------------------



  • 11.  RE: rpgle barcode via o'specs help

    IBM Champion
    Posted Thu August 18, 2022 09:27 AM
    That's a good way of looking at it, @Lori Austin​​

    ------------------------------
    Jack Woehr
    IBM Champion 2021 -2022
    ------------------------------



  • 12.  RE: rpgle barcode via o'specs help

    Posted Fri August 19, 2022 08:57 AM
    A lot of good info here. The code looks like the raw zebra print codes I have used. It is low level printing to a barcode zebra printer.
    I see "EVAL DATA1='¬XA¬JMA¬FS¬XZ"  is a ZPL codes.
    This manual should help.
    https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf

    Example from PDF page 374.
    ZPL Commands ^XA
    The ^XA command is used at the beginning of ZPL II code. It is the opening bracket and indicates the start
    of a new label format. This command is substituted with a single ASCII control character STX (control-B,hexadecimal 02).
    Start Format
    Format: ^XA
    Comments: Valid ZPL II format requires that label formats should start with the
    ^XA command and end with the ^XZ command

    ------------------------------
    Glenn Gross
    ------------------------------