ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Convert Labels to Zebra's ZPL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert Labels to Zebra's ZPL

    Hi all:

    This program converts our standard label output to Zebra's ZPL printer output.
    Our labels are 5 lines but this should work on almost any output that does not use skip to line XX (other than top of page).
    Our labels are 40 char wide but this should work up to 80 chars wide.

    We developed this because we are too cheap to by TLAshford/Mark Magic etc..

    Hope it helps someone else.

    Code:
         H DFTACTGRP(*NO)                                        
         FPRTIN     IF   F  133        DISK                      
         FZEBOUT    O    F  132        PRINTER                   
                                                               
         DZEBPRT           PR                  EXTPGM('ZEBPRT')
         DZEBPRT           PI         
                               
         DZEBB4            S              3S 0 INZ               
         DFIRST            S               N   INZ(*ON)          
                                                                 
         IPRTIN     NS                                           
         I                                  1    1  CTLCHAR      
         I                                  2   81  PRTLIN       
                                                                 
          /FREE                                                  
                 DOU %EOF(PRTIN) ;                               
                     READ PRTIN ;                                
                     IF %EOF(PRTIN) ;                            
                        ITER ;      
                       ENDIF ;                            
                                                         
                      SELECT ;                           
                        WHEN CTLCHAR = '1' ;             
                             ZEBB4 = 50 ;                
                             IF NOT FIRST ;              
                                EXCEPT END ;             
                             ENDIF ;                     
                             EXCEPT START ;              
                        WHEN CTLCHAR = ' ' ;             
                             ZEBB4 += 50 ;               
                        WHEN CTLCHAR = '0' ;             
                             ZEBB4 += 100 ;              
                        WHEN CTLCHAR = '-' ;             
                             ZEBB4 += 150 ;              
                        WHEN CTLCHAR = '+' ;                          
                            ZEBB4 = ZEBB4 ;                          
                       OTHER ;                                       
                            ZEBB4 = 50 ;                             
                       ENDSL ;                                       
                       FIRST = *OFF ;                                
                                                                     
                      EXCEPT DTLOUT ;                                
                                                                     
                 ENDDO ;                                             
                  EXCEPT END ;                                       
                 *INLR = *ON ;                                       
          /END-FREE                                                  
         OZEBOUT    E            START             1                 
         O                                            8 '^XA ^POI'   
         OZEBOUT    E            DTLOUT     01                       
         O                                           10 '    ^FO01,'  
         O                       ZEBB4               13                   
         O                                           26 '^ADN,36,20^FD'   
         O                       PRTLIN             106                   
         O                                          109 '^FS'             
         OZEBOUT    E            END        01                            
         O                                            3 '^XZ'
    It is based on using a copied spool file with control characters.
    Code:
                 CPYSPLF    FILE(&PRTNAME) TOFILE(QTEMP/PRTIN) +  
                              JOB(&JOBNO/&USERNAME/&JOBNAME) +    
                              SPLNBR(&SPLNO) MBROPT(*REPLACE) + 
                             [COLOR=#ff0000][U][I]CTLCHAR(*FCFC) [/I][/U][/COLOR]        
    OR
           CPYSPLF FILE(QSYSPRT) TOFILE(QTEMP/PRTIN) + 
                              JOB(WSID/GLS400/123456) + 
                              SPLNBR(7) MBROPT(*REPLACE) + 
                              [COLOR=#ff0000][U][I]CTLCHAR(*FCFC) [/I][/U][/COLOR]
    Notes:
    The ^poi command prints the label INVERTED. You may want to remove that command.
    The CTLCHAR(*FCFC) places a "line number" in position 1 of the copied file.
    '1' = top of page
    ' ' = space before 1 line
    '0' = space before 2 lines
    '-' = space before 3 lines
    '+' = space before 4 lines

    Just direct the output to your zebra printer and it should work
    If not you can always get your money back

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  • #2
    Hi, I use a 3rd party API to generate some ZPL for a shipping label. I cannot print the ZPL - I have tried replacing the "^" with "¬", "@" etc but still nothing. The ZPL is stored on a table in multiple records and read 100 bytes at a time to create a spool. The completed spool is then sent to the Zebra printer. Any ideas would be welcome

    Comment

    Working...
    X