We help IT Professionals succeed at work.

Barcoding Code in RPG400

9,609 Views
Last Modified: 2013-12-06
Hi,

I want a program in RPG/400 for Barcoding.  Please I need sample code for both read & write

Barcode.  Yes, separate Read barcode RPG & Write barcode programs is required.

I will give you the printer specification. I have two printers: One is Wipro 1050 printer

and the other one is SATO CT400 printer.

We normally use the Wipro Printer for our AS/400, the device named for this printer is

'purprn'.  The SATO printer is purchased for barcode printing from other applications and

not AS400.

Plz, I need programming code for both printers.

Regards,
Praveen.
Comment
Watch Question

Application Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi Murph
Thank you for what ever you have sent.  I already have this with me, downloaded from Ibm site.

As I said I am using Sato CX Series Printer for Barcode.  So, I need a sample code for reading and also writting.  I have attached a label which I want to print using AS400, written in RPG400.

I also have the Barcode Scanner(Manufacturer: Symbol).  These hardwares are not used through AS400.  But I want to use it by writting code in RPG.  I need your help, plz provide me some sample codes.

Regards,
Praveen.
Lbl1.bmp

Author

Commented:
Hi,
I would like to add, apart from RPG Coding if it requires DDS code for creating the Label and also for storing data(PF).

Plz mention the coding for the same.

Thanks and I doubled the points.
Praveen.
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Dear Murph,

Thank you for all the good programming suggestions.  I am struggling to create a basic report program in which I have added a barcode field.  Can you help in posting an example code.  Any four fileds including a fileld with barcode.  I want to print a label.  Say three input fields after entering the value, if given print command(using any function key), the label should print with those entered values in three fields along with a barcode.

Thank you Gary for your support.

Regards,
Praveen.
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi Praveen,

I will look in the office tomorrow  for a sample program.

Regards,
Murph
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Murph,

Thank you very much, I will try and get back to you.


Regards,
Praveen.

Author

Commented:
Murph,

Ok, I have tried and can get the output, however to get the barcode,
I have added following line to get the barcode output while I print.
c                   eval      bar1='123456'

However, "Bar codes not displayed" error is displayed in the spool file.  And if I assign the Printer, then it goes to HLD status always.

And one more thing I have also changed the Printer Device Type as *AFPDS and Unit of Measurement as *CM.

Please help me in getting the barcode print.

Thanks,
Praveen.

Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi Praveen,

The code I send you was compiled without errors and processed with a result containing a barcode.

I will check again tomorrow what the printed barcode contains, but the sample will print
as long as the printerfile is compiled with *AFPDS

Regards

Author

Commented:
Murph,

The code is perfectly working.  But the Barcode print is not coming.  So I added the extra line, which also not giving any barcode print.

I am sending spool file to a WIPROLMP P-500 LINE PRINTER, this is network printer

Murph can I give you 500 points for all the efforts you are taking for me..

Thank you.
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
A line printer?
do you mean a dot-matrix printer? I think you will never get a barcode from such printer.
Unless it's an IPDS printer, in that case recompile your BAR001P printerfile with *IPDS instead of *AFPDS.

Did you test the output on a laser printer?

Regards,
Murph

Author

Commented:
Murph,

I have tried with laser printer, it is HP 2015.. except the barcode rest of the text in the three fields entered is printed.

regards,
Praveen

Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT

Commented:
I thought the task was to print a barcode on the Sato CX?  That takes a whole different approach than to print on an AFP (or AFP via Host Print Transform) printer.

Murph's program, above, generates AFP (Advanced Function Printing) printer language.  You need an AFP printer to print AFP-language spooled files, OR you need to tell the AS/400 operating system to use the Host Print Transform (HPT) function to convert AFP to the printer's native language.

The Sato CX does not "speak" AFP.  It uses a proprietary printer language that is not supported by HPT.  That means that your program has to "speak" the Sato's language directly, and you need to take steps (Ascii Transparency) to make sure that no formatting of the print stream is done by the operating system before sending it to the printer.  You have to look up the commands in the Sato manual, and then create strings in your program containing the various printer commands.  It is a real pain.  See my earlier comments for sample code for this approach.

Most people buy software to do this, like TL Ashford's Barcode/400.  It has all of this support built in for a bunch of proprietary printers.

The HP 2015 is a different animal.  It supports the popular PCL printer language, and Host Print Transform knows how to generate various flavors of PCL from AFP.

Try configuring the HP 2015 with:  TRANFORM(*YES) MFRTYPMDL(*HP5SI).  This tells the AS/400 print subsystem to turn on Host Print Transform, and also which IBM-supplied workstation customization object to use to translate AFP into HP PCL.

Check out this IBM Redbook for more information on configuring Host Print Transform:

http://www.redbooks.ibm.com/redbooks/pdfs/sg242160.pdf

This IBM Support Document provides HPT settings for many ASCII printers:

http://www-912.ibm.com/s_dir/slkbase.NSF/0888cc5d18fceca58625680b005dc690/b44a2cf4ba778d83862568250053649f?OpenDocument

HPT Settings for HP Printers, including the 2000 Series:

http://www-912.ibm.com/s_dir/slkbase.NSF/7c4c0f5a4d52e3c4862569b4005d198a/ba0863cfa6463903862569c10078c903?OpenDocument

All of that said, if at the end you need to print barcodes on the Sato, Host Print Transform won't help - you'll need to use ASCII transparency and figure out the stream of printer commands that you need to send to the printer to format your label.

Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi Praveen,

I'm almost sure that the HP 2015 is supporting AFP, check the DEVD of that printer on the AS?400 and try to change it in AFP, to tell the AS/400 that AFP data can be send.

