The previous steps in this exercise have run the User Agent from Integrator Studio. In this step, you will execute the User Agent in batch mode to send the XLS file.
1. The files already created for the User Agent project are in a directory such as:
C:\Program Files\LANSA\Integrator\Studio\workspace\JMI Training\solutions\SendCSVFile
Copy these files from the above directory
SendCSVFile.lih
iii_employee_new_salary.xls
to the \User Agent\workspace folder, such as:
C:\Program Files\LANSA\Integrator\UserAgent\workspace
2. In the following steps you will use Notepad to create an iii_UPLOAD.BAT file in the directory where you installed the LANSA User Agent (by default C:\Program Files\LANSA\Integrator\UserAgent\workspace). The file iii_UPLOAD.BAT is a DOS batch file which will enable the user agent to be executed without a user interface, by passing the required parameters into the User Agent when the batch file is executed.
3. Open Notepad and open the file:
C:\Program Files\LANSA\Integrator\UserAgent\workspace\upload.bat
This is a shipped example batch file for running User Agent. The code should look like the following:
@echo off000clsrem --- Delete previous error log fileif exist useragent.err del useragent.errrem --- Sendjava -Djsf.log=\LANSA\Integrator\useragent\useragent.log com.lansa.jsf.useragent.JSFUserAgent acme.lih order.xls xls-order-response.rspif exist useragent.err goto errorrem --- Sendjava -Djsf.log=\LANSA\Integrator\useragent\useragent.log com.lansa.jsf.useragent.JSFUserAgent acme.lih order.csv csv-order-response.rspif exist useragent.err goto errorgoto endrem -- An error has occured:errorclsecho Check useragent.err for possible messagesecho Check useragent.log for possible messagesgoto end:end
Delete the second block of code between "rem --- Send" and "goto error" including this code. The supplied example assumes that the batch file will send two files. The code to delete, is shown in red in the program code above. Your code should now look like the following:
@echo offclsrem --- Delete previous error log fileif exist useragent.err del useragent.errrem --- Sendjava -Djsf.log=\LANSA\Integrator\useragent\useragent.log com.lansa.jsf.useragent.JSFUserAgent acme.lih order.xls xls-order-response.rspif exist useragent.err goto errorgoto endrem -- An error has occured:errorclsecho Check useragent.err for possible messagesecho Check useragent.log for possible messagesgoto end:end
4. The supplied code needs to be extended to operate on your PC. The code you enter will depend on the version of Windows you are using. The example provided here is for Windows 8.1 on a 64bit PC. Replace "java" at the start of the command line with a full path. Your code should look like the following. The new code is shown is highlighted.
rem --- SendC:\Program Files\Java\jre1.8.0_112\bin\JAVAW.EXE "-Djava.ext.dirs=..\lib\ext" "-Djava.endorsed.dirs=..\lib\endorsed" "-Djsf.log=.\useragent.log" com.lansa.jsf.useragent.JSFUserAgent acme.lih order.xls xls-order-response.rsp
5. The command line you are editing runs the User Agent in the Java runtime environment (JVM) passing a number of parameters such as the configuration file (.lih) to be used. The first parameter begins "-Djava.ext.dirs= . You need to insert into this parameter the path for the …\lib\ext folder.
Examine the folder C:\Program Files\Java. you may find it contains folders for a number of versions of Java, which were left in place when Java was updated.
Specify the path for the latest version of Java (or alternatively the actual Java version you have specified in your Integrator settings).
For example C:\Program Files\Java\jre1.8.0_112\lib\ext.
Add this path into the first parameter as shown. Changes are shown in red:
rem --- SendC:\Program Files\Java\jre1.8.0_112\bin\JAVAW.EXE "-Djava.ext.dirs= C:\Program Files\Java\jre1.8.0_112\lib\ext;.\lib\ext" "-Djava.endorsed.dirs=..\lib\endorsed" "-Djsf.log=.\useragent.log" com.lansa.jsf.useragent.JSFUserAgent acme.lih order.xls xls-order-response.rsp
6. This step will specify the correct runtime parameters for the configuration file(lih), the input file (xls) and the response file (csv).
Replace the end of the command string, starting from acme.lih, so that the command looks like the following. Ensure the file names used have your initials. The changes are shown in red:
rem --- SendC:\Program Files\Java\jre1.8.0_112\bin\JAVAW.EXE "-Djava.ext.dirs=C:\Program Files\Java\jre1.8.0_112\lib\ext;.\lib\ext" "-Djava.endorsed.dirs=..\lib\endorsed" "-Djsf.log=.\useragent.log" com.lansa.jsf.useragent.JSFUserAgent workspace\iiiSendCSVFile.lih workspace\iii_employee_new_salary.xls workspace\iii_employee_response.csv
7. The complete iii_upload.bat file should look like the following:
@echo off
cls
rem --- Delete previous error log file
if exist useragent.err del useragent.err
rem --- Send
C:\Program Files\Java\jre1.8.0_112\bin\JAVAW.EXE "-Djava.ext.dirs=C:\Program Files\Java\jre1.8.0_112\lib\ext;.\lib\ext" "-Djava.endorsed.dirs=..\lib\endorsed" "-Djsf.log=.\useragent.log" com.lansa.jsf.useragent.JSFUserAgent workspace\iiiSendCSVFile.lih workspace\iii_employee_new_salary.xls workspace\iii_employee_response.csv
if exist useragent.err goto error
goto end
rem -- An error has occured
:error
cls
echo Check useragent.err for possible messages
echo Check useragent.log for possible messages
goto end
:end
Note how the send instruction is composed of four parts:
The instruction to start the User Agent.
The first parameter - SendCSVFile.lih (how to find the service)
The second parameter - iii_Employee_New_Salary.xls (the data to be processed)
The third parameter - iii_employee_response.csv (the name of the file that will receive the response from the service)
8. In the File menu, select the Save As option using these options:
Save in | locate the directory where you installed the LANSA User Agent, by default ...\program files\lansa\integrator\UserAgent\ |
|---|---|
File Name | iii_UPLOAD.BAT |
Save as Type | All files |
9. Execute the iii_UPLOAD.BAT file. If successful, a file called iii_response.csv should be created in the directory …\UserAgent\workspace\. Windows will open this (CSV) file with Excel.
If you encounter a problem, the first thing to check is whether you can manually start the LANSA User Agent, load host SendCSVFile.lih, open source iii_Employee_New_Salary.xls, send, and receive a response. Refer to Step 5. Test iiiFN03 function for details.