Copyright © TIBCO Software Inc. All Rights Reserved

> Second Tutorial Example
> The modifyexample.txt script shows how to call Java methods from inside the FTP scripts and how to execute a batch/shell program before sending the file to the FTP server. The batch/shell program calls a Java program that modifies the document by adding CRLF (\r\n) at the end of the document. The executePutCmd method is then executed to store the file at the FTP server.
> This example is a demonstration that Java classes can be called from scripts at runtime and external programs can be called by using the Java runtime class.
> How modifyexample.txt Works
> This script is the same as putexample.txt except for one minor change. Before connecting to the FTP server, the source file name, which is a reference to the file that is stored locally before the script execution takes place, is sent to the executeProgram method in the RunProgram class. This method sends the fileName reference to a batch/shell program BC_HOME\samples\bc\ftpscripts\bcfilemodifier.bat. The batch file/shell program calls the Java class ModifyFile, which adds a CRLF at the end of the document file that is being transferred to the FTP server. Once the file is modified it is stored on the FTP server that is available to the trading partner.
> If you want to perform a full round trip of your transaction, you can upload mgetexample.txt from the first example to retrieve the files from the FTP server so that the Responder trading partner can process the document that was uploaded after the modification.
> Tutorial Files
> The following files are part of this tutorial:

> • | BC_HOME\samples\bc\ftpscripts\modifyexample.txt

> • | BC_HOME\samples\bc\ftpscripts\ftpexample.jar

> Setting Up the Second Tutorial
> The following steps are necessary to set up this tutorial:

> 1. | Configure the participants and business agreement on the Initiator following the procedure described in Setting Up the First Tutorial.

> Note, however, that in Step 11 when selecting the uploaded script file for the file processing, you must select the BC_HOME\samples\bc\ftpscripts\modifyexample.txt file.

> 2. | Stop the BusinessConnect server.

> 3. | Copy ftpexample.jar to BC_HOME/hotfix/lib.

> 4. | Add these two properties in the .tra file in the directory TIBCO_HOME/tra/domain/domain/application/BusinessConnect directory. There is a .tra file for every BusinessConnect engine.

> − | java.property.bc.user.execProgramName=bcfilemodifier

> − | java.property.bc.user.execProgramDir= %BC_HOME%\samples\bc\ftpscripts

> Running the Second Tutorial Example
> To run modifyexample:

> 1. | Start the BusinessConnect server.

> 2. | Send a document using one of the mechanisms described in Running the First Tutorial Example.

> Expected Results
> You can notice that the file that is transferred to the FTP server location contains the extra CRLF. If you are trying to process this document on the Responder, there is extra CRLF at the end of the file.

Copyright © TIBCO Software Inc. All Rights Reserved