Skip to Content
Author's profile photo Former Member

More Barcodes with Barcode Writer in Pure Postscript

Previously I covered a standalone method to introduce the Barcode Writer in Pure Postscript (BWIPP) into SAP smartforms and sapscript which can be found here Barcodes in SAP with the Barcode Writer in Pure Postscript.. That particular blog covered a method to introduce any one of the barcodes supported by the BWIPP into a SAP device type.

This blog demos extended use of the BWIPP and is in 3 sections

1) Barcode Sample Page. Generate barcodes by merging the BWIPP code with the SAP output stream on the desktop with free pdf software.

2) Generate custom barcodes with BWIPP and display them using the ABAP Bitmap class from Thomas Jung.

3) Using standard (free) GuiXT scripts to generate a barcode to display in Windows sapgui.

1) Barcode Sample Page

Below screen shot covers 26 barcodes on one page using ABAP print controls.

26 barcodes in SAP with BWIPP


Here I cover a method by using desktop PDF software to merge the BWIPP into the SAP output stream on the desktop. This removes the need to install the BWIPP barcode postscript code into the device type. The only postscript code left in the device type controls how to use the BWIPP.

Follow this link to a Device Type I prepared earlier

The link points to a zip file containing a device type called ZBWIPP (ZBWIPP.PRI), a text file containing the ABAP code for the sample page (ZBWIPP_PRINT.TXT) and an output device ZBWIPP_ALL. Also the BWIPP file linked to the device type.

Postscript Device Type changes

Refer to the Barcodes in SAP with the Barcode Writer in Pure Postscript.for the technical details however what remains in the device type is the CREDITS action page. The main change to the code is to allow the barcode of choice to be defined in a variable. The ZBW01 printer control remains, however as shown below the printer controls change depending on which barcode is required.

ZBWIPP device type's printer controls

The CREDITS action page postscript code is here…

The above code again controls how the BWIPP is used, and the main change from the previous blog is the line.

/sqrd {bcopt zzbc / findresource exec} def

This basically allows the barcode to be set by the device type’s printer control. This is done with the zzbc variable.

As shown in this extract from my device type.

ZBW25 zbst
/zzbc (royalmail) def
bct sqrd

The royalmail barcode would be selected with printer control ZBW25.

Options are shared among all barcodes.

ZOP03  /bcopt (includetext) def

So to use the option to include text in a barcode then ZOP03 would be used for all barcodes. Refer to the device type for the options already setup or the BWIPP wiki page for any other options required.

By removing the BWIPP code from the device type then it needs to be integrated at the printer ( a postscript printer may allow the BWIPP code to be uploaded to memory) or desktop. In this blog I will again cover the desktop PDF way.


I now use PDFcreater which to quote “is free, even for commercial use” check out the website for further details.

The options to include the (which is the BWIPP)

By placing the in the additional parameters will allow the ghostscript call to process and the SAP postscript output to use the BWIPP.


You may have noticed the fact that is in the cutepdf directory in my screenshot. So you can do the same thing with cutepdf by creating a setup.ini file with the following contents for cutepdf.

Command=”C:program filesgsgs8.64 ingswin32c.exe”
Arguments=-q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=”%1″ “C:Program FilesAcro SoftwareCutePDF Writer” –

The above example uses my ghostscript 8.64 version. Also as I am not sure how the above will be formatted in this biog, its 3 lines and the Arguments line ends with a

 *)Note Ghostscript resource

The above config for the PDF software  (and in the other 2 sections below) is for a demonstration in this blog and uses ghostscript batch processing of postscript files to use the BWIPP. Ghostscript resources are normally found in a directory called Resource (parameter GenericResourceDir). In the download section of the BWIPP website refer to the README file in the tarball for use with Ghostscript. Using the resource directory method you could pick a combination of barcodes and not the entire file (and then remove the references to the in the above examples).

ABAP report for the 26 barcode sample page.

The sample page was produced using a standard ABAP report (ZBWIPP_PRINT.TXT in the zip file) with printer controls. I used the “new-page print on.” command which is a depreciated command but it’s the easiest way for me to demonstrate the wide range of barcodes supported by the BWIPP.

The report was done using page format X_65_80.

If you want to run the report then you need to have activated “print immediately”  for your SAP user account. The output device ZBWIPP_ALL in the download zip file in this blog is a frontend printer linked to the PDFCreator printer on the desktop.

There is a youtube video in the previous blog covering the use of BWIPP in smartforms and a link for sapscript.

2) Generate custom barcodes with BWIPP and display them in a Bitmap Class.

The next two methods were inspired by reading SDN and are on my demo SAP system.

I had the idea I was only a conversion (or two) away from getting an image bitmap of a barcode but how to display this in ABAP. I am not a developer but I was interested enough to search SDN for a possible answer. So I do start with how I found the main code to display a bitmap with ABAP.

