overview of commander - seagull scientific

27
Commander Middleware for Automatically Printing in Response to User-Defined Events The World's Leading Software for Label, Barcode, RFID & Card Printing

Upload: others

Post on 23-Dec-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

CommanderMiddleware for Automatically Printing in Responseto User-Defined Events

The World's Leading Software forLabel, Barcode, RFID & Card Printing

Contents

Overview of How Commander Works 4Triggers 4Tasks 5Task Lists 5How Commander Detects Triggers 5Using Commander to Run Any Application 6

Advanced Commander Capabilities 7Commander Scripts 7Commander Variables 7BarTender Command Handlers 8

Commander Features added with Enterprise Automation Edition 10TCP/IP Socket Triggers 10Ability to Submit BarTender XML Script (BTXML) and Receive Print Status Response 10Send Data to a File, a TCP/IP Socket, or a Web Server 10XML Transforms 10Search-and-Replace Transform 10Built-in Transforms for SAP AII, IBM WebSphere, and Oracle WMS and MSCA 10Multiple BarTender Processes 10

Example 1: Print Item when Detecting New Trigger File 12Goal 12Case Scenario 12Implementation 12

Example 2: Print Item Using Trigger as Database 15Goal 15Case Scenario 15Implementation 15

Example 3: Print Item Using Commander Script 19Goal 19Case Scenario 19Implementation 19

Example 4: Print Item Using SAP R/3 IDoc File 23Goal 23Case Scenario 23

Implementation 23Related Documentation 27

Overview of How Commander WorksCommander is a software utility, provided with both the Automation editions of BarTender, thatenables you to perform automatic printing using BarTender in situations where it is not convenient orpossible to perform automation using ActiveX or command lines. Commander can be run as anapplication or as a Windows service.

TriggersWhen a system needs to print, it simply performs a triggering action, such as placing a file in alocation of your choosing on the network, transmitting an e-mail, sending data via RS-232 (a serialport), or sending information through a TCP/IP socket connection. Commander detects the arrival oroccurrence of these “triggers” and then “wakes up” BarTender so it can merge your data into theprinted item design and automatically print your items.

Some Different Trigger Types

A trigger file or message can be an empty “wake up call” without data. Alternatively, the triggercan contain printed item data and script commands that will be used by Commander, BarTender,and/or another application that Commander launches.

As an example, assume that an in-house order fulfillment program saves order information into adatabase and creates a trigger file named NewOrder.dat in a directory being watched byCommander. After Commander detects the creation of that file, it would “wake up” BarTenderand the print job could be processed in a number of ways, including:

If the Trigger File is Empty: The BarTender document might be configured to query thedatabase for information about orders entered after a specified time, and use the queryresults in the print job.

If the Trigger File Contains BarTender Document Data: Alternatively, the BarTender printjob might be set up to simply read the document data right out of the trigger file.

Other Types of Trigger Content: In addition to printed item data, trigger files andmessages can also contain Commander Script and BarTender XML Script (BTXML).

Regardless of the trigger type, once the print job is done being processed, Commander wouldusually be configured to delete the NewOrder.dat trigger file so that it could resume monitoring ofthe directory and wait for the next print job.

Commander 4

TasksA Commander task is a set of one or more commands associated with a trigger.

l First you select what type of trigger willcause Commander to execute thecommand(s) for that task, and you specifycertain options.

l Next you define the actual commands thatwill be executed in response to the trigger.These can be any combination of BarTendercommands, operating system commandlines, and Commander script.

Task ListsCommander can monitor more than one triggerand execute a separate task in response to eachone. The task or set of tasks that Commander is ready to execute at any given time is called a tasklist. You may define and save more than one task list, but only one can be active in Commander atany one time.

How Commander Detects TriggersCommander’s methods of detecting triggers are customizable. For example, Commander can detectfile triggers using either of two methods:

l Interrupt-driven: Commander detects almost immediately that the trigger file has beencreated.

l Polling-driven: Commander checks the target directory at periodic intervals for the presenceof the trigger file. You can set the interval with precision measured in milliseconds.

There are also multiple ways that TCP/IP Socket communications can trigger Commander, such as:

l Arrival of a specific sequence of characters.l Occurrence of predefined periods of inactivity.l Disconnection of the socket’s source.

Commander 5

