Skip to Content

Barcodes in SAP with the Barcode Writer in Pure Postscript update


A while back I lost access to my user account for SCN; this was due to a change of job which meant losing access to the ‘S’ user account I had registered with. Also one aspect of the new platform is that you can’t transfer/merge user accounts at the moment (and it will be “months” before this is possible). One of the first actions recommended for the new platform was to move your blogs to spaces, which is not possible for me. During the move to the new platform there was some damage to my blogs with a loss of images/formats and they are not in a state that I like and I can’t update them.

So when the Barcode Writer in Pure Postscript (BWIPP) was updated a short time ago to include Kanji encoding, this was an obvious step for myself to update the Japanese SAP device type I had with the latest BWIPP version and post an update blog here on the new SCN. As my journey into the world of QRcodes/Barcodes began in Japan and I already had a version for a long time based on the Japanese SAP postscript device type, the actual QRcode Kanji encoding appealed to me for an update even though I have left Japan a long time ago. I also cover other aspects of using the BWIPP in this blog, including an ASCII85 (ASCII85 wikipedia entry) version and another section covering SAP server side setup.

When and if I get access to my original blogs I will remove this first section of the blog.

Most of the technical details I have used can still be found in my original blogs here.



BWIPP in SAP update

1) Updated QRcode device type

In my original development of the SAP barcode device types based on the BWIPP it was suggested to use the BWIPP ASCII85 encoded versions. The ASCII85 BWIPP versions can be found here.

I do like the ASCII85 encodingmethod as it reduces the amount of code and therefore the size of the SAP device type. The number of “action pages” in the device type is reduced from 5 to 2 for the QRcode version.

The new device type also contains two extra print controls to cover some extra formatting options for smartforms. The first SDN blog covers printing to text files first to determine the correct print controls, the comments section to that blog also cover these new print controls.

Download link to the new QR code device type is here

The zip file contains file ZBWPQR2.PRI which is the ZBWPQR2 device type.

Follow the original QRcode blog but use the ZBWPQR2 device type

The main benefits are

*Reducing the number of SAP Action pages required for the device type.

*Reducing the size of the device type

*The extra print controls covering Smart Form formatting.

New device type print controls

In most “normal” formatting of smartforms then new print controls are not required, however if no barcode is displayed then the format of the postscript generated from the smarform needs to be checked as described below.

There is a section in my first SDN blog about “Identify the Text for the Barcode” so if I quote the relevant section below.

“Standard formatted text can appear with the “s” command however sometimes especially if small text formatting is used other postscript procedures such as “w1” and “w2” appear. So any new form or output that requires a barcode should be output to a flat file. This is to check the file for the postscript formatting and commands used by SAP. This can be useful to note where to insert postscript commands via print controls (also for any trouble shooting). A tip for smartforms and sapscript is to search for lines with “<~” and “~>” as this signals ASCII85 encoded text. “

As the smartform will be converted to postscript then the way the smartforms text format is converted is vital to allow the barcode to be printed.

a) So lets start by creating a Windows frontend printer that prints purely text.
This will be used to create a text file of the SAP generated postscript.

Follow this note but use the QRcode/barcode device type
Note 576973 – Creating a file printer on a Windows PC

b) send the smartform to the new frontend printer.
You will be prompted for a file location so enter c:\ for example (the full path must be entered).

For example in the following screen shot I have used various formats in a smartform and I sent the output to the file printer on my desktop.


c) open and search for “/s {bct exch ctxt” which is the start of print control ZBW01. (Note I have added the “= testing …. ” text myself for this blog to match the above smartform screenshot.)


In the above smartform output shown in the red box, there is some formatting to do with the width/size of the text so the normal postscript s command is not used and therefore the qrcode would not be generated correctly.

*NOTE, in the above example the formats in the postscript use w1 and w2 as an example, the exact formatting may be different in your smartform.

The postscript commands w1 and w2 are used instead of the S command in the smartform. Therefore to keep the formatting in the smartform we can use the two new print controls.

The TWO new print CONTROLS are.
ZBW90 = /w1 {bct} def /w2 {ctxt /bct exch def} def \n
ZBW91 = /w1 {SW 0 8#040} def /w2 {widthshow} def \n

d) Change the smartform to include the new print controls

..TEXT – empty / or blank lines to make room for the barcode

Basically the ZBW90 changes the W1 and W2 commands to allow the concatenation of the text.
ZBW02 is the same command to generate the QR code.
ZBW91 resets the W1 and W2 to SAP standard postscript.

e) Print the smartform to the original QRcode(barcode) printer with the new print controls and the QRcode should now appear in the output.