While reading Blag’s The specified item was not found., I read the webdynpro blog Web Dynpro ABAP: Display tiff images by Elvez who linked to Thomas Jungs blog Web Dynpro ABAP: Display tiff images. And who did Thomas Jung quote but full circle back to Blag. So thanks to all the links and contributions I did have some way to progress my idea.

I used Thomas Jung’sABAP Bitmap Image Processing Class and code for the ability to display bitmaps only. I was not intending to do any further processing. So why the bitmap class, well the main intention is to show a method to generate a custom barcode. Thomas Jung also provided the code for the bitmap class and example ABAP reports, so I was happy to use this to display the resulting bitmap image.

I have a newly installed demo SAP server so I added the code to generate barcodes (via sm49 commands) and upload via dataset commands controlled by the ABAP program. I am not an ABAP developer so it’s the idea and not my (adapted from examples) code that I want to share. I would be happy to hear about alternate/better methods to show barcodes in ABAP (or if there are any issues with the approach I have taken). There are many ways to convert from postscript to a bitmap, and the following is obviously a demonstration of 1 way to do the conversion.

I was hoping to have a standalone barcode generator controlled via ABAP webdynpro and Thomas Jung includes ABAP webdynpro code however it remains a possible long term side project for me. 

A comment on my previous blog came from  Sergio Ferrari so I took the opportunity to contact him in regards to the general approach I was taking with the BWIPP. He pointed out his  abap2qrcode webdynpro code can accommodate different backend engines. So I downloaded and installed the code and from the structure of the webdynpro I can see the potential for using BWIPP. However developing in ABAP webdynpro is not in my plans. I appreciated Sergio’s suggestions and encouragement to continue. Sergio also kept in touch in regards to sharing ideas and collaborating on mobile tagging in SAP and he is great at getting people involved. He made me aware of Durairaj Athavan Raja‘s work related to mobile tagging and involved us all in the Wiki process. If you have any ideas/suggestions around the mobile tagging subject then please join in.

So adapting the classic ABAP dynpro example Thomas Jung provided, here is the screen shot of the options page.


barcode option page


Here is the QRcode result for the bitmap class weblog by Thomas Jung. ( I have downloaded the URL shortener on code exchange, but using that is for another day)

qrcode for bitmap class blog

Another barcode this time ISBN barcode.

ISBN from agoogle search

ISBN from a google search

 Here is how I did it in general terms,

You will need the following,




All programs need to be in the PATH environment variable of the {SID}adm used

I placed all scripts in the work directory of my demo server.

Postscript Dataset options

Obviously we need to generate postscript code from the user supplied selections for the BWIPP to generate the required barcode.

Here is how I did this with the dataset command…..

concatenate ‘0 0 moveto (‘ text  ‘) (‘ options ‘) /’ BARCODE ‘ / findresource exec’ into TEXT1.
concatenate psX pSY  ‘ scale’ into TEXT2.
TRANSFER ‘gsave’ to psnm.
TRANSFER ’50 50 translate’ to psnm.
TRANSFER ‘grestore’ to psnm.
TRANSFER ‘showpage’ to psnm.


text/BARCODE/psX/pSY are parameters for the selection screen. The BARCODE parameter needs to match the BWIPP. I used the  “CALL FUNCTION ‘VRM_SET_VALUES'” code to use the drop down menu for the BARCODE selection (to ensure a valid selection).The postscript code for the position of the image is hard coded with the translate command. It’s my choice you may need to experiment with the position of barcodes depending on the size and scaling options used for the barcode.

Barcode Generation with external commands

So now we have the postscript code we need to generate the barcode, here is the SM69/49 external scripts.

ZBWIPP external command defined in transaction SM69.

bat file sapbwipp.bat in the SAP work directory.


cd usrsapNSPDEVEBMGS00work


ps2epsi out.eps & convert -density 85 out.eps BMP3:rob.bmp


Basically the above dos bat file takes the dataset of the barcode options and merges this with the file.

ps2epsi is key to generate what is known as an encapsulated postscript file (EPS). The EPS conversion is required to allow only the image of the barcode to be processed further and not the entire page. (ps2epsi is a script with ghostscript)

convert is imagemagick doing its magic to convert the EPS file to a bmp file. Now it may or may not be the case of a convert issue with Windows systems depending on the PATH environment variable. e.g. convert is also a system command so check out this link on the image magick site for this convert issue. It would be useful to test the conversion purely on the operating system to check PATH variables or any other issues.

Density actions need to be confirmed for any requirements. 2d barcodes can work with lower density settings however text in some 1d barcodes required higher density to be clear in the bitmap. More info can be found with this link to the image magick site here