Using Commander to Run Any ApplicationCommander’s primary purpose is to allow software programs to print items with BarTender withoutactually having to directly control BarTender. However, Commander can launch any systemcommand or installed Windows application that can be executed using the Run option of theWindows Start menu. Therefore, Commander can respond to a received trigger by doing much morethan just printing BarTender items.

For example, assume that a company’s customer service department processes customers byhaving them come to web site to fill out forms requesting assistance and that the entered data isthen transmitted to headquarters in the form of an e-mail. A copy of Commander running atheadquarters could be configured to trigger when those emails arrive, write the e-mail contents to atext file, and then call an application that reads the file and stores its contents in a database. This isan example of how Commander’s trigger-based integration technology can simplify your middlewarechallenges.

Commander 6

Advanced Commander CapabilitiesHere are some more complex triggering scenarios that Commander can handle:

l It does not matter whether the application creating the trigger is running on Windows or not.l The wildcard characters * and ? can be used to specify the trigger file name (or the Subject

line when an e-mail trigger is used). This lets you easily take advantage of serialize file names(such as name001, name002, etc.) so that triggers can occur faster than Commander canprocess them.

l Special Commander variables can be used so that Commander can fill in certain values at taskexecution time and pass the data to BarTender.

l The contents of a trigger can contain the command line parameters that BarTender is to usewhen launched.

l The trigger contents can contain the data that should appear on a printed item.l Commander can be configured to preload copies of BarTender and selected BarTender

documents in advance. This way, the execution of tasks does not have to be slowed down bythese loading actions, and can start printing right away.

l Commander can perform more than one command in response to a given trigger.l Commander can instruct BarTender to close after it has printed the item.l Commander can be set to log all of its activities.

Commander ScriptsA Commander script is a set of written instructions that Commander can read and execute.Applications that create triggers can add include script commands in the triggers. This allows theapplication to give Commander instructions that vary from trigger to trigger, instead of havingCommander perform exactly the same actions in response to every trigger of a given type.

The primary purpose of a Commander script is to specify a BarTender command line, and to specifythe data that is to populate the fields on the BarTender document.

Commander VariablesCommander Variables are text tags that get replaced at task execution time. They are used bydifferent Command types in different ways. Some examples:

l With a Commander Script command, Commander Variables are replaced directly in theCommander Script.

l For an Operating System command, Commander Variables will be replaced in the CommandLine.

l For a BarTender command, you can specify the name of a text file using a CommanderVariable.

System environment variables can also be read using Commander Variables. This is useful forretrieving information like User Name or Computer Name. In the Variables tab of the File > Task ListOptions dialog, there is a table that allows you to create your own Commander Variables.

Commander 7

BarTender Command HandlersYou can increase the speed at which items are printed by having multiple instances (or “processes”)of BarTender running, each working simultaneously on the same or different tasks. Furthermore,different instances of BarTender can launch with different sets of command parameters, so you canassign each command of a task to the most appropriately-configured instance of BarTender. You canalso save system resources by having seldom-triggered tasks immediately close BarTender after it isdone being used to execute a task.

Each command in a task can specify a “Command Handler” to execute it. A Command Handler is anamed group of settings that specify command line parameters to use when starting BarTender, aswell as the number of BarTender processes to start. Command Handlers are primarily responsiblefor preloading Bartender documents, and passing print job instructions to BarTender processes.With the Enterprise Automation Edition (described below), if a particular Command handler is heavilyused, you can define it to use more than one BarTender process. By default, all tasks share a singleCommand Handler. This minimizes the use of system memory, but does not perform as well in somecases if custom Command Handlers are used.

For example, a user could create these three command handlers:

l The command handler called “Standard” is used to create printed items for a high-volumeshipping application. It preloads the same BarTender document into five different BarTenderprocesses and leaves them running. Each time a new order is placed, a trigger is created bythe shipping application and Commander uses the first available BarTender process to printthe document. (The ability to assign multiple BarTender processes to a Command Handler isspecific to the Enterprise Automation edition of Commander.)

l A second command handler, called “Repair/Returns,” is used less frequently. Therefore, it issufficient for it to preload and use only one BarTender process.

l Finally, a third command handler, called "Refunds," is assigned to a task that is triggered toprint an envelope only a few times a week. In order to conserve system resources, theCommand Handler does not preload a BarTender process or any BarTender documents.Instead, it loads BarTender and the document as needed, prints the required envelope, andthen closes BarTender.