The following extract is from the Barcode Writer in Pure Postscript page detailing all the supported barcodes. Using the same method any of these could be incorporated into an SAP device type. If you see any you would want to use in SAP then you could follow the original SDN blog to create your own.

The BWIPP supports an impressive list of barcodes, as listed here from the BWIPP site.

The project supports all major barcode symbologies including:

EAN-13(EAN, UCC-13, JAN, JAN-13, EAN-13+2, EAN-13+5, EAN-99), EAN-8(UCC-8, JAN-8, EAN-8+2, EAN-8+5, EAN-Velocity), UPC-A(UPC, UCC-12, UPC-A+2, UPC-A+5), UPC-E(UPC-E0, UPC-E1, UPC-E+2, UPC-E+5), ISBN(ISBN-13, ISBN-10, Bookland EAN-13), ISMN,ISSN, EAN-5 & EAN-2(EAN/UPC add-ons), GS1 DataBar Omnidirectional(RSS-14), GS1 DataBar Stacked(RSS-14 Stacked), GS1 DataBar Stacked Omnidirectional(RSS-14 Stacked Omnidirectional), GS1 DataBar Truncated(RSS-14 Stacked), GS1 DataBar Limited(RSS Limited),GS1 DataBar Expanded(RSS Expanded), GS1 DataBar Expanded Stacked(RSS Expanded Stacked), GS1-128(UCC/EAN-128, EAN-128, UCC-128), SSCC-18(EAN-18, NVE), EAN-14(UCC-14), GS1 Composite(EAN/UPC, GS1 DataBar and GS1-128), ITF-14(UPC SCS), QR Code(Quick Response Code, Micro QR Code), Aztec Code (Compact Aztec Code, Aztec Runes), Data Matrix(Data Matrix ECC 200), GS1 DataMatrix, PDF417 (Truncated PDF417), MicroPDF417, MaxiCode (UPS Code, Code 6), Codablock F, Code 16K(USS-16K), Code 49(USS-49), Code One (Code 1, Code 1S), USPS POSTNET, USPS PLANET, USPS Intelligent Mail(USPS OneCode), USPS FIM, Royal Mail(RM4SCC, CBC), Royal TNT Post(KIX), Japan Post, Australia Post, Deutsche Post Identcode(DHL Identcode), Deutsche Post Leitcode(DHL Leitcode), Pharmacode (Pharmaceutical Binary Code), Two-track Pharmacode (Two-track Pharmaceutical Binary Code), Code 32(Italian Pharmacode), Pharmazentralnummer(PZN, PZN-8, PZN-7), Code 39(Code 3 of 9, LOGMARS, Alpha39, USD-3, USD-2, USS-39), Code 39 Extended (Code 39 Full ASCII), Code 93(USD-7, USS-93), Code 93 Extended (Code 93 Full ASCII), Code 128(Code 128A, Code 128B, Code 128C, USD-6, USS-128), Code 2 of 5(Code 25, Industrial 2 of 5, IATA 2 of 5, Data Logic 2 of 5, Matrix 2 of 5, COOP 2 of 5), Interleaved 2 of 5(ITF, Code 2 of 5 Interleaved, USD-1, USS-Interleaved 2 of 5), Code 11(USD-8), Codabar(Rationalized Codabar, Ames Code, NW-7, USD-4, USS-Codabar, Monarch, Code 2 of 7), Plessey(Anker Code), MSI Plessey(MSI, MSI Modified Plessey), Telepen(Telepen Alpha, Telepen Full ASCII, Telepen Numeric), Channel Code, PosiCode (PosiCode A, PosiCode B), BC412 (BC412 SEMI, BC412 IBM), GS1 Composite Components CC-A, CC-B, CC-C(EAN-13 Composite, EAN-8 Composite, UPC-A Composite, UPC-E Composite, GS1 DataBar Omnidirectional Composite, GS1 DataBar Stacked Composite, GS1 DataBar Stacked Omni Composite, GS1 DataBar Truncated Composite, GS1 DataBar Limited Composite, GS1 DataBar Expanded Composite, GS1 DataBar Expanded Stacked Composite, GS1-128 Composite), HIBC barcodes(HIBC Code 39, HIBC Code 128, HIBC Data Matrix, HIBC PDF417, HIBC MicroPDF417, HIBC QR Code, HIBC Codablock F)