The BMP3 option was my solution to actually see an image in the bitmap class, the reason I tried the option BMP3 is in this link.

The way I used ABAP to run the external command is here in the WIKI, it’s a Unix related page however the ABAP code is what I required for my windows based sm49 commands.

    commandname                   = ‘ZBWIPP’
*   additional_parameters         = v_dir_input
*   operatingsystem               = c_oper
    exec_protocol                 = t_result
    no_permission                 = 1    …..there is more so see the wiki page……

Bitmap Image Dataset options

 I knew I had to upload a binary file, so I started with this search however, I can’t recall the exact search options I finally used but  I got the following for the dataset options from this another image question – using Regular ABAP not web dynpro

 IF bitmap IS INITIAL.
 DATA: lv_ds TYPE string VALUE ‘rob.bmp’,
             lv_xstring TYPE xstring.
  CHECK sy-subrc = 0.
    READ DATASET lv_ds INTO lv_xstring.

Display the Barcode
Thankfully Thomas Jung had put some comments into his blog covering his code, so I could swap out the frontend upload and use the xstring from the dataset.

*   bitmap = zcl_abap_bitmap=>create_from_frontend_upload( ).
bitmap = zcl_abap_bitmap=>create_from_bytestream( lv_xstring ).
             i_container = custom_container ).
      CATCH zcx_abap_bitmap .
ENDMODULE.                 ” STAT

The barcode image file is hardcoded in the code above and no unique file names are used for the temporary files. However the image file is created on the filesystem.

Now all the above lead to me to a demo with GuiXT

3) Windows SAPGUI barcodes with standard GuiXT

 GuiXT in its standard form allows scripts to run to display images.

So using the same scripts as above with some slight modification we can generate a QR code with MEcard formatted data as below. It is a demo and only uses the postcode and other items for demonstration purposes. I had already tried scanning a MEcard Generating QR codes with a Zebra Crossing in the Java stack, so I thought SAP could generate one on the desktop.


qrcode with address details in mecard format

So taking the business partner transaction (/nBP). The guixt script will call one dos bat file which in turn will call a dos bat script to generate the barcode image. This example uses QRcodes, however it could obvioulsy be one of the BWIPP supported barcodes depending in requirements.