Commander 8

Commander 9

Commander Features added with Enterprise Automation Edition

TCP/IP Socket TriggersIn addition to triggering on Files and E-mails, the Enterprise Automation edition of Commander iscapable of triggering on TCP/IP sockets. As with trigger files, TCP/IP socket communication cansimply be an “empty” trigger, or the communication can also contain document data and/orCommander Script code. TCP/IP sockets are a good option when a file share or file creation is notpossible or convenient. Direct TCP/IP socket communication is also faster than the creation ofintermediary data files, and allows superior programmatic interaction between the originatingapplication and Commander.

Ability to Submit BarTender XML Script (BTXML) and Receive Print StatusResponseThe Enterprise Automation edition of BarTender supports an XML-based scripting language thatgives applications even more control of BarTender than Commander Script offers. WhereasCommander executes Commander Script directly and performs the requested actions itself,Commander passes on received BTXML for execution by BarTender.

Once BarTender executes the BTXML, it will return BTXML that contains detailed information aboutany executed print jobs, including the job status.

Send Data to a File, a TCP/IP Socket, or a Web ServerYou can send trigger contents, the BTXML print response, or other data to a file, a socket, or a webserver. This is particularly useful when returning print status.

XML TransformsIf XML is received by Commander as part of a trigger, Commander can use XSL transforms to convertit into any other data format. One of the best uses of this feature is to allow applications to outputXML in their own familiar format and then depend on Commander to convert it into the XML scriptreadable by BarTender (BTXML).

Search-and-Replace TransformThis transform allows you to automatically search and replace information from an incoming trigger.This is useful in a variety of circumstances, like changing a BarTender document name or a printername.

Built-in Transforms for SAP AII, IBM WebSphere, and Oracle WMS and MSCAThese built-in transforms allow you to convert print request from these various systems into BTXML,so that they can be submitted to BarTender for processing.

Multiple BarTender ProcessesWith the Enterprise Automation edition of Commander, it is possible to assign multiple BarTenderprocesses to a single Command Handler (described above, in the Bartender Command Handlers

Commander 10

section). This allows for more rapid response to large numbers of closely occurring Commandertriggers, such as might be encountered in high-demand centralized printing environments.

Commander 11

Example 1: Print Item when Detecting New Trigger File

GoalThe purpose of this example is to show, in detail, how Commander is configured to detect an emptytrigger file or e-mail message and then to react by instructing BarTender to launch and print aspecified BarTender document. The techniques involved are also applicable to the later examples.

Case ScenarioAt a parts-manufacturing plant there is a need to have an item with a serialized number printed atthe end of an assembly line. On this item, there is no other dynamic or changing information, otherthan the incremented barcode. What generates the trigger file is a “Laser Presence Sensor” towardthe end of the assembly line that detects parts and generates an empty text file into a specificdirectory that Commander is configured to monitor.

Implementation

NOTE: The files created in this example can be found in 1stExample.zip insideCommanderExamples.zip located at:

ftp://ftp.seagullscientific.com/BarTender/Examples/Commander

Use them to verify that the files you create are correct.

Create the BarTender Document

1. Open BarTender.2. From the File menu, select New. The New Document Wizard opens.3. Select Blank Template, then click Finish to close the New Document Wizard.4. From the File menu, select Print. The Print dialog opens.5. From the Name dropdown list, select the printer you want to use. Click Close.6. From the File menu, select Page Setup and configure your page as needed. When you're

finished, click OK.7. From the Create menu, select Barcode.8. From the Select Barcode dropdown list, select a barcode type, or select More Barcodes

to open the Select Barcode dialog. (If you use the dialog, choose a barcode type, and clickSelect.)

9. Click anywhere on the template to add the barcode object.10. Double-click the barcode. The Barcode Properties dialog opens.11. Click the Transforms tab.

12. Next to Serialization, click the icon. The Serialization dialog opens.13. Select Increment.14. Click OK to close the Serialization dialog.15. Click Close to close the Barcode Properties dialog.

Commander 12

16. From the File menu, select Save As, and save the BarTender document under the nameSerialized.btw.

17. Close BarTender.

Create the Commander Task

1. Choose the network directory where the trigger files will be saved. This is the directory thatCommander will monitor. In this example, it will be called\\AssemblyLine\NextPart.