2) Using JSPOST Device type

for Japanese language support

As I did come across QR codes in Japan I thought I would blog on how I used the Japanese postscript device type driver with QR codes.

So the intention of using this version of the BWIPP device type is to show the way to use Japanese in the output including a QRcode.

When I used Japanaese with the original method using cutepdf the output would look like the following screenshot.


So to get Japanese to print properly then the SAP Postscript font file from this note was required.

Note 83502 – Printing Support for Native Languages

I downloaded the Japanese font file “Japanese  |  JPSPOST    | Dfnsjis  (note 83502)”

Follow the note to set the required parameter and upload the font to the SAP server.

*Check the limitations of using these device types in the note and that the font file will be sent to the frontend with each print.

The end result when using the QRcode enabled device type.


Smartform Example.


Steps involved.

1) Download the font file and set the parameter from the SAP note. Restart the SAP server

2) Download here  the zip file which contains the following files.

ZQR_PRINT_JP.txt     = ABAP code to produce a QRcode using the ZJPSPTQR device type.

ZBWIPP_JAPAN        = Output Device linking the device type to cutepdf desktop printer

ZJPSPTQR.PRI           = QRcode enabled SPOST Device Type

3) Use the original post in relation to the QRcode but use the above files to enable Japanese.

4) Run report ZQR_PRINT_JP (and make sure that print immediately is active).

select Japan QRcode printer.jpg

with QRcode Kanji Encoding

The BWIPP can now encode Kanji into the actual QRcode, so a combined ASCII85 and BWIPP updated version can be found in the zip file for the Japanese device type download above. The link again here. In the subdirectory “japan kanji” device type ZJPSPTQK, can be uploaded and I have updated the ABAP code (ZQR_PRINT2KAN) with kanji for a demonstration as shown below.

The ABAP code now as Kanji in the line that generates the QRcode, as per the following screenshot.

ABAP code for Kanji output.PNG

Results in the following PDF with Kanji encoded in the QRcode.

pdf OUTPUT Kanji QRcode.PNG

3) Server side BWIPP

This version merges the BWIPP on the SAP server side. Therefore there is no need to configure PDF software or use scripts to introduce the BWIPP to generate barcodes. Server side integration allows the possibility to print direct to a postscript printer.

By using standard SAP configuration the BWIPP can be merged into the SAP output stream on the server side. Therefore reducing any configuration on the client side by placing the configuration  on any SAP application server used for printing.

Also as the solution is purely postscript based ANY postscript 2 compatible printer can be used for a barcode solution. While I no longer have access to any HP printers, I did cover this at a previous location and posted elsewhere in regards to printing postscript on HP printers.

Steps involved.

1) Download this zip file which contains.

ZBWIPP_M.PRI This is the SAP device type which contains the BWIPP configuration

Dbwipp This file is the Barcode Writer in Pure Postscript

ZBWIPP_PRINT.txt This is the ABAP code which produces 26 barcodes on one page

The test page looks like this.


2) SET the profile parameter ‘rspo/devinit/datafile’ to

rspo/devinit/datafile =

Note: Please pay attention to the number of “+” after the letter “D”.
*Its important the the parameter is set exactly as above

3) Copy the Dbwipp file to the following directory on the SAP server

*the parameter and Dbwipp file need to be set/copied to all application servers used for printing.

4) RESTART the application server

5)Follow this original post in regards to a standalone QRcode solution but CHANGE the following steps.

Import device type = ZBWIPP_M.PRI
Use ABAP code = ZBWIPP_PRINT.txt

*the output device qrcodes and cutepdf setup can be used as stated in the blog post. (They can be renamed as required)

Run the report ZBWIPP_PRINT for the demo ABAP code.

Here is a video covering barcodes in SAP Smart Forms with the BWIPP. The video was in the original blog post but got lost in the move to the new SCN.

