Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 


In this document we will work on printing a Data Matrix barcode (DMC) which is a 2D barcode not supported by SAP.

A 2D (two-dimensional) barcode is a graphical image that stores information both horizontally -- as one-dimensional bar codes do -- and vertically. As a result of that construction, 2D codes can store up to 7,089 characters and possibly more.

Below are some of the types of 2D barcodes


Print Data Matrix barcode (2D barcode) on zebra printers using Smartform.

* Similar approach can be followed for printing other 2D barcodes and the generic barcodes with specific height and width.


SAP by default only supports PDF417 as 2D barcode and does not support Data Matrix and other 2D barcodes


Printing other 2D barcodes which are not supported by SAP is possible by following the below steps

  • Printer should support the required barcode: We can check this online based on the printer model and make. Most probably you will find this information on the manufacturer’s website.


  • Choose an appropriate device type for the printer: Selection of device type is based on the printer you are using.  In this example we are using ZEBRA printer so the device type selction will be based on Zebra printer.This topic is dealt in more detail in the other document named ‘Working with Zebra Printers using Smartforms in SAP’ please refer to the same for additional documentation on selecting the device type for Zebra printers.  For Zebra printers we have the following device types LZEB* (* => 2/3/4) series or YZB# (# => 200/300/400) series based on the DPI resolution of the printer.

        For the demonstration as an example we will use LZEB2 device type from here on in this document.

  • Create a system barcode of type UNDEF in SAP: For creating a system barcode go to transaction SE73.

          This will take you to the SAP script Font Maintenance: Initial screen


          Select System barcodes check box and click the change button. This will display a list of all the Barcodes on the SAP system.

          Click the Create button (Paper icon) at the top of the screen


          The Choose Bar Code Technology select box will now be displayed.


          The barcode we are adding is a new barcode symbology which is not supported by SAP, and the new barcode techcnology allows only specif types

          of barcodes symbologies to be created therefore we are going to use Old technology to create our new barcode as an undefined symbology.

          So Click on Old.

          The Create/Change System Bar Code settings screen will be displayed. For barcode type enter ‘UNDEF’ ( barcode not defined) as the data matrix

          barcode type is not defined in SAP. Also specify the height and width of the barcode.


          Then save the changes by clicking on the Ok button. Now the system barcode ZDMC is created.

  • Create a printer barcode for the newly created system barcode with appropriate print control:

       For creating a system barcode go to transaction SE73. This will take you to the SAP script Font Maintenance: Initial screen


          Select printer barcodes check box and click the change button. This will display a list of device Types available in SAP system.



          In this case I am using device type LZEB2 so I will create a printer barcode for this device type. It is advisable to copy this device type to a new

             device type and then make changes to the new Z device type and use it for printing but for demonstration I am using the same device type.

             Double click on the device type to list the barcodes supported by this device type.


               Notice the Prefix and Suffix value ranges used for the barcodes. Here in this case the highest number used for prefix is SBP20 and is different

               for each barcode however the suffix is same for all the barcodes. These prefix and suffix are the print controls of the barcodes supported by

               the printer.

               Now select the create button on the top of the screen to add a new printer barcode. This will take you to the barcode selection screen.


               Select the system barcode you created earlier and enter the other values as shown in the screenshot above. For prefix we are entering SBP21

               because all the numbers from 1 -20 (SBP01 to SBP20) are already used so we are using the next available number SBP21 and the suffix number

               stays the same. We can use any number from 21-99 for prefix.

               Now the barcode is created for the device type (see screen shot  below)


               But the print control SBP21 is empty. For the barcode to work properly we have to add commands in the print control in ZPL-II language

               (printer language).

               Please find the online document named 'ZPL2 command book' . The site link for the same is


               It is adviced to have the document before we proceed further. This command book has all the commands for printing different types of

               barcodes on a printer ( only if the printer supports it )using the ZPL2 command Lanugage.

               Here we are adding the Data matrix barcode, and the printer command format for printing the data matrix is: ^BXo,h,s,c,r,f,g

               Command Parameters:

               O – Orientation

               H – Height

               S – Quality level

               C – Columns to encode

               R – Rows to encode

               F – Format ID

               G – Escape sequence control character

               Refer to the attached command book for accepted and default values for the above parameters and how to use the command.

           Below is an example of the post script language commands used for printing a DMC barcode on the printer.


            The printer command mainly needs to have 3 types of information

  1.      Command to indicate the type of barcode to be printed ( Marked by ^BX in the command above)
  2.        Command to indicator the start of data ( Marked by ^FD)
  3.        Command to indicator the end of data (Marked by ^FS)

           When working with Smartforms the prefix print control in the printer barcodes screen should have both the commands for the type of barcode

               and the command for the start of data whereas the suffix will only have the command to mark the end of data.


          Taking the above points into consideration we will have ^BXN,2,200,20,20,6,~,1^FD command in prefix and ^FS in suffix.  As the suffix is

             used to mark the end of data it is same for all the barcodes and hence maintained as default.

             Meanings of the command Parameters for prefix ^BXN,2,200,20,20,6,~,1^FD are:

              ^BX        The Data Matrix command

              N            The orientation is normal

              2              Dimensional height in dots of the individual symbol elements

              200         Quality ECC level (ECC 200)

              20           Columns to encode

              20           Rows to encode

              6              Data to be used (6 means full 256 ISO 8-bit data is used)

              ~             Escape sequence for control characters

              1              Square aspect ratio, if you required rectangle this will be 2

              ^FD        This is to mark the start of the field data to be encoded in the barcode

            Add the following command in the print control prefix:  ^BXN,2,200,20,20,6,~,1^FD

            Go to SE73 -> Select printer barcodes -> Change ->Select device type (in this case LZEB2) -> double click to display the list of barcodes supported

            by the device type.


              Select the new print control SBP21 (barcode prefix) and click on Maintain Print control button. Following popup will be displayed.


              Enter the command in the control characters sequence field and make sure the Hexadecimal switch is turned OFF. Then press enter.

              The print control is saved.

               The barcode suffix SBS00, which is default for all the barcodes holds the end of data command (see below)


               The configuration of the printer barcode is complete. Now we can use this barcode to print the Data Matrix barcode (2D barcode) from SAP.


               There can be various combinations to the prefix command. If the barcode is not printed then you have to try changing the values for the height,

               rows and columns variables in the command. The prefix combination that worked for me is: ^BXN,3,200,,,6,~,1^FD


  • Use the barcode in the Smartform using a style:

       Please refer to online documentation for adding a barcode to a style in Smartform.

       After you have added the barcodes to one of the character formats of the style which is being used in the Smartform, we just have to use the

         newly created barcode type to display the 2D content as Data Matrix Barcode.

       See below screenshot for an example.


       As the example depicts, use a separate text node for the 2D barcode , keep all the 2D content in a variable or write it all down in the text node.

         Select the whole text and select the character format for the DMC barcode.


          At this point if you try to print the barcode it is expected to see the barcode on the printout, but you might not see the barcode printed on the

         printer, the reason as i understood is that based on the ZPL2 command the data should be marked with the start of data command and End of data

         command along with the type of barcode we are trying to print. so the commands should be inserted before and after the text node that holds

          the 2D data content. This will give the printer a command saying that the data between this is to be printed as the barcode symbology specified in

          the command, in our case Data Matrix.

          Note : Preview will not show the barcode because literally this barcode is not in SAP system and will only be printed on the printer. So anything

          concerning the barcode has to be tested on the actual printer not the preview because both the preview and the actual print will be a lot


  • Create a command node before and after the text node that holds the 2D barcode content:

       See below screen shots for an example on how to create a command node.


        Then enter the prefix print control we created in the printer control input field (see below).


       Create one more command node under the 2d content text node and enter the enter the suffix print control in the printer control input

         field (see below)


        Now test the print on the Zebra printer, the barcode should be printed on the zebra printer as shown in the screen shot below. Now take the

        printout and scan the barcode with any of the android apps or any barcode reader that support DMC barcode. Please note that the printout taken

        on your local printer from a scanned document wont be readable, so it is advised to test the barcode scanning from the actual printout or from the

        Scanned document on your computer.


        After scanning, the barcode should display all the 2D content .

Alignment issues with the 2D barcode:

          After the barcode is printed you might notice alignment issues on the label. To solve the alignment issues the following approach can be used.

          Go to Smartstyle you have used in the Smartform, select the respective paragraph format node you have assigned for the barcode. Here try

          changing the alignment and spacing values (see screen shot below) and try giving it a few trials. You will be able to align barcodes after a few




               Please make sure you have enough space for the barcode when designing the layout. I mean if you are planning to have a barcode of size

               1 CM * 1 CM then make use you have a separate window on the layout with space more than the barcode size.

                                                 ----------------  THE END  -----------------

Please note that the document is based on my personal experience and the online documentation i came across. So if there is any scope of improvements in this document you are most welcome to add your comments.



Labels in this area