2. Create, in some other directory, a blank text file called “part.txt”.3. Open Commander.4. From the File menu, select New.5. From the Task menu, select Add to open the Task Options dialog.6. Enter "Each Part" (without the

quotation marks) as the taskName, and select File in theTrigger drop down list.

7. Click the Trigger tab, and in theFolder to Scan box, enter thepath of the directory thatCommander will monitor. This isthe same directory that youused in step 1, above.

8. Enter "part.txt" or just "*.txt" inthe Files to Scan for box. (Donot include the quotationmarks.)

9. Set the Detection Response toDelete File, because BarTenderwill not need to open and read the file.

10. Click the Commands tab, and in the first row of the Command Type column, selectBarTender from the dropdown list.

11. Click the button labeled "…" at the end of the row to open the BarTender CommandOptions dialog (opens on Documents tab). Note that there is initially just a /P parameterin the Command Parameters box. This tells BarTender to print.

Commander 13

12. Select the Documents tab, andselect the File(s) radio button. Enterthe path and file name forSerialized.btw. Note that an /AF=parameter has been added to theCommand Parameters box,identifying which BarTenderdocument to print.

13. Click OK to close the BarTenderCommand Options dialog, and thenclick OK to close the Task Optionsdialog.

14. In the File menu, select Save As, andsave the task list under the nameNewPart.tl.

Start Detection

1. From the Detection menu, select Start Detection.2. Test your configuration by copying the sample file, part.txt, into the directory that

Commander is monitoring.

Commander will:

l detect the file part.txtl delete itl launch BarTender behind the

scenes. (You won’t see theBarTender application open onyour desktop.)

BarTender will:

l open Serialized.btwl print the item

With this setup, you can have an inventory tracking application, or some other application,automatically create files named part.txt in the directory that Commander is monitoring, andBarTender will print out this item each time such a file is created.

Commander 14

Example 2: Print Item Using Trigger as Database

GoalThe goal of this example is to show, in detail, how Commander can use the trigger file, or message,itself as a data file. The file can contain one or more rows of delimited (or fixed-width) fields of datathat Commander reads and passes to BarTender. The latter uses the data to populate the fields onthe BarTender document at print-time.

Case ScenarioAt a mail order company, there is a need to print an item containing data from a sales record eachtime an order is packaged. The sales application generates a comma-delimited text file, and saves itin a directory that Commander has been set to monitor. Commander detects the file and instructsBarTender to get data from the file and print the item.

Implementation

NOTE: The files created in this example can be found in 2ndExample.zip insideCommanderExamples.zip located at:

ftp://ftp.seagullscientific.com/BarTender/Examples/Commander

Use them to verify that the files you create are correct.

Set Up a Sample Data File

1. Choose the network directory where the trigger files will be saved. This is the directory thatCommander will monitor. In this example, it will be called\\ShippingServer\NewOrders

2. Create, or obtain, a sample file that is structured and delimited exactly as the real datafiles will be. In this example, we will create a file in Notepad that will be namedorder.txt. It will contain a single line of comma-delimited data (as shown below). Thereare no hard carriage returns in the file.Around the Town,Jerome Davis,Buyer,1220 Governor Sq.,Haddonfield, Alberta,WA11DP,Canada,(171) 555-7788,(171) 555-6750

3. Save the sample file in the directory that you chose in step 1.

Create the BarTender Document

1. Open BarTender.2. From the File menu, select New. The New Document Wizard opens.3. Select Blank Template, then click Finish to close the New Document Wizard.4. From the File menu, select Print. The Print dialog opens.5. From the Name dropdown list, select the printer you want to use. Click Close.6. From the File menu, select Page Setup and configure your page as needed. When you're

finished, click OK.

Commander 15

7. From the File menu, select Database Connection Setup. The Add Database Connectionwizard opens.

8. In the Add Database Connection wizard, click Next.9. Select Text File, then click Next.

10. Enter the complete path and file name of the sample file you created, then click Next.11. From the Delimitation Type dropdown list, select Comma, then click Next.12. Select No when asked about the text file header.13. Click Finish to close the wizard.14. Click OK to close the Database Connection Setup dialog.15. From the Create menu, select Text. From the Text Objects dropdown list, select a type of

