Saturday, December 18, 2010

SAP: 26 different barcodes on a page with 1 ABAP report for FREE

So why have 26 different barcodes on one page with one ABAP report?

It's basically to demonstrate another way to use the Barcode Writer in Pure Postscript with SAP. Check out the BWIPP to see all the barcodes it supports.

My previous blogs have demonstrated integrating the BWIPP code for one barcode into a device type. This link demonstrates the approach using QR codes. Check out my SDN blog covering the technical detail.

However the method I will cover here requires some simple scripting to integrate the BWIPP into the SAP output stream for further processing at the desktop/printer. The following screen shot is the final result.



Windows XP Desktop Method - PDF


Steps involved
1) Download the BWIPP here
2) SAP Device types/output device and ABAP code 
3) Ghostscript ( I used version 8.64 for this demo)
4) Redmon (it can be found on the general ghostscript link above aswell)
5) Microsoft Service for Unix*
6) Final step run the ABAP code.


*As I used Solaris to develop the scripts on a Unix system I use the Unix based commands to integrate the BWIPP on windows. After reading the detail you may be able to help me out and suggest another method, I would like to hear about any other suggestions.


1) BWIPP
Extract the zipfile and the barode.ps file should be placed in the ghostscript bin directory that is covered later.


2) SAP Device type
The SAP Device type this time only sets up the postscript code to call the barcode. Therefore the insertion of the barcode.ps at the desktop/printer is essential.

SAP Device Type here ZBWIPP  (Filename = ZBWIPP.PRI)
SAP Output Device ZBWIPP_ALL (Filename = ZBWIPP_ALL)
SAP ABAP Code ZBWIPP_PRINT (Filename = ZBWIPP_PRINT.TXT)

Download all 3 files in a zip file here

Follow the QRcode guide but import the above files into SAP at the appropriate place.

The Output device will be ZBWIPP_ALL
The device type will be ZBWIPP
and the ABAP code is called ZBWIPP_PRINT
#######################################################################
### 17-Jan-2011 update
### Due to a change in the barcode writer in pure postscript then the ZBWIPP device type
### needs to be updated. Read about the BWIPP change in the link to the BWIPP mailing list
So the following printer controls need to be changed ZBW26 ZBW27 and ZBW28
text for the 3 barcodes below starting from ZBW26
zbst\n/zzbc (databaromni) def\nbct sqrd\nzben\n
zbst\n/zzbc (databarexpanded) def\nbct sqrd\nzben\n
zbst\n/zzbc (databarlimited) def\nbct sqrd\nzben\n
###
###
#######################################################################


3) Ghostscript is required to process the postscript file and create the PDF. The rest of the scripts will be placed in the bin directory of the ghostscript install.

4) REDMON is required for XP to create a printer in XP that SAPLPD can use. The scripts run with REDMON will integrate the BWIPP into the SAP output stream and call ghostscript to produce the final PDF.

This is the guide for a virtual postscript printer that I modified in the following way

Its IMPORTANT again to match the SAP printer name with the desktop printer. The name has to be the following "qrcodeport" (obviously if you know what your doing you can change it and you can see the qrcode origins of all of this :)



Basically the call to the printer is not made, so only one REDMON printer port is setup and the script called is PBWIPP.BAT as shown here


Script for REDMON

PBWIPP.BAT

cat - > "C:\Program Files\gs\gs8.64\bin\temp.ps"
cd "C:\Program Files\gs\gs8.64\bin\"
bwipp.ksh temp.ps



5) Microsoft Services for UNIX.
Now as my background is in UNIX then I used UNIX scripts for the Windows install. If you think there could be a better way then I would be happy to hear about any suggestions.
* I have found another way that bypasses both Redmon and Microsoft Service for Unix here.
barcode.ps needs to exist in the bin directory, its best to remove the very first line.

Script should be placed again in the ghostscript bin directory.
BWIPP.KSH
#!/bin/ksh

export PATH=$PATH:/dev/fs/C/"Program Files"/gs/gs8.64/bin/:/dev/fs/C/"Program Files"/gs/gs8.64/lib/

cd /dev/fs/C/"Program Files"/gs/gs8.64/bin

#move the SAP postscript input to one side
cat $1 >$$sap.ps

#insert Postscript
sed '/INSERTBARCODE/ r barcode.ps' <$$sap.ps >     $$sap1.ps
mv $$sap1.ps $$sap.ps

gswin32c.exe -q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=ghost$$.pdf  $$sap.ps

runwin32  start acrord32.exe "c:\program files\gs\gs8.64\bin\ghost$$.pdf"

rm -f $$sap.ps
rm -f temp.ps


6) Final step run the ABAP code.
From transaction se38 run the ABAP code created earlier.
Its IMPORTANT to select the following options for page format X_65_80 and print immediately.


and the final PDF should appear in the bin directory.

NOW as it is all based on device type print controls then all the above can be used in SMARTFORMS or SAPSCRIPT.
As per the following youtube video but there is no need to change printers if the above method is used...



Printer Control Barcode Postscript code
ZBW01 MANDATORY at the START of every BARCODE
ZBW02 qrcode
ZBW03 datamatrix
ZBW04 azteccode
ZBW05 maxicode
ZBW06 auspost
ZBW07 code11
ZBW08 code128
ZBW09 code2of5
ZBW10 code39
ZBW11 code93
ZBW12 ean13
ZBW13 ean8
ZBW14 interleaved2of5
ZBW15 isbn
ZBW16 japanpost
ZBW17 kix
ZBW18 msi
ZBW19 onecode
ZBW20 pdf417
ZBW21 pharmacode
ZBW22 plessey
ZBW23 postnet
ZBW24 rationalizedCodabar
ZBW25 royalmail
ZBW26 rss14
ZBW27 rssexpanded
ZBW28 rsslimited
ZBW29 upca
ZBW30 upce
ZBW31 leitcode
ZBW32 hibccode128
ZBW33 hibccode39
ZOP01 /bcopt (parse) def\n
ZOP02 /bcopt (raw) def\n
ZOP03 /bcopt (includetext) def\n
ZOP04 /bcopt (includecheck includetext) def\n
ZOP05 /bcopt (format=truncated) def\n
ZOP06 /bcopt (format=stacked) def\n

2 comments:

Anonymous said...

Great implementation!
But I'm stucked trying to print control charaters as group separator, end of transmission and record separator. I've tryed many ways using different characters (\0x1d, /0x1D, /x1D, \u001D, {GS} ..) with no success.
Did you have a solution?

Robert Russell said...

Hi Simone,
I am guessing your name :)
But I replied here
http://scn.sap.com/people/robert.russell/blog/2010/10/25/barcodes-in-sap-with-the-barcode-writer-in-pure-postscript#comment-591802

Cheers

Robert

Post a Comment

Google +