ABAP BarCode

本文介绍了如何在SAP系统中利用Smartforms生成条形码,包括维护字体、创建样式、构建Smartform以及ABAP程序来调用Smartform。详细步骤包括创建新的条形码字体、定义样式,并提供了在打印中遇到问题时的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Introduction

With traditional bar code printing, the bar codes are generated at the printer and not in the SAP system. Special hardware, such as SIMM modules, is required to do this. If the bar code is to be formatted or controlled with traditional bar code printing, print controls must be changed in the printer commands. In contrast to traditional bar code printing, the new bar code printing does not require any special software, since the bar code is sent to the printer as a graphic. However, the new bar code printing only works with Smart Forms.

1. Maintaining the Font(s)

  • Go to TCODE SE73 and display the system bar codes*,*
  • A default font (such as C128A shown below) can be used or you can create your own font

Creating a new font

  • Make sure you are in change mode for System bar codes
  • Click on the New button on the toolbar and then choose the 'New Bar Code Technology' and give it a name (eg: BC_NAME) and description

        

 

  • Different barcode technologies are available. For this example we shall use 'Code 128'
      
  • Keep the other settings as default and save the font in a transport request (clicking on cancel at the transport request popup will save it locally)

2. Creating the Style

  • Go to transaction SMARTSTYLES or use the 'Style' radio button of transaction SMARTFORMS
  • Create a new Style (eg: ZBARCODE_STYLE)
  • Create a default Paragraph Format by clicking on 'Create Node' from the Context Menu of 'Paragraph Formats' in the left navigation view
  • Create a new Character Format by clicking on 'Create Node' from the Context Menu of 'Character Formats' in the left navigation view (I have given the Character Format the name 'CH' in this example)

      

  • From the barcode name dropdown list, choose either a system default value such as C128A or the font that we just created (eg: BC_NAME)

       

  • Save and activate the Style

    3. Creating the Smartform

Here we will create a Smartform to display Material numbers from the MARA table as well as a barcode which contains that same Material number * Go to transaction SMARTFORMS and create a new Smartform (ZBARCODE_MARA in this example)

  • Create the following entry in the Tables tab of the Form Interface of your Smartform

       

  • Save the Smartform
  • Create a new Table entry on the Main Window as shown below

      

  • In the Table tab of %TABLE1,Split the Line type %LTYPE1 into two parts
  • In the Data tab, LOOP AT Internal Table IT_MARA INTO IT_MARA
  • Create a Table Line in the header as well as the Main Area of the table
  • Assign Line type %LTYPE1 to both of them
  • Create a Text value in each of these four cells (you can rename them to make it easier to understand) Your left side navigation display should now look something like this

      

  • Put appropriate headers into the HEADER_MATNR and HEADER_MATNR_CODE text fields
  • Click on the Field list button to display the field list

      

  • Drag and drop the MATNR field from the IT_MARA table interface into the General Attributes tab of the DATA_MATNR as well as the DATA_MATNR_CODE cells

        

  • In the Output Options tab of the DATA_MATNR_CODE cell, choose the style that you created earlier (ZBARCODE_STYLE in this example)
  • Go back to the General Attributes tab, select the text &IT_MARA-MATNR& and then change its character style to 'CH'
  • Save and activate the Smartform

4. ABAP Program to call the Smartform

  • Go to transaction SE38
  • Create a simple program to call the Smartform
  • Save, activate and run the program
  • You can choose to preview or print the Smartform

Sample program

5. Sample Output


 

 

 

6. Troubleshooting

Consecutive bar-coded rows overlap

Create a new paragraph format and set the Line Spacing to 2 Lines

Use this new format in the non bar-coded cells

Second field shows MATNR in English and not bar-coded

Make sure you select the text before changing the character format in the Smartform

Preview is proper but printing doesn't take place at all

Make sure your printer is configured properly in transaction SPAD. Try printing something else from SAP to verify the settings

The device type used in our system is SAPWIN   : Rel.4.x/SAPlpd 4.09+_Also check the _Print Immediately button, else go to transaction SP01 to immediately print all pending print jobs

Preview is proper, text is printed properly but barcode (and pictures) are not proper

Check that your printer is configured properly in Windows with the proper driver that matches your printer's model

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值