text object, and click on the template to add it.16. Right-click the text object, and select Properties. The Text Properties dialog opens.17. Click the Data Source tab, and click the Properties icon next to Type. The Change Data

Source Type Wizard opens.18. From the dropdown list, select Database Field. Click Next.19. From the Field Name dropdown, select Field 2 (because, in the sample, the second field

contains the buyer's name).20. In the Sample Data field, enter "buyer name" as the sample data, and click Finish to close

the wizard.21. Click Close to close the Text Properties dialog.22. If other text objects are needed, simply return to step 15, in each case assigning the

object to the appropriate field in the database. Otherwise, continue to step 23.23. From the File menu, select Save to save the BarTender document under the name

NewOrderAddress.btw.24. Move the sample database file, orders.txt, out of the directory that Commander will be

scanning.25. Close BarTender.

Create the Commander Task

1. Open Commander.2. From the Commander File menu, select New.3. From the Task menu, select Add to open the Task Options dialog.4. Enter "Each Order" (without the quotation marks) as the task Name.5. In the Trigger dropdown list, select File.6. Click the Trigger tab.7. In the Folder to Scan box, enter the path of the directory that Commander will monitor.

This is the same directory that you used in step 1 of Set Up a Sample Data File, above.8. Enter "order.txt" or just "*.txt" in the Files to Scan for box (without the quotation marks).

Commander 16

9. Set the Detection Response to Rename File, since BarTender cannot use the file as itsdatabase if Commander has deleted it.

10. Set the New Extension to "old" (without the quotation marks). This extension cannot bethe same one specified in Files to Scan for.

11. Click the Commands tab, and in the first row of the Command Type column, selectBarTender from the dropdown list.

12. Click the button labeled "…" at the end of the row to open the BarTender CommandOptions dialog. Note that there is initially just a /P parameter in the CommandParameters box. This tells BarTender to print.

13. Click the Documents tab, and select the File(s) radio button. Then enter the path and filename for NewOrderAddress.btw. Note that an /AF= parameter has been added to theCommand Parameters box, identifying which BarTender document to print.

14. Click the Text File tab and enable theText File check box, but leave thevalue at its default, %Trigger FileName%. A /D=%Trigger FileName% parameter has been addedto the Command Parameters boxtelling BarTender that it should usethe trigger file as its database.

15. Enable the Delete File When Donecheckbox to tell BarTender that itshould delete the file after reading it.A /DD parameter has been added tothe Command Parameters box.

16. Click OK to close the BarTenderCommand Options dialog.

17. Click OK to close the Task Optionsdialog.

18. From the File menu, select Save, and save the task list under the nameNewOrderAddress.tl.

Start Detection

1. From the Detection menu, select Start Detection.2. Test your setup by copying the sample file, orders.txt, back into the directory that

Commander is monitoring.

Commander will:

l detect the file orders.txtl rename it to orders.oldl launch BarTender behind the

BarTender will:

l open NewOrderAddress.btwl read data from orders.oldl print the item

Commander 17

scenes. (You won’t see theBarTender application open on yourdesktop.)

l delete orders.old

With this setup, you can have a sales-entry application, or some other application, automaticallycreate files named orders.txt (containing the data from the sale) in the directory thatCommander is monitoring, and BarTender will print out an item for each record in the file.

Commander 18

Example 3: Print Item Using Commander Script

GoalThe goal of this example is to explain how to include a special Commander script in a trigger file ormessage and configure Commander to use it.

Some companies have different applications and databases with printing needs, scatteredthroughout their network. In such cases, the BarTender document that should be printed can bevaried depending on the contents of the trigger file or message.

With little programming, these applications can be modified or configured to write data andcommand lines to a text file. That is why there is an option to have a Commander script embedded inthe trigger file along with the data. A Commander script is a set of written instructions thatCommander can read and execute.

This feature enables the application to give Commander instructions that vary from trigger to trigger,instead of having it perform exactly the same actions in response to every trigger of a given type.

Case ScenarioA company needs to print sticky-backed invoices that are entered by many different users acrosstheir network. Each user has access to a shared drive. However, there are differently formattedinvoices depending on the user and the product being invoiced. And the various departments eachuse their own printer.

In this situation, an invoicing application can create, with each invoice, a text file containing data anda Commander script that instructs BarTender to:

l open up a particular invoice *.btw file,l use the trigger file as the data file, starting on line 3,l print to a specific printer, andl delete the trigger file when it’s done.

Implementation

NOTE: The files created in this example can be found in 3rdExample.zip insideCommanderExamples.zip located at:

ftp://ftp.seagullscientific.com/BarTender/Examples/Commander

Use them to verify that the files you create are correct.

Set Up Sample Data Files

1. Choose the network directory where the trigger files will be saved. This is the directory thatCommander will monitor. In this example, it will be called\\InvoiceServer\CommanderWatch

Commander 19

2. For each type of invoice, create, or obtain, a sample file in which the data is structured anddelimited exactly as it will be in the real data files. In this example, we will assume thatthere are two departments printing invoices. For the first, create a file in Notepad namedinvoice1.txt that contains a single line of comma-delimited data (as shown below).The only hard carriage return is at the end of the record.Around the Town,Jerome Davis,Buyer,1220 Governor Sq.,Haddonfield, Alberta,WA11DP,Canada,(171) 555-7788,(171) 555-6750

3. For the second, create a file in Notepad named invoice2.txt that contains a singleline of quote-and-comma-delimited data (as shown below). The only hard carriage return isat the end of the record."Far Fetched Imports","Jerry Bom","manager","3320 HappySt.","Incident","Washington","98887","USA","(444) 555-7788","(444) 555-6750"

4. Save the sample files in the directory that you chose in step 1.

Create the BarTender Documents

1. Following the same steps as the Create the BarTender Document section of the previousexample, create a BarTender document for the first department, using invoice1.txt,created above, as the database. Use HardwareInvoice.btw as the document's filename.

2. Create a second BarTender document for the second department, using invoice2.txtas the database. (Be sure to indicate that the delimitation type is quote-and-comma.) UseSoftwareInvoice.btw as the BarTender document’s file name.

3. Move both sample database files from the directory that Commander will be scanning.4. Close BarTender.

Create the Commander Task

1. Open Commander.2. From the Commander File menu, select New.3. From the Task menu, select Add to open the Task Options dialog.4. Enter "Invoices" (without the quotation marks) as the task Name.5. From the Trigger dropdown list, select File.6. Click the Trigger tab.7. In the Folder to Scan box, enter the path of the directory that Commander will monitor.

This is the same directory that you used in step 1 of Set Up Sample Data Files, above.8. Enter "*.txt" in the Files to Scan for box. (Do not include the quotation marks.)9. Set the Detection Response to Rename File, since BarTender cannot use a file as a

database if Commander has deleted it.10. Set the New Extension to "old" (without the quotation marks). This extension cannot be

the same one specified in Files to Scan for.

Commander 20

11. Click the Commands tab, and in the first row of the Command Type column, selectCommander Script from the dropdown list.

12. Click OK to close the Task Options dialog.13. From the File menu, select Save, and save the file under the name

VariantInvoices.tl.

Creating Sample Trigger Files

1. Open the first sample database file, invoice1.txt, and add the following two lines to thevery beginning of the file. (The only hard carriage returns are immediately before andimmediately after %END%.)

%BTW% /AF=c:\command\HardwareInvoice.btw /D="%Trigger File Name%"/PRN="EasyCoder F4 (203 dpi)" /R=3 /P /DD%END%

So the entire file now contains the following:

%BTW% /AF=c:\command\HardwareInvoice.btw /D="%Trigger File Name%"/PRN="EasyCoder F4 (203 dpi)" /R=3 /P /DD%END%Around the Town,Jerome Davis,Buyer,1220 Governor Sq.,Haddonfield, Alberta,WA11DP,Canada,(171) 555-7788,(171) 555-6750

%BTW% is a Commander script command that tells Commander to launch BarTender andto use the string that follows as a BarTender command line. %END% tells Commander thatthe command line is finished and what follows is data.

Of course, you must substitute your own printer name in the Commander Script, if it isdifferent from EasyCoder F4 (203 dpi) and you must replace c:\command\ withthe path where you saved your *.btw files.

NOTE: If any of the paths, file names, or printer names used in yourCommander Script contain spaces, you must enclose the entire path inquotes.

Do not replace %Trigger File Name% with the name of the database file.Commander will recognize %Trigger File Name% as a variable on its own and it willautomatically replace it with the latest trigger file name before it passes the parameter toBarTender.

The /R=3 command tells BarTender to treat the third line in the trigger file as the datarecord, and the /P command tells BarTender to print the item. Finally, /DD tellsBarTender to delete the trigger file after reading it.

2. Open the second sample database file, invoice2.txt, and add lines to the very beginning ofthe file so that the resulting file reads as follows.

Commander 21

%BTW% /AF=c:\command\SoftwareInvoice.btw /D="%Trigger File Name%"/PRN="Datamax 4400" /R=3 /P /DD%END%"Far Fetched Imports","Jerry Bom","manager","3320 HappySt.","Incident","Washington","98887","USA","(444) 555-7788","(444) 555-6750"

Note that this example assumes that the SoftwareInvoice.btw will be printed to a differentprinter than HardwareInvoice.btw. In both trigger files, you should change the path andprinter name following the /PRN command, as needed.

Start Detection

1. From the Detection menu, select Start Detection.2. Copy the first sample file, invoice1.txt, back into the directory that Commander is

monitoring.

Commander will:

l detect the file invoice1.txtl rename it to invoice1.oldl launch BarTender behind the

scenes. (You won’t see theBarTender application open on yourdesktop.)

BarTender will:

l open HardwareInvoice.btwl read data from invoice1.oldl print the iteml delete invoice1.old

3. Copy the second sample file, invoice2.txt, back into the directory that Commander ismonitoring.

Commander will:

l detect the file invoice2.txtl rename it to invoice2.oldl launch BarTender behind the

scenes. (You won’t see theBarTender application open on yourdesktop.)

BarTender will:

l open SoftwareInvoice.btwl read data from invoice2.oldl print the iteml delete invoice2.old

Now you can have various invoice-creating applications automatically create files named *.txt inthe directory that Commander is monitoring. The files should begin with a Commander script anddata as in this example. Each time such a file is created in the directory, BarTender will print outthe document designated in the trigger file to the printer designated in the file.

Commander 22

Example 4: Print Item Using SAP R/3 IDoc File

GoalThe goal of this example is to show how a SAP™ (Systems, Applications, and Products in DataProcessing) IDoc can be used as the trigger file and the data source.

SAP is an enterprise-scale, customizable, workflow application. SAP's success is built on itsintegration features, which enable disparate third-party applications and incompatible databases toexchange information with each other. BarTender uses one of these integration technologies, calledIntermediate Documents (IDocs), to print data from any SAP-connected database onto print items.

IDocs are hierarchically structured text files, and they can be used to trigger Commander, which, inturn, can instruct BarTender to use the IDoc as its data source.

Case ScenarioA company with an inventory management database running on a mainframe needs to print itemsusing BarTender running on Windows PCs. Using SAP R/3, the company creates a system that readseach new record in the database and creates an IDoc file containing the data of the record.Commander detects each new IDoc and uses BarTender to read the desired data from the IDoc andprint the item.

Implementation

NOTE: The files created in this example can be found in 4thExample.zip insideCommanderExamples.zip located at:

ftp://ftp.seagullscientific.com/BarTender/Examples/Commander

Use them to verify that the files you create are correct.

Create a Sample IDoc

1. Choose the network directory where the IDoc files will be saved. This is the directory thatCommander will monitor. In this example, it will be called \\Inventory\IDocs.

2. Create, or obtain, a sample IDoc file of the same IDoc type as the IDocs that will be usedfor real data. Put it in the directory that you chose in step 1. In this example, we willassume that the IDoc type to be used is WTADDI01. As the sample file we will use IDD-LIEF03_00108227.WTADDI0_46C, which is installed with BarTender.

3. Save the sample file in the directory that you chose in step 1.

Create the BarTender Document

1. Open BarTender.2. From the File menu, select New. The New Document Wizard opens.3. Select Blank Template, then click Finish to close the New Document Wizard.4. From the File menu, select Print. The Print dialog opens.5. From the Name dropdown list, select the printer you want to use. Click Close.

Commander 23

6. From the File menu, select Page Setup and configure your page as needed. When you'refinished, click OK.

7. From the File menu, select Database Connection Setup. The Add Database Connectionwizard opens.

8. In the Add Database Connection wizard, click Next.9. Select SAP Intermediate Document (IDoc) File and click Next.

10. Select the IDoc Type Definition File from the dropdown list. In this example, the type isWTADDI01.

11. In the IDoc File (Optional) box, enter the complete path to the sample IDoc file. This is thesame directory that you choose in step 1 of Create a Sample IDoc.

12. Click Next.13. Select a Master Segment. In this example, we select the line segment E2WTADDl09000

(Additionals IDoc: Conditions).14. Click Next.15. On the Fields page of the wizard, click Add Fields.16. Select the fields you would like, and then click OK.17. Click Finish on the Database Connection Setup dialog.18. Click OK to close the Add Database Connection wizard19. From the Create menu, select Text. From the Text Objects dropdown list, select a type of

text object, and click on the template to add it.20. Right-click the text object, and select Properties. The Text Properties dialog opens.21. Click the Data Source tab, and click the Properties icon next to Type. The Change Data

Source Type Wizard opens.22. From the dropdown list, select Database Field. Click Next.23. Select a field to be the source for the text object, and then click Finish to close the wizard.24. Click Close to close the Text Properties dialog.25. From the File menu, select Save to save the BarTender document under the name

UsingSAPIDoc.btw.26. Verify the connectivity to the IDoc file by printing the item.27. Move the sample database file IDD-LIEF03_00108227.WTADDI0_46C out of the

directory that Commander will be scanning.28. Close BarTender.

Create the Task

1. Open Commander.2. From the Commander File menu, select New.3. From the Task menu, select Add to open the Task Options dialog.

Commander 24

4. Enter "New Item" (without thequotation marks) as the taskName.

5. In the Trigger dropdown list,select File.

6. Click the Trigger tab.7. In the Folder to Scan box, enter

the path of the directory thatCommander will monitor. This isthe same directory that youused in step 1 of Create aSample IDoc, above.

8. Enter “IDD-LIEF03_00108227.WTADDI0_46C" inthe Files to Scan for box(without the quotation marks).

9. Set the Detection Response to Rename File, since BarTender cannot use the file as itsdatabase if Commander has deleted it.

10. Set the New Extension to "old" (without the quotation marks). This extension cannot bethe same one specified in Files to Scan for.

11. Click the Commands tab, and in the first row of the Command Type column, selectBarTender from the dropdown list.

12. Click the button labeled “…“ at the end of the row to open the BarTender CommandOptions dialog. Note that there is initially just a /P parameter in the CommandParameters box. This tells BarTender to print.

13. Click the Documents tab, and select the File(s) radio button. Then enter the path and filename for UsingSAPIDoc.btw. Note that an /AF= parameter has been added to theCommand Parameters box, identifying for BarTender which BarTender document it shouldprint.

14. Click the SAP R/3 IDoc tab and enable the SAP R/3 IDoc File check box, but leave thevalue at its default, %Trigger File Name%. An /IDoc=%Trigger File Name%parameter has been added to the Command Parameters box telling BarTender that itshould use the trigger file as its database.

15. Enable the Delete File When Done checkbox to tell BarTender that it should delete thefile after reading it. A /DIDoc parameter has been added to the Command Parametersbox.

16. Click OK to close the BarTender Command Options dialog.

17. Click OK to close the Task Options dialog.

18. From the File menu, select Save, and save the task list under the name IDocReact.tl.

Commander 25

Start Detection

1. From the Detection menu, select Start Detection.2. Copy the sample file, IDD-LIEF03_00108227.WTADDI0_46C, back into the directory that

Commander is monitoring.

Commander will:

l detect the file IDD-LIEF03_00108227.WTADDI0_46C

l rename it to IDD-LIEF03_00108227.old

l launch BarTender behind thescenes. (You won’t see theBarTender application open on yourdesktop.)

BarTender will:

l open UsingSAPIDoc.btwl read data from IDD-LIEF03_

00108227.oldl print the iteml delete IDD-LIEF03_00108227.old

Commander 26

Related Documentation

White PapersGeneral White Papers

l The Advantage of Drivers by Seagulll Licensing for BarTender's Automation Editionsl Silent Install

Companion Applications

l Printer Maestro: True Enterprise Print Management for Windowsl Librarianl BarTender Security Centerl BarTender Web Print Server

Recent Upgrades

l What’s New in the Latest BarTender

For downloadable versions, visit:

www.seagullscientific.com/label-software/white-papers.aspx

Version 2016-09-27 Copyright © 2016 Seagull Scientific, Inc.