You need to know the directory used by GuiXT which is normally guixt  (or guixt/scripts). The following examples are hardcoded with c:GuiXT. In the GuiXT directory place the file (in this example I renamed the file to Again both ghostscript and imagemagick programs need to be in the PATH environment variable of the user.

In c:GuiXT folder create a directory called img

Create a text file with the name SAPLBUS_LOCATOR.e3000.txt

if Q[Page=Address]

Pushbutton (toolbar) “Refresh Screen for QRcode” “/0”

image (19,130) “c:GuiXTimg&F[ADDR1_DATA-POST_CODE1].jpg” “-NoBuffer” “-Transparent” “-Plain” exe=“C:GuiXTstartstatic.bat &F[ADDR1_DATA-POST_CODE1] “”&F[T005T-LANDX]”” “”&F[BUT000-NAME_ORG1]”” “”&F[SZA1_D0100-TEL_NUMBER]””” start=“C:GuiXTstartstatic.bat &F[ADDR1_DATA-POST_CODE1] “”&F[T005T-LANDX]”” “”&F[BUT000-NAME_ORG1]”” “”&F[SZA1_D0100-TEL_NUMBER]”””


This file in its current form would be active for any BP transaction on any system. The toolbar pushbutton “/0” emulates a return command so best for display only transactions. It uses the post code and address details of the business partner and calls script startstatic.bat. The image would only be displayed on the Address tab which is set by the if Q[Page=Address] line. The exe= executes the dos bat file to load the image. The start= command runs if the image icon is clicked by the user to refresh the image with the toolbar pushbutton option.

The GuiXT image command is used to call the following dos script.

Script C:GuiXTstartstatic.bat


cd c:guixt

del /Q c:GuiXTimg\%1%.jpg”

set LAND=%2
set LAND=%LAND: =+%

set NAME=%3
set NAME=%NAME: =+%

start /min c:GuiXTstaticnew.bat %1 %LAND% %NAME% %4


The above replaces all spaces in the variables with a plus +. This was useful for some simple url encoding I was doing. The start command is used to run the next script c:GuiXTstaticnew.bat in a minimised window.

Script c:GuiXTstaticnew.bat

cd  guixt
set LAND=%2
set LAND=%LAND:”= %
set NAME=%3
set NAME=%NAME:”= %
echo gsave >
echo 50 50 translate >>
echo 2 2 scale >>
echo 0 0 moveto (MECARD:N:%NAME%;ADR:%1,%LAND%;TEL:%4;) () /qrcode / findresource exec >>
echo grestore >>
echo showpage >>
gswin32c -sDEVICE=epswrite -q -dBATCH -dNOPAUSE -sOutputFile=out.eps
convert -density 80 out.eps .img\%1.jpg


The earlier idea of using the ABAP bitmap class lead me to this point and similar scripts to create the barcode. E.g. ghostscript creates the EPS file and imagemagick creates the image. This time I use ghostscript’s epswrite device to get the encapsulated postscript file. Imagemagick is used to create a jpg file so guixt can use the file. The is renamed in the above example.

One final idea

Ok I was having some fun. So I carried on and put the ABAP code above with modifications for a BSP application (create/load via the same dataset commands and use the cache to redirect to the image). Then controlled the whole thing from Excel,  demo in this youtube video here. The video shows barcodes being created from the contents of the cells in Excel, and then I adjust the scale of the barcode in the backend BSP which is generating the barcodes for Excel.

Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sergio Ferrari
      Sergio Ferrari
      Great job Robert,
      I like everything about QR Codes but this blog impressed me by the amount of different technologies you were able to integrate.
        This is a fantastic material to learn how to extend the functionalities of an ABAP system.
      Author's profile photo Steffen Froehlich
      Steffen Froehlich
      Thanks so much for sharing your ideas to create barcodes in SAP directly. As you mentioned, google service for QR-codes is also a way but for in business it is mostly not adequate way to transfer data to any service in the web. So thanks for showing us how to do in this via SAP print controls!!
      Author's profile photo Simone Cattozzi
      Simone Cattozzi


      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.

      I've also created a printer control character in SPAD of type direct-hexadecimal and hex value (eg. 1D) as control sequence with no success.

      Did you have a solution?

      Author's profile photo Robert Russell
      Robert Russell

      Hi Simone,

      Going to refer you to an answer I gave some moments ago 🙂

      Barcodes in SAP with the Barcode Writer in Pure Postscript.



      Author's profile photo Simone Cattozzi
      Simone Cattozzi

      Thanks, I apologize for repetition.

      A strange behaviour i've noticed in the provided example is that it doesn't recognize the ASCII space (^32) used to fix long text.

      When I scan the generated barcode it gives me "This^32is^32and^example^32to^32fix^long^32text.."

      Author's profile photo Robert Russell
      Robert Russell

      Hi Simone,

      Apologies that is not a very good example, it should be ^032.

      Out of my interest where is the exact link you used to get that example, I can fix it.



      Author's profile photo Former Member
      Former Member

      Hi Robert

      It was good document . We tried printing the UPS maxicode by downloading the device type.

      When we printed using PDF creator it is working fine. Instead to printing the barcode we want to used smart form and trying to email the UPS label to customer by converting PDF inside the program, but barcode is not appearing correct.

      Any suggestion.


      Arun prasad

      Author's profile photo Robert Russell
      Robert Russell

      Hi Arun,

      Sounds like you are using the standard SAP PDF process which will not work for the barcode.

      The barcodes are generated with postscript using the Barcode Writer in Pure Postscript.

      So the conversion needs to be OTF to Postscript and then to PDF. The OTF to postscript conversion is done by the SAP and the barcode code introduced by the device type you downloaded. The postscript conversion to PDF is done by pdfcreator/cutepdf in this blog example. Standard SAP is OTF to PDF and misses out the postscript part.



      Author's profile photo Simone Cattozzi
      Simone Cattozzi


      there's a way to pass parameters to print control?

      In my case I've to resize a datamatrix. Using print controls ZSX01 and ZSY01 it works perfectly, but it only increase sizes by 0.1.

      I've created a new print control ZXS00 defined as

      ZSX00 = /bcscx bcscx %%X add def\n

      then call in smartform as


      but it doesn't works.

      Where I'm wrong?

      Author's profile photo Robert Russell
      Robert Russell


      I was not aware of a method to pass an attribute to the print control, I assumed that was just for the spool request only and would not be converted to a parameter to be passed to the postscript output. I would suggest changing the print control or create a new one with the required value.

      Also to note the BWIPP was updated to optimize the size for 2d barcodes and I updated the device types with that release. They can be downloaded via the blog post below. I do cover all the questions I have had previously about sizing and aligning barcodes with the BWIPP with SAP.

      Also the blog post does mention the SAP standard support now for datamatrix and this may offer you an alternative.

      Barcodes in SAP with the Barcode Writer in Pure Postscript Updated and Also Available in JavaScript



      Author's profile photo Peter Niedergrottenthaler
      Peter Niedergrottenthaler


      is there a problem with Windows 10?
      It seems it doesn't work for Windows 10 using ZBWIPPQR the local Printer (Default-Printer of the user in his Windows 10 - Operating System)

      Has anyone the same problem?