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
    ------------------------------



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

    Posted Tue February 07, 2023 02:52 PM
    Does the ^XA work for the Zebra printers that have a prefix format of 5EH?  Our Zebra printers were changed to the AA prefix format so that we could print a barcode label from the O specs in the RPGLE program.

    ------------------------------
    Steve Anderson
    ------------------------------



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

    IBM Champion
    Posted Wed February 08, 2023 01:50 AM
    Dear Steve

    Please look at Glenn Gross's post above and you will find the answer is yes.  Read the manual from the URL that Mr. Glen provided for more information.

    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



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

    Posted Fri February 10, 2023 08:32 AM

    Hello,

    I am still having issues, the spool file creates but nothing comes out of the zebra printer.

    Here is my code in the O specs of the program:

    ORITR339   E            D1               01                            
    O                                            3 '^XA'                   
    O          E            D1                                             
    O                                            4 '^FWN'                  
    O          E            D1                                             
    O                                            4 '^PRA'                  
    O* FIELD ORIENTATION: HORIZONTAL,VERTICAL                              
    O          E   N65      D1                                             
    O                                           21 '^FO310,30^A0,25,25^FD' 
    O                                           43 'Property of Agiliti^FS'
    O          E   N65      D1                                             
    O                                           21 '^FO310,30^A0,25,25^FD' 
    O                                           43 'Property of Agiliti^FS'
    O*                                                                     
    O          E            D1                                             
    O                                           11 '^BY2,2.4,20'           
    O*  THIS IS THE HUMAN READABLE TEXT                                    
    O          E            D1                                             
    O                                           21 '^FO250,63^A0,75,80^FD' 
    O                       S1PFX               24                         
    O                       S1EQNO              29                         
    O                                           32 '^FS'                   
    O          E            D1                                             
    O                                           21 '^FO251,63^A0,75,80^FD' 
    O                       S1PFX               24                         
    O                       S1EQNO              29                         
    O                                           32 '^FS'                   
    O*  THIS IS THE BAR CODE                                               
    O          E            D1                                             
    O                                           25 '^FO295,130,^B3,,60,N,D^
    O                       S1PFX               28                         
    O                       S1EQNO              32                         
    O                                           35 '^FS'                   
    O          E            D1                                             
    O                                            3 '^XZ'                   

    And  the resulting spool file:

    ^FWN                                        
    ^PRA                                        
    ^FO310,30^A0,25,25^FDProperty of Agiliti^FS 
    ^FO310,30^A0,25,25^FDProperty of Agiliti^FS 
    ^BY2,2.4,20                                 
    ^FO250,63^A0,75,80^FDAIK 0500^FS            
    ^FO251,63^A0,75,80^FDAIK 0500^FS            
    ^FO295,130,^B3,,60,N,D^FDAIK0500^FS         
    ^XZ                                         

    Do I need to override the printer file to allow for a zebra printer that has a prefix format of 5EH?

    Thank you, Steve



    ------------------------------
    Steve Anderson
    ------------------------------



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

    Posted Fri February 10, 2023 08:59 AM

    I pasted your code into an on-line viewer program

    Labelary Online ZPL Viewer

    saw "error" that it was missing a "^XA"

    adding that first line shows...



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



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

    Posted Fri February 10, 2023 09:21 AM

    I have that, it is my second line of code  

    ORITR339   E            D1               01                            
    O                                            3 '^XA'                   
    O          E            D1                                             
    O                                            4 '^FWN'          

    and those don't show up in the spool file output.



    ------------------------------
    Steve Anderson
    ------------------------------



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

    Posted Fri February 10, 2023 09:51 AM

    the spacing is hard to verify, but i wonder if the skip is in the correct column and "^FWN" is overwriting the "^XA"



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



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

    IBM Champion
    Posted Fri February 10, 2023 07:31 PM

    Dear Steve

    Please have a look if this guidebook from Zebra provides other useful information for your case : A Guide to Barcode Label Printing for IBM Midrange Servers



    ------------------------------
    Education is not the learning of facts but the training of the mind to think. -- Albert Einstein.
    ------------------------------
    Satid S.
    ------------------------------



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

    Posted Fri February 10, 2023 11:48 PM

    please post the code for your printfile.



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



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

    Posted Tue February 14, 2023 08:40 AM

    Here is the code that generates the printfile:

    ORITR339   E            D1               01                            
    O                                            3 '^XA'                   
    O          E            D1                                             
    O                                            4 '^FWN'                  
    O          E            D1                                             
    O                                            4 '^PRA'                  
    O* FIELD ORIENTATION: HORIZONTAL,VERTICAL                              
    O          E   N65      D1                                             
    O                                           21 '^FO310,30^A0,25,25^FD' 
    O                                           43 'Property of Agiliti^FS'
    O          E   N65      D1                                             
    O                                           21 '^FO310,30^A0,25,25^FD' 
    O                                           43 'Property of Agiliti^FS'
    O*                                                                     
    O          E            D1                                             
    O                                           11 '^BY2,2.4,20'           
    O*  THIS IS THE HUMAN READABLE TEXT                                    
    O          E            D1                                             
    O                                           21 '^FO250,63^A0,75,80^FD' 
    O                       S1PFX               24                         
    O                       S1EQNO              29                         
    O                                           32 '^FS'                   
    O          E            D1                                             
    O                                           21 '^FO251,63^A0,75,80^FD' 
    O                       S1PFX               24                         
    O                       S1EQNO              29                         
    O                                           32 '^FS'                   
    O*  THIS IS THE BAR CODE                                               
    O          E            D1                                             
    O                                           25 '^FO295,130,^B3,,60,N,D^
    O                       S1PFX               28                         
    O                       S1EQNO              32                         
    O                                           35 '^FS'                   
    O          E            D1                                             
    O                                            3 '^XZ'                   

    Thank you,

    Steve



    ------------------------------
    Steve Anderson
    ------------------------------