Printing Barcodes with SAP R/3 and Bar Tender
Home > Barcode Basics > Application Notes > AppNote012

Bar Tender Enterprise Edition can be used to print barcode labels and documents on SAP R/3 systems without the complex programming effort required by many other solutions. This document provides an introduction; the best way to fully understand and test the system is to download a copy of the Bar Tender trial edition. Click here for pricing information and the trial edition.
   
SAP™ R/3 (Systems, Applications, and Products in Data Processing) is an enterprise-scale, customizable, workflow application produced by SAP AG of Frankfurt, Germany. It is designed to automate all of the core processes in a large business including order processing, supply chain, inventory management, order fulfillment, and customer service, and it is used by medium and large businesses worldwide.

Crucial to SAP's success is its powerful integration features that enable disparate third-party applications and incompatible databases to exchange information with each other. Bar Tender uses one of these integration technologies, called Intermediate Documents (IDocs), to print data from any of your company's SAP-connected databases onto your labels.

An IDoc (Intermediate Document) is a transactional message, in the form of a text file, sent from a SAP-connected application to other applications. Most of an IDoc message consists of fields of data grouped into segments. The segments themselves have a hierarchical relation to each other.

Example: A physician's prescription of a drug for a hospital patient needs to get to the hospital's pharmacy. This could be done by means of an IDoc sent from a bedside application to an application in the pharmacy. Suppose the IDoc has a hierarchy of four levels of segments:

Patient Name: Johnson
     Diagnosis: croup
     Diagnosis: tibia fracture
          Visit Type: admission
               Drug: codeine
               Drug: amidol
          Visit Type: followup
               Drug: naprosin

^    ^    ^    ^
1    2    3    4


Level 1: Contains data that remains constant for years at a time, such as patient name and address.

Level 2: Contains data that remains constant through a given illness, but changes from illness-to-illness; such as primary physician and diagnosis. There can be more than one second level segment for a given patient.

Level 3: Contains data that tend to change from visit-to-visit but remains constant through a particular visit to the hospital; such as visit type (admission or followup) and attending physician. A patient may have more than one hospital visit during an illness.

Level 4: Contains data that tends to change from prescription-to-prescription; such as prescribing physician, medicine, and dosage. More than one medicine may be ordered for a given patient on a given visit.

Since an IDoc is a message, both the sending and receiving applications must conform to a common convention about where, in a given IDoc, each piece of data will be found. To this end, SAP AG has defined several hundred IDoc types and a large number of segment types.

A sending application must construct an IDoc of a given type in accordance with these definitions and a receiving application, like Bar Tender, must conform to the definitions when parsing the IDoc. This means that identifying a parser file is one step in setting up Bar Tender to use data from IDocs. A parser file for an IDoc type contains the information Bar Tender needs to parse the IDocs; such as what segments can appear in it, which segments are repeatable, what data fields will appear in each segment, what order the fields will be in, and what length each field will have. You associate a parser file with a particular IDoc type on Bar Tender’s IDoc Type Definitions window.

IDoc types have names of six letters and two numerals. SHPMNT01 is an IDoc that embodies a message about shipments. SAP revises the definitions of IDocs from time to time, and the two numerals at the end of the name identify the revision.

Segment names may end in three digit version numbers. For example, E2KNA1M001 is a segment for the DEBMAS02 (customer masters) IDoc type. SAP owners can create their own custom IDoc types and segment types. Names of segments defined by SAP AG always begin with "E", while custom designed segment names always begin with "Z".

Since data in a child segment is always associated with the data in its parent, any non-branching path through a tree in an IDoc, from a top node to a bottom node can be thought of as a record just like the records in a table-oriented database. For example, consider the data hierarchy shown earlier, in which each segment has just one field for simplicity:

Patient Name: Johnson
     Diagnosis: croup
     Diagnosis: tibia fracture
            Visit Type: admission
                 Drug: codeine
                 Drug: amidol
            Visit Type: followup
                 Drug: naprosin


Patient Johnson has been treated at different times for croup and a tibia fracture (details of the first illness are not depicted). In the first hospital visit for the fracture the doctor prescribed codeine and amidol. In the second, the doctor ordered naprosin. The path through the tibia fracture and the prescription for naprosin can be collapsed into a flat record like this:

Patient Name    Diagnosis        Visit        Drug
Johnson         tibia fracture   followup      naprosin


The two other complete paths could be collapsed into these records:

Patient Name    Diagnosis        Visit        Drug
Johnson         tibia fracture   admission    codeine
Johnson         tibia fracture   admission    amidol


When Bar Tender reads IDocs, it will collapse data trees into flat records. You will select the fields from these records that you need on your labels. The Add Database Wizard takes you through the process of adding a SAP IDoc database to the pool of databases available to this application.

1.    On the Add Database Wizard - Type window, select the radio button SAP R/3 Intermediate Document (IDoc) File, and then click Next.

2.    On the Add Database Wizard - Options window, select an IDoc type and an IDoc file from which to draw data for your labels. If necessary, add, modify, or remove IDoc types. When you are finished, click Next.

3.    On the Add Database Wizard - Master Segment window, select the Master Segment and click Next.

4.    On the Add Database Wizard - Fields window, select the fields on the IDoc from which you want to draw data. If you pick any fields on repeating segments, set the repeating segment rules for each such field.

5.    Click Finish.

The Add Database Wizard process is complete and you will be returned to the Database Setup window. In the tree view of databases available to Bar Tender, there is now a child, called SAP Database, under All Databases. Fields from the IDoc are available for inclusion on a label design.

Printing of labels can be automated by including the name of an Idoc on the command line which runs Bar Tender; command line options are also available for changing the IDoc type and for automatically erasing the IDoc on completion of printing. Bar Tender’s Active-X interface also permits programmatic control of the IDoc type and name.


SAP is a trademark of SAP Aktiengesellschaft

Related links:
[ Bar Tender for Windows ]
[ SAP barcode solutions ]