Regards,
Murph
Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT

Commented:
Murph / Praveen,

The HP 2015 isn't an AFP printer.  As far as I know, HP doesn't make any native AFP printers.  It is just a little personal laser that supports PCL5e, PCL6, and HP Postscript L3:  

http://h10010.www1.hp.com/wwpc/us/en/sm/WF06a/18972-18972-3328059-14638-3328066-1845551.html

You CAN, however, use Host Print Transform on the AS/400 to convert from AFP to PCL5e per my instructions above.

HP also offers "The Blue Kit" which can convert some HP printers into AFP/IPDS printers:

http://www.hp.com/sbso/product/printing/laserjetfonts/emulation.html

- Gary Patterson

Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT

Commented:
Praveen,

Setting the HP 2015 outq or device description to DEVTYPE(*AFPDS) or AFP(*YES) isn't enough.  You need to use host print transform and specify the manufacturer type and model as in my earlier comment:

TRANFORM(*YES)
MFRTYPMDL(*HP5SI)

And regardless of how the printer is configured, you won't be able to view the barcode from WRKSPLF - you'll need to actually print it.

Regards,

-Gary

Author

Commented:
Thank you Gary and Murph...

I was thinking it is so simple but it is not.  I will be out of my office, so I will be out of touch with AS400.  I try your suggestions and once I gone through I will get back to you.

Thank you once again.

Have a nice time.
Rgds,
Praveen.
Gary Patterson, CISSPExpert for hire: IBM i, AIX, Linux, Windows, DB2, Performance, Security. EDI
CERTIFIED EXPERT

Commented:
Praveen,

As Murph's examples show, printing barcodes on an AFP printer is pretty easy.  IBM expects you to use an AFP printer for this sort of thing on the iSeries.

If you don't have an AFP printer, a lot of common printers can be used (with some limitations) through Host Print Transform, which converts AFP into the target printer's native language on the fly on the AS/400.  There is an extra step, of course - you have to configure HPT for the target printer on the AS/400 (DEVD or OUTQ).

When you get away from AFP printers (and HPT-supported printers) is when it gets complex - then you have to write programs that output low-level printer language, and that varies from manufacturer to manufacturer and even from model to model.

-Gary
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi Praveen,

If you use barcodes ore then sometimes, and the result must be constant, skip Laserprinters and lineprinters completely.
Try to shop for a Barcode printer Like Zebra, Stripe or UBI
Zebra and Stripe are the most used, but UBI is far more easy to  program without experience.

Regards,
Murph

Author

Commented:
Murph,

I am back to office, I will try and let you know.

Thanks,
Praveen.

Author

Commented:
Hi Murph & Gary,

I was trying a program to send a data stream, I get the output as:  $.  Ú  Ø~ «  
snippet is added below.

However, I am unable to print the barcode, I studied and checked, my pdt file is correct for the printer HP 2015.  What more programming I need to do.

Is that I need to write a printer program - O-Spec.  Is there no easy way out.  
Actually I am not getting enough time to study all the documents you have sent to me.  I m reeeeely soorry..

Do you have any program written for a HP Printer.  The barcode output gets from any HP LASERJET Printer??

Thanks,
Praveen.

    FQSYSPRT O   F      19            PRINTER
    E                    CHR        19  1               DATA STREAM
    C                     BITOF'0123'    CHAR1   1
    C                     MOVE CHAR1     CHR
    C                     BITON'67'      CHR,1
    C                     BITON'37'      CHR,2
    C                     BITON'3467'    CHR,3
    C                     BITON'13467'   CHR,4
    C                     BITON'1467'    CHR,5
    C                     BITON'45'      CHR,6
    C                     BITON'0123456' CHR,8
    C                     BITON'237'     CHR,9
    C                     BITON'7'       CHR,10
    C                     BITON'0'       CHR,11
    C                     BITON'027'     CHR,12
    C                     BITON'7'       CHR,13
    C                     BITON'046'     CHR,14
    C                     BITON'5'       CHR,15
    C                     BITON'5'       CHR,16
    C                     BITON'5'       CHR,17
    C                     BITON'5'       CHR,18
    C                     BITON'5'       CHR,19
    C                     EXCPTCONDIT
    C                     SETON                    LR
    C            EOJ      TAG                            +++ EOJ
    OQSYSPRT E                CONDIT
    O                         CHR

Open in new window

Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
Hi Praveen,

The example I posted here was a working example on a Lexmark printer, that runs also PCL like HP, so that is no problem.

The C lines above can be replaced by Dspecs like :
And use the DS name :)

DCHAR             DS            19              
DC01                             1    Inz(X'03')
DC02                             1    Inz(X'11')
DC03                             1    Inz(X'1B')
DC04                             1    Inz(X'5B')
DC05                             1    Inz(X'4B')
DC06                             1    Inz(X'0C')
DC07                             1    Inz(X'00')
DC08                             1    Inz(X'FE')
DC09                             1    Inz(X'31')
DC00                             1    Inz(X'01')
DC11                             1    Inz(X'80')
DC12                             1    Inz(X'A1')
DC13                             1    Inz(X'01')
DC14                             1    Inz(X'8A')
DC15                             1    Inz(X'04')
DC16                             1    Inz(X'04')
DC17                             1    Inz(X'04')
DC18                             1    Inz(X'04')
DC19                             1    Inz(X'04')

Open in new window

Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Commented:
BTW i inserted line C07 my self I assumed it should be x00 becuse it was missing in your source

DC07                             1    Inz(X'00')

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.