10 Replies Latest reply: Sep 16, 2013 11:38 AM by lawrence smith RSS

barcode

T SRINIVAS
Currently Being Moderated

hi all,

 

how to generate barcode  in abap report ?

  • Re: barcode
    Currently Being Moderated
  • Re: barcode
    pavan pachimatla
    Currently Being Moderated

    A barcode solution consists of the following:

    - a barcode printer

    - a barcode reader

    - a mobile data collection application/program

     

    A barcode label is a special symbology to represent human readable information such as a material number or batch number

    in machine readable format.

     

    There are different symbologies for different applications and different industries. Luckily, you need not worry to much about that as the logistics supply chain has mostly standardized on 3 of 9 and 128 barcode symbologies - which all barcode readers support and which SAP support natively in it's printing protocols.

     

    You can print barcodes from SAP by modifying an existing output form.

     

    Behind every output form is a print program that collects all the data and then pass it to the form. The form contains the layout as well as the font, line and paragraph formats. These forms are designed using SAPScript (a very easy but frustratingly simplistic form format language) or SmartForms that is more of a graphical form design tool.

     

    Barcodes are nothing more than a font definition and is part of the style sheet associated with a particular SAPScript form. The most important aspect is to place a parameter in the line of the form that points to the data element that you want to represent as barcode on the form, i.e. material number. Next you need to set the font for that parameter value to one of the supported barcode symbologies.

     

    The next part of the equation can be a bit tricky as you will need to get a printer to print that barcode font. Regular laser printers does not normally print barcode fonts, only specialized industrial printers that is specifically designed to support that protocol and that uses specialized label media and heat transfer (resin) ribbon to create the sharp image required for barcodes.

     

    Not to fear though, there are two ways to get around this:

    - You can have your IT department do some research -

    most laser printers can accept a font cartridge/dimm chip (similar to computer memory), called a BarDIMM that will allow a laser printer to support the printing of barcodes.

    - Secondly, you can buy software that you can upload in your SAP print Server that will convert the barcode symbology as an image that will print on a regular laser printer. I found that this option results in less sharper barcodes. This option is really if you need to convert a large quantity of printers (>10) to support barcodes.

    - Thirdly, you can buy a third party software like Barcode.dll and install on your frontend PC connected to the laser printer.

     

    Now you have a barcode printed - what next?

    Well there are two options, depending on your business requirements:

    - You can use an existing SAP transaction on a regular workstation and get a barcode wedge reader to hook up between the keyboard and the PC. These wedge readers comes in a wand or scanner format. There are even wireless wedge scanners available that allows you to roam a few yards from the workstation to scan a label. This approach is mostly used where you want to prevent human errors in typing in long material, batch or serial numbers in receiving or issuing of material. The problem is that it's just replacing the keyboard input and you are basically locked down in one location and have to bring all the material to that location to process.

    - Another solution is to use SAPConsole transactions

    or write your own ABAP Dialog programs that will fit onto a barcode enabled wireless handheld terminal and that will follow the business logic as executed on the shop floor.

     

    These programs are highly complex exercises in industrial engineering and ergonomics because of the limited screen sizes and limited ability to accept keyboard input. The user is instructed step-by-step and only scan and push F-keys to interact with the SAP system. Scan, scan, beep, beep, enter - highly automated.

     

    Check the below...

     

    Creating Bar code:

    -->From trans code - SPAD -> Full Administration -> Click on Device Type -> Double click the device for which you wish to create the print control -> Click on Print Control tab ->Click on change mode -> Click the plus sign to add a row or prefix say SBP99 (Prefix must start with SBP) -> save you changes , it will ask for request -> create request and save

     

    --> when you go to SE73 if you enter SBP00 for you device it will add the newly created Prefix

     

     

    -->Create a character format C1.Assign a barcode to the character format.Check the check box for the barcode.

     

    -->The place where you are using the field value use like this

     

    <C1> &itab-field& </C1>.

     

    You will get the field value in the form of barcode.

    Which barcode printer are you using ? Can you download this file and see.

    http://www.servopack.de/Files/HB/ZPLcommands.pdf.

    It will give an idea about barcode commands.

     

     

    SAP Barcodes

    -->Barcode solution consists of the following:

    barcode printer

    barcode reader

    mobile data collection application/program

     

    A barcode label is a special symbology to represent human readable information such as a material number or batch number

    in machine readable format.

    There are different symbologies for different applications and different industries. Luckily, you need not worry to much about that as the logistics supply chain has mostly standardized on 3 of 9 and 128 barcode symbologies - which all barcode readers support and which SAP support natively in it's printing protocols.

    You can print barcodes from SAP by modifying an existing output form.

    Behind every output form is a print program that collects all the data and then pass it to the form. The form contains the layout as well as the font, line and paragraph formats. These forms are designed using SAPScript (a very easy but frustratingly simplistic form format language) or SmartForms that is more of a graphical form design tool.

     

    Barcodes are nothing more than a font definition and is part of the style sheet associated with a particular SAPScript form. The most important aspect is to place a parameter in the line of the form that points to the data element that you want to represent as barcode on the form, i.e. material number. Next you need to set the font for that parameter value to one of the supported barcode symbologies.

     

     

     

    for your reference check the below links:

    http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/d9/4a94c851ea11d189570000e829fbbd/content.htm

     

    for smart, please check the below link:

    http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm

     

    See the below program forbarcode in sapscript for your reference:

     

     

    DATA: BAR_CODE1(16) VALUE `ABC01230123A01'

    NEW-PAGE PRINT ON IMMEDIATELY `X'.

    FORMAT COLOR OFF INTENSIFIED OFF.

     

    • If the barcode is the first element on the page, the following Write

    • statement is needed (otherwise you get a date in the first print

    • control.

     

    WRITE:/

     

    • Turn on the barcode font, print the data, and switch back to the

     

    • printer's default font. Be sure to use NO-GAP to avoid unwanted

     

    • characters or CR/LF.

     

    PRINT-CONTROL FUNCTION `BCPFX'

     

    WRITE: BAR_CODE1 NO-GAP

     

    PRINT-CONTROL FUNCTION `BCSFX'

     

    • Add a Write statement to prevent insertion of CR/LF into the barcode.

     

    WRITE:/

     

    Sample SAPSCRIPT

     

    • Variable BAR_CODE1 contains the barcode data, including asterisks.

     

    • The & is needed to avoid unwanted spaces or CR/LF characters

     

    /E LINE

     

    /: PRINT-CONTROL BCPFX

     

    = &BAR_CODE1&

     

    /: PRINT-CONTROL BCSFX

     

     

    Regards,

    Pavan

  • Re: barcode
    reshma alumadathil
    Currently Being Moderated

    hi,

     

    Check this link for Barcodes.

    http://www.sap-img.com/abap/details-information-about-sap-barcodes.htm

     

    Regrds

    Reshma

  • Re: barcode
    Azra Husain
    Currently Being Moderated

    Hi

     

    Please follow the link. This will help you to generate

    barcode in ABAP report.

     

    http://www.makebarcode.com/info/appnote/app_024.html

     

    please reward points if helpful.

    • Re: barcode
      neerja thakur
      Currently Being Moderated

      Hi,

      To create barcode go to transaction se73 Then System Bar codes.

      There are some barcodes already present.

      If they solve your purpose,use them otherwise create new ones.

       

      The main characteristics of barcodes are

      1) Min. Char

      2)Max Char

      3)Width

      4)Height

       

      Now in your sapscript create a character format.

      There you can see an option to select barcode.

      From there select the appropriate type.

       

      Now use this character format for the field you want to display the barcode.

       

      I think this will solve your problem.

      Fell free to ask if you still get an issue.

       

      Reward if helpful.

       

      Thanks,

      Neerja

  • Re: barcode
    Anji Reddy Vangala
    Currently Being Moderated

    Hi

    To Create a Bar code prefix:

     

    1) Go to T-code - SPAD -> Full Administration -> Click on Device Type -> Double click the device for which you wish to create the print control -> Click on Print Control tab ->Click on change mode -> Click the plus sign to add a row or prefix say SBP99 (Prefix must start with SBP) -> save you changes , it will ask for request -> create request and save

     

    2) Now when you go to SE73 if you enter SBP00 for you device it will add the newly created Prefix

     

     

    Create a character format C1.Assign a barcode to the character format.Check the check box for the barcode.

     

    The place where you are using the field value use like this

     

    <C1> &itab-field& </C1>.

     

    You will get the field value in the form of barcode.

     

    Which barcode printer are you using ? Can you download this file and see.

     

    http://www.servopack.de/Files/HB/ZPLcommands.pdf.

     

    It will give an idea about barcode commands.

     

    Check this link:

     

    http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm

     

    Check this link:

     

    http://help.sap.com/saphelp_nw04/helpdata/en/d9/4a94c851ea11d189570000e829fbbd/content.htm

    Hope this link ll be useful..

     

    http://help.sap.com/saphelp_nw04/helpdata/en/66/1b45c136639542a83663072a74a21c/content.htm

     

    Detailed information about SAP Barcodes

    A barcode solution consists of the following:

    - a barcode printer

    - a barcode reader

    - a mobile data collection application/program

    A barcode label is a special symbology to represent human readable information such as a material number or batch number

    in machine readable format.

    There are different symbologies for different applications and different industries. Luckily, you need not worry to much about that as the logistics supply chain has mostly standardized on 3 of 9 and 128 barcode symbologies - which all barcode readers support and which SAP support natively in it's printing protocols.

    You can print barcodes from SAP by modifying an existing output form.

    Behind every output form is a print program that collects all the data and then pass it to the form. The form contains the layout as well as the font, line and paragraph formats. These forms are designed using SAPScript (a very easy but frustratingly simplistic form format language) or SmartForms that is more of a graphical form design tool.

    Barcodes are nothing more than a font definition and is part of the style sheet associated with a particular SAPScript form. The most important aspect is to place a parameter in the line of the form that points to the data element that you want to represent as barcode on the form, i.e. material number. Next you need to set the font for that parameter value to one of the supported barcode symbologies.

     

    <b>Reward points for useful Answers</b>

    Regards

    Anji

  • Re: barcode
    Ameet Jassani
    Currently Being Moderated

    Hi,

     

    We are able to print barcodes from smartforms. Doing this way,  we print barcodes on laser printers. 

     

    We are also printing from sap to zebra printers using two ways: 

    1. Download the data to an excel sheet, then creating a macro that opens the printer port and sending the commands to the printer through this "file". All this is done via vb script provided with excel).. 

    2. The second way is creating a vbscript  (an ascii file from sap) with the printer commands and then runing it using ws_execute. 

     

    You need a barcode reader to read the barcodes, and this scanner acts like a keyboard, it sends the data scanned to the active field on screen. (which might be a notepad, word, excel or an input field  or ... ). 

     

    Back to your problem:

     

    1. We're using Zebra 2746-e (Eltron)  to print labels that have some barcodes in their design. There are several approaches to solve this problem. We've decided to work with the programming language of the printer (EPL-2), because we use the zebra printers from SAP or from other windows applications.  

     

    Our solution was to develope function module that creates an ascii file  (a vbscript file) and then use the ws_execute to run wscript with this file. The vbscript just opens the port for output and sends a sequence of writeline, each of them with a command to the printer. After all the commands were sent to the printer, we close the port . Just note that the port acts the same as a file. 

     

    This is an EXAMPLE of the visual basic script code;

     

    Set fs=CreateObject("Scripting.FileSystemObject")

    Rem send the output to COM1 port.

    Set a = fs.CreateTextFile("COM1:",True) 

    Comilla = Chr(34)

    a.writeline "O"

    a.writeline "ZB"

    a.writeline ""

    a.writeline ""

    a.writeline ""

    a.writeline "N"

    a.writeline ""

    a.writeline ""

    a.writeline "q800"

    a.writeline "Q635,24+0"

    a.writeline "R32,24"

    a.writeline "S3"

    a.writeline "D8"

    a.writeline "ZT"

    a.writeline ""

    rem this is an example of barcode ean128-ucc

    a.writeline "B126,429,0,1E,3,3,61,B,""011234567890123410051215"""

    rem this is an example of barcode 3 of 9 rotated

    a.writeline "B10,495,3,1,3,3,49,B,""01234567"""

    a.writeline ""

    a.writeline ""

    a.writeline "P1"

    a.writeline ""

    a.Close

     

    We've send this code to an ascii file or as part of a macro to be run within an excel sheet. We have succeed in both cases. 

    The zebra printer is created as local to the computer running the vbscript.  We haven't been able to share the zebra printer so other people in the network can use it. And the zebra printer isn't installed as a SAP printer (we aren't using sap spooler to send jobs to the zebra). Another Note: zebra 2746 comes with a software bar-one (or something like that) that allows you to design the barcode label in a wysiwyg way 

     

    If my memory isn't failing, I think that I've read something about controlling zebra printers from smartforms in service.sap.com, but I haven't explored this possibility. 

     

    2. From 4.6c on, you can use smartforms to print barcodes without buying any barcode.dll software nor hardware extention like Bardimm on any laser/inkjet printer (Please Note that I haven't mentioned Zebra printers here!). To do this, you have to create a smartstyle -> character format with the desired barcode font (defined within sap). Then in the smartform, create a window, put the field and associate it the character format. That's all (I mean, that's all we do at least :-). I think, you have to consider the barcode specifications before sending the barcode value to the smartform (Just an example, if you're using 3 of 9, the code should start and end with an asterisk - '*' -) We're printing an interleaved 2 out of 5 barcode in our invoices due to a legal requirement, and we did it this way.

     

    3. If you have a barcode scanner, then you should not need reading the barcode into an ascii file to get the data read in an standard or custom screen field. You can read it  directly to the field you want. (unless... you have  complex data coded in the barcode - for example if you're using an ean-ucc 128 compliant code and you're sending several fields in a single code ... In this case, an interface is almost mandatory because you must interpret the data fields according to the ucc standard, split the code into several fields .... and .... pure programming logic   ). 

    To put it clear: if you have to read, for example, a barcode that holds the legal number of an invoice using a barcode scanner and this number should be sent to migo-> bktxt then you don't need an interface. The scanner itself acts like a fast operator entering the characters using a keyboard and filling in the field. 

    We're reading barcodes in several places (when we finish each pallet, when we receive an invoice, and so on. Each case is a different screen. We arent using an ascii file to read these barcodes. Furthermore, we read the invoice legal number into migo bktxt field (Head Text). 

     

     

    Pls reward points if useful.

     

    Regards,

    Ameet.

  • Re: barcode
    Ameet Jassani
    Currently Being Moderated

    Hi,

     

    Printing barcodes from a SAP script is quite easy, but how can we print it with a WRITE statement? The following ABAP code is a tested solution, which prints barcodes (type ARTNR -code 128) on Kyocera (F800-FSxxxx series) laserjet printers. For other types of printers find the printer control and driver info from the user manual and define it your report.

     

    Note: This code has not been tested above 4.0B versions.

     

    Code:

     

    data: begin of precom9, "command for  printer language PRESCRIBE

       con1(59) value

    '!R!SCF;SCCS;SCU;SCP;FONT62;UNITD;MRP0,-36;BARC21,N,''123456''',

        con3(55) value

       ',40,40,2,7,7,7,4,9,9,9;MRP0,36;RPP;RPU;RPCS;RPF;EXIT,E;',

          end of precom9.

    ...................

     

    *replace 123456 of precom9+52(06) with the actual material number..

    .....................

    new-page print on.    "barcode printer

    Write: 'material number', precom9.      "barcode for matnr

    new-page print off.

     

     

    Pls reward points.

     

    Regards,

    Ameet

    • Re: barcode
      Pavan Valluri
      Currently Being Moderated

      Hi

      Introduction

       

      This paper describes how to print barcodes on SAP systems using downloadable fonts and standard laser printers. The process is relatively simple:

       

      • Copy a barcode font file from the host system to the destination printer.

       

      • Create an output file with formatted text strings and font selection commands

       

      • Send the output file to the printer.

       

      PCL (Printer Command Language) is a standard developed by Hewlett-Packard Corporation which

       

      defines a wide range of commands that control the formatting of documents on laser printers. PCL is supported by virtually every laser printer manufactured. PCL includes specifications for "soft fonts" which, when downloaded to a printer, will be automatically stored in the printer's memory and be available for use.

       

      Most laser printers do not include native barcode capability. Those that do often employ a variety of command syntaxes, making it difficult to mix printer brands within a single system. Plug-in barcode modules are available, but are often printer brand or model-specific, and the cost per printer stays relatively level (generally from $250 to $425 per printer depending on capabilities of the module).

       

      Downloadable soft fonts work on any brand or model of printer with the same command syntax, simplifying programming in large installations and expanding the range of printers that can be used. Some high-capacity printers include programmable memory or hard disk drives and can store downloaded fonts permanently. Although downloadable fonts do not offer the automated formatting features found in the high-end hardware modules, the cost per printer is dramatically less.

       

      The downloadable fonts described in this paper are available as pre-built kits or can be generated using the Barcode Font Generator from MEC Software. Sample fonts, demonstration programs, and pricing/licensing information are available through The Barcode Software Center, on the web at www.makebarcode.com.

       

      The version of SAP used in preparing this paper was 4.6c.

       

      top of page

       

       

      -


       

      Downloading Fonts to the Printer

       

      Before barcodes can be printed, a barcode font must be available in the printer's memory.  MEC Software PCL-5 fonts include all of the required PCL commands and data; all that is required is to send the font file from the host computer to the printer. There are several methods for sending a font to your printer. Two that work well in the SAP/Windows environment are lpr and copy.

      lpr

       

      The lpr command can be an effective method for downloading fonts. Unix and Linux support lpr; Windows/NT, 2000, and XP also support lpr, but it may not be installed by default (lpr may be called Unix printing by the Windows setup process). The general form of the lpr command is:

       

      1. lpr -S<server> -P<printer> [-C<class>] [-J<job name>]

       

      [-O<option>] <filename>

       

      As an example, let's assume that the destination printer is available at IP address 192.168.100.40 and the file BC_3of9_4pitch.dsf contains the downloadable PCL barcode font. We must use -O (option) followed by a lower case letter "L" to specify binary mode (Windows requires a lower case "o"):

       

      1. lpr -S192.168.100.40 -P192.168-100.40 -Ol myfont.dsf

       

      copy

       

      You can simply Copy the font file to the printer port. In Windows, open a MS-DOS command line window. Use the /b (binary) command line option:

       

      C:\> COPY /B myfont.dsf LPT1:

       

      Note: If your system does not support long filenames you will need to rename the files. For example: C39_4PIT.DSF.

       

      If you are in a MS-DOS command prompt under Windows and the destination printer is on the network, using the printer's network name may not work depending on your version of Windows. For example, this command should send the font to the printer under Windows/98 and Windows/2000, but may simply make a copy of the file on disk with Windows/95:

       

      C:\> COPY /B myfont.dsf
      MAIN\LASER

       

      You may first have to assign the printer to a local printer port with the NETUSE command. The port does not have to physically exist, and you should not use a port that actually has a local printer attached to it. For example, if you have local printers attached to LPT1 and LPT2 and a network printer named "
      Main\Laser," you could assign LPT3 to the network printer:

       

      C:\> NETUSE LPT3: "
      MAIN\LASER"

       

      C:\> COPY /B myfont.dsf LPT3:

       

       

      <u><b>Defining Printer Control Sequences in SAP</b></u>

       

      We need to define a barcode prefix (a command string to turn on the barcode font) and a suffix (another command to switch back to a normal text font). First, we need to get to the right screen. Select SAP Transaction SPAD (Spool Administration) to display Spool Administration: Initial Screen. Then click the Full Administration button.

       

       

       

      Select the Device Types tab and select the printer that will be printing the barcodes (HPLJ4, for example).

       

       

       

      Select the green check mark after entry of the Device Type to display the Spool Administration: Device Type screen, then click on the Print Controls tab.

       

       

       

      The Print Controls page displays a list of defined print control sequences, each identified by a name. You can create new sequences or modify existing sequences. Let's create a control sequence named BCPFX to define the prefix that will turn on the barcode. Each downloaded font is identified by a number which is built into the font. Assuming that the font we want is number 200, we will need the following characters:

       

      Escape Code (hex 1B)

       

      Opening (left) parenthesis character (hex 28)

       

      Font ID 200 (hex 32 30 30)

       

      An upper case X to mark the end of the command (hex 58)

       

      All of these characters need to be entered as a single string (no spaces) in the Control Character Sequence column: 1B2832303058. We also need to define a sequence to turn off the barcode font and switch back to a normal text font. Let's create sequence BCSFX to switch to the printer's default font. The PCL command to do this requires the following characters:

       

      Escape Code (hex 1B)

       

      Opening (left) parenthesis character (hex 28)

       

      The number 3 (hex 33)

       

      An @ symbol (hex 40)

       

      So the complete sequence would be written as: 1B283340. You might prefer to switch to a specific text font instead of the printer's default. Complete details can be found in the PCL Reference Manual, available from Hewlett-Packard.

       

      top of page

       

       

      -


       

      <b>Printing Barcodes with ABAP or SAPSCRIPT</b>

       

      We are now ready to print barcodes using an ABAP report program or a SAPSCRIPT form. In these examples we are using Code 39 barcodes which require very little formatting (all we have to do is add asterisks before and after the data).

       

      <b>Sample ABAP Program:</b>

       

      DATA: BAR_CODE1(16) VALUE `*ABC01230123A01*' 
      
      NEW-PAGE PRINT ON IMMEDIATELY `X'. 
      
      FORMAT COLOR OFF INTENSIFIED OFF. 
      
      * If the barcode is the first element on the page, the following Write 
      
      * statement is needed (otherwise you get a date in the first print 
      
      * control. 
      
      WRITE:/ 
      
      * Turn on the barcode font, print the data, and switch back to the 
      
      * printer's default font. Be sure to use NO-GAP to avoid unwanted 
      
      * characters or CR/LF. 
      
      PRINT-CONTROL FUNCTION `BCPFX' 
      
      WRITE: BAR_CODE1 NO-GAP 
      
      PRINT-CONTROL FUNCTION `BCSFX' 
      
      * Add a Write statement to prevent insertion of CR/LF into the barcode. 
      
      [code]WRITE:/

      [/code]

       

      <b>Sample SAPSCRIPT</b>

       

      • Variable BAR_CODE1 contains the barcode data, including asterisks.

       

      • The & is needed to avoid unwanted spaces or CR/LF characters

       

      /E LINE 
      
      /: PRINT-CONTROL BCPFX 
      
      = &BAR_CODE1& 
      
      /: PRINT-CONTROL BCSFX

       

       

       

       

      Reward all helpfull answers

       

      Regards

      Pavan

       

      Message was edited by:

              Pavan praveen

  • Re: barcode
    lawrence smith
    Currently Being Moderated

    As for generating barcodes in Reports, I used two types. They are may be helpful.

    generating barcode in RS

    generating barcode in RDLC Reports

Actions