Follow me onGoogle+

You must be Logged on to comment or reply to a post.
  • Thanks. You really save my life here. 🙂 By the way, 2 questions. Does the QR code size change because of the amount of data passed to the QR code? Can fix a size regardless of the how much is the content?

    • Hi Janet, thanks for the comment, nice to save a life 🙂 . As for your questions it depends exactly what you need and may create other issues for placing the QR code on the page.

      Start with some references to QR codes.

      i)             Wikipedia QRcode entry link to “Storage section”

      The information here indicates that it is possible to have a QRcode at a defined size

      ii)            BWIPP wiki entry for QRcodes

      The BWIPP does actually support the version options of 1-40.

      So as a test I added the following printer control to the QRcode device type via transaction SPAD.

      ZOP03  /bcopt (version=4) def\n

      Changing the demo ABAP program to test the option



      write:  ‘Version 4 QRCODE: 50 characters’.

      *leave gap for qr code

      skip 6.



      WRITE: ‘abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx’ NO-GAP.


      …..*****THE ZOP03 is used to define the version of the QRcode.


      So the actual QR code will be at a defined size.

      I did this again for the default QRcode (No ZOP03 print control) and the size which is determined automatically. A test 10 character QRcode was smaller by default.


      As stated in my very first blog the number of characters encoded in the barcode determines the position on the page. This would be shown above with the 50 character barcodes appearing on the right. This can be controlled with further print controls as stated in the original blog. The issue being that to get a consistent position you need to know the number of characters passed to the QRcode. Hope this helps and any further questions let me know, happy to help if I can. I will when I get some time take a look into some aspects of the positioning of the barcode as a result of your questions (as I have some ideas but no time to test fully at the moment)



      • Thanks again. Managed to solve one of my problems. Like you have mentioned, the position of the QR code is shifting up and down due to the different number of charcters being passed in. Trying to adjust it to make sure it is still printed within the box. But guess the functional will ask me if possible to fix the position. Haha.

        • Hi Janet,

          Not sure how you are using the QRcode device type, however I have done some quick tests with ABAP and the CHAR character type. This way I was able to achieve a consistent position and size of the QRcode on the page with variable length of data.  (other print controls can move the QRcode from its relative position).

          E.g. the ABAP code.

          DATA: tt(50) type c.

          tt = ‘‘.

          write:  ‘Version 4 QRCODE:‘.
          *leave gap for qr code
          skip 6.
          WRITE: tt NO-GAP.

          skip 2.

          write:  ‘Version 4 QRCODE: 50 characters’.
          *leave gap for qr code
          skip 6.
          tt = ‘abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx’.
          WRITE: tt NO-GAP.

          produced a document as below. (not sure how this image will look in this comment section but I have tried to scale it to fit, it didnt work 🙁 – if you click on the image it will pop up. )




          • Hi,

            I am using it in a smartform. Trying to create 1 page with 6 labels. Then created 6 window for 6 QR code. Printer control BW01, ZOP03, ZSX03, ZSY03, <BARCODE TXT>, ZBW02.

            BW01 – /s {bct exch ctxt /bct exch def} def \n

            ZOP03 – /bcopt (version=4) def\n

            ZSX03 – /bcscx bcscx 0.2 add def\n

            ZSY03 – /bcscy bcscy 0.2 add def\n

            ZBW02 – \nbwippst\nbct sqrd\nbwippen\n

            This is how I creating the QR code.

          • Hi Janet

            As per the ABAP example the C character data type is the way to go with variable length data in smartforms.

            I created a test smartform and successfully managed to create a consistent QRcode in size and position as follows. ( I have added images again, so click on them to get a better view.)

            1) created one window with a border for the smartform.

            SMARTfoRms QR code  in a box.PNG

            I used some ZRT50 to move the barcode right ZDN10 – move it down & ZLT10 to move it back 10 postscript points. Just to center the barcode in the box, I could have created a ZRT40 print control instead of using the ZRT50 & ZLT10 printer controls but the above is just for testing.

            2) After I successfully sent a test print and was happy I had a barcode in the center of the box I did a straight copy of the window. As shown in the image below.

            straight copy of code.PNG

            3) send some variable text in length (data type C and length 50)  to the smartform and the output was centered in both boxes as shown below. “r” and “robert russell” text sent to the smartform and the QRcodes are in position and same size.

            Smartform output.PNG



          • Hi Janet,

            Happy to help, but maybe email would be better now? if you agree, then I would be interested screenshots in how you defined the CHAR character data type to pass to the smartform.

            I have an email address defined on my profile, u should be able to pick it following the link on this blog. Direct email may be better so we can exchange some extra screenshots/config.

            let me know.



  • Hi Robert,

    We are using BWIPP in combination with smartforms as described in your blogs. We are able to create any barcode we wish and print it directly in pdf, very happy with that. last step for us is to change the datamatrix barcode into GS1 datamatrix which we didn’t succeed in sofar.

    If I understand correcly we have to start with a FNC1 so I tried the following:


    text = ^2320103400949140855171412001011L14IKJ

    ZOP01 (parse)

    ZBW03 (=datamatrix)


    Can you advice us on this?

    Tom Wessels

    • Hi Tom,

      Good to hear you are using the info in my blogs.

      As for the GS1 Datamatrix I would suggest the following.

      Take a trip over to the BWIPP wiki and note the options for GS1DataMatrix.

      I checked the Dbwipp file that is part of the setup for the device type and it does contain Gs1DataMatrix

      So as you are using the server side setup I would suggest you add the following print control (via SPAD).

      ZBW34  zbst\n/zzbc (Gs1DataMatrix) def\nbct sqrd\nzben\n

      I can’t advise on the text for the barcode (FNC1 or otherwise) so only make the suggestion that you

      visit the BWIPP online generator and experiment/test the text options at this site.

      When you have completed any tests, then use those options with the SAP BWIPP.


      ZBW90 (as you state you use these print control combination)



      ZBW91 (as you state you use these print control combination)

      Hope the above helps and let me know if you need any more info.



      • Hi Robert,
        thanks for your quick response!
        We created ZBW34 with zbst\n/zzbc (gs1datamatrix) def\nbct sqrd\nzben\n
        than I had a look into the Dbwipp file (in wordpad) in the GS1 Data Matrix section.
        An example string is available right at the begin of the part:

        % –BEGIN ENCODER gs1datamatrix–
        % –REQUIRES datamatrix–
        % –DESC: GS1 Data Matrix
        % –EXAM: (01)03453120000011(17)120508(10)ABCD1234(410)9501101020917

        which doesn’t contain anything like FNC1.
        The FNC1 part is added automatically at the beginning of the string (a little bit further in the script)
        The result created from our smartform is now exactly the same as the result from terryburton barcode generator.
        It seams that our problem os solved!
        kind regards,

  • Hi Robert,

    I have created smartform to create 2D Barcode, Ihave uploaded device type, & assigned mt device type to SAP printer when i execute the output of smartform Brcode is getting generated but while scanning it shows no data(Barcode is cop pasted below). my smartform looks like as below

    In smartform

    gv_pdf is variable which contains of type 120 character & i am passing it as

    gv_pdf = ‘MATERIAL CODE 1234567890’.

    and i am passing follwing Commands(printer Controllers)

    COMMAND1 – ZBW01

    COMMAND5 – ZLT01

    COMMAND5 – ZRT50

    COMMAND2 – ZBW02

    after executing smartform & generating output in pdf i am getting following output.

    when i scan this barcode with my mobile, it is getting scanned but not showing any values.also in your video text for bar code was not printing & in my case it is printing as shown above on left side which we don’t want. Also if change value of the variable then also it shows me barcode with same pattern(No values). I am same pattern for any variable i am passing.

    But when i run the same from report then it shows me correctly on scanner.

    also i want multiple line to be printed on barcode

    for eaxmple

    Mat. Code :-  1234567899

    batch : 676767

    plant : 1810

    Please help me as i have already spent lot of time on it and it is quite urgent for me.

    Thanks in Advance.

    Thanks & Regards,

    Paresh G

    • Hi Paresh,

      I am curious to know if you followed the troubleshooting page I sent you earlier?

      The first part of your question.

      The section in this blog that you really need to follow closely is…

      New device type print controls

      This section mentions the possibility of different formatting changing the postscript commands used by the smartfrom. I cant tell from your screenshot the formatting used in the postscript. This is where printing to a text file helps.

      At the end of this section after the analysis of the text file in the c) sreenshot is

      the following combination of print controls.

      ..TEXT – empty / or blank lines to make room for the barcode

      It appears from your description that the first print control ZBW01 is not working. This is where ZBW90 and ZBW91 have been introduced for different postscript commands used for the formatting.

      You could try the new print controls or you would have to print to a text file.

      You could check my profile and send me an email of any text file if you wish.

      The second part of your question

      To achive carriage return and line feed you could use the parse print control to pass the ascii values for these, as shown below.


      *print control ZOP01 sets the parse option for the barcode *writer in pure postscript

      *NO-GAP required to remove the gap ^010^013 is the ascii *code for line feed & carriage return
      WRITE: ‘1st line’, simpletest1, ‘^010^013’ NO-GAP.

      WRITE: ‘2nd line’, simpletest2, ‘^010^013’ NO-GAP.




      • Thanks Robert for your reply,

        i have one more doubt i am printing more then on lines in barcode as suggested by you above but when i am printing only 1 or 2 line & more then that my barcode size changes & it goes out of the window.

        Output for the both is as shown below

        Case 1 :

        Input :-


        Case 2

        Input :-


        Print Controls for parameter is as shown in fig below.

        Kindly suggest me how to print barcode of same size with different number of lines

          • Dear Robert,

            Thanks for reply,

            I have read the above comment & some how i managed it in my window but now my problem is that it is not at fixed position i had to resize the barcode using ZSX01 & ZSY01.

            For above given case if i add or subtract one or more line barcode size as well as position is changing.

            For Example

            If i print 2 lines then it is printing as below

            and when i print only 1 line then it is printing as below.

            I am not getting what to do in this case.Can i print same size & at same position with different No . of lines

            i am using following print controls

            When i am giving DN10 & decrease the size barcode position changes accordingly

            Please guide me.

          • Hi Paresh,

            As noted previously variable text passed to the barcode is causing issues. If the window is wide enough to contain all the text then variable data will still work. The issue is the word wrap, when the text does not fit on one line in the window. So either make the window wide enough so that the text does not word wrap. Or you could pad the text with spaces (or another character). Normally space is a bit of a pain and will be truncated. So using the BWIPP parse option again you could pass ^032 which is the ASCII code for a space.

            e.g. Purely an example below and would rely on testing the window size and knowing the MAXIMUM characters to be passed. If you exceed the maximum characters and limit the barcode size, more than likely this will result in NO barcode.

            QR3 = ‘TESTING |’.
            translate QR3 using ‘ ^0’.
            translate QR4 using ‘ ^’.
            replace all occurrences of ‘^’ in QR4 with ‘^032’.
            replace all occurrences of ‘^’ in QR3 with ‘^032’.
              while strlen( QR3 ) < 60.
            concatenate QR3 ‘^032’ into QR3.
              concatenate QR3 ‘^032’  into QR3.
              while strlen( QR4 ) < 60.
            concatenate QR4 ‘^032’  into QR4.
              concatenate QR4 ‘^032’ into QR4.

            Padding the text would require TESTING and sending pure text BEFORE creating ANY barcode (i.e. no print controls) to ensure the window is sized correctly and will always wrap the text to the same line. This would ensure that the barcode is then generated at the same position each time when the print controls are introduced.



  • Hi Robert,

    you can tell me how to combine QR code with the device Type for Hebrew languish for post script (HESPOST) ?

    I am want to do it like you do with the Japanese Device Type.



    • Hi Roy,

      Can you use HESPOST successfully with SAP at the moment.

      It may be possible to add the barcode writer in pure postscript to it but I have not checked out the HESPOST device type previously.

      If you can use HESPOST and the output is as expected then let me know, can’t promise anything and may not work in the end. However if you can confirm that the HESPOST works as expected with the correct output, I would be happy to take a look at the qrcode side.  (Also if you print to a PDF then you most likely will get a bitmap image and not pure text as that is the font in use).



  • Very helpful blog Robert, thanks a lot.

    However I got problems with parse option (‘ZOP01’) in Smartforms. If I activate it, my QR code dissappears.

    Could you help me?

    Thanks again,