LANSA User Agent - Batch File Conversion and Upload
Example 235 - Rating: specific
In this example the user creates a simple CSV file of employee numbers. The LANSA User
Agent is then is invoked in batch mode to upload the file to a LANSA function (SET235S) running on an iSeries. SET235S then reads the list of employees and produces a report detailing everything known about the employees. The spool file of the report is then returned to the client system as a single column CSV file. The client can then review and/or print the results
Detailed Notes and Suggestions
1. The series of events is initiated by the execution of bat file SET_235_Upload.bat. (The bat file can be executed by a program or by a user double clicking on the .bat file, from windows explorer.) The execution of SET_235_Upload.bat starts the LANSA User Agent and points it to a host configuration file (SET_235_CSV.lih) , an input data file (SET_235_Employees_to_report_on.csv), and a file name for any response from the server (SET_235_Response.csv). The LANSA User Agent looks up the file type of csv in configuration file SET_235_CSV.lih, and determines that this type of file is processed by service SET_235_CSV at the web server ip address. As a result the LANSA User agent sends an instruction to JSM Direct to start service SET_235_CSV on the iSeries. JSM looks up service SET_235_CSV on file DC@W29 and identifies it as function SET235S in process SET_235 in partition <ppp>. JSM starts function SET235S.
2. Function SET235S starts by opening JSM and then requesting the load of the HTTPClient service. (This is a service shipped with JSM)
3. Function SET235S then requests the data to be processed (the file of employee numbers). It does this with a JSM RECEIVE command. The original .csv file is sent to JSM, which passes it on to function SET235S. The handler that function SET235S specifies for the RECEIVE (handler ISVL) automatically converts the .csv data into a working list (#S_LSTRCV).
3a. Function SET235S reads through the received list of employees, gets their details from the server database, and produces a report of the details. It then reads the spool file produced and writes the report spool file data into a new working list (#S_LSTSND). This working list containing the report will be sent back to the user.
4. Function SET235S requests that the new list #S_LSTSND be returned to the LANSA User Agent using the JSM SEND command. The SEND, using hander ISVL, automatically converts the list into csv format and passes it back to the LANSA User Agent. The LANSA User Agent automatically writes out the received data to the file name specified in the original .bat file.
5. Function SET235S requests close and ends.
This Example Also Demonstrates:
Example 235 - Rating: specific
The Things that Make Up this Example | To Execute this Example |
In this example the user creates a simple CSV file of employee numbers. The LANSA User
Agent is then is invoked in batch mode to upload the file to a LANSA function (SET235S) running on an iSeries. SET235S then reads the list of employees and produces a report detailing everything known about the employees. The spool file of the report is then returned to the client system as a single column CSV file. The client can then review and/or print the results
Detailed Notes and Suggestions
1. The series of events is initiated by the execution of bat file SET_235_Upload.bat. (The bat file can be executed by a program or by a user double clicking on the .bat file, from windows explorer.) The execution of SET_235_Upload.bat starts the LANSA User Agent and points it to a host configuration file (SET_235_CSV.lih) , an input data file (SET_235_Employees_to_report_on.csv), and a file name for any response from the server (SET_235_Response.csv). The LANSA User Agent looks up the file type of csv in configuration file SET_235_CSV.lih, and determines that this type of file is processed by service SET_235_CSV at the web server ip address. As a result the LANSA User agent sends an instruction to JSM Direct to start service SET_235_CSV on the iSeries. JSM looks up service SET_235_CSV on file DC@W29 and identifies it as function SET235S in process SET_235 in partition <ppp>. JSM starts function SET235S.
2. Function SET235S starts by opening JSM and then requesting the load of the HTTPClient service. (This is a service shipped with JSM)
3. Function SET235S then requests the data to be processed (the file of employee numbers). It does this with a JSM RECEIVE command. The original .csv file is sent to JSM, which passes it on to function SET235S. The handler that function SET235S specifies for the RECEIVE (handler ISVL) automatically converts the .csv data into a working list (#S_LSTRCV).
3a. Function SET235S reads through the received list of employees, gets their details from the server database, and produces a report of the details. It then reads the spool file produced and writes the report spool file data into a new working list (#S_LSTSND). This working list containing the report will be sent back to the user.
4. Function SET235S requests that the new list #S_LSTSND be returned to the LANSA User Agent using the JSM SEND command. The SEND, using hander ISVL, automatically converts the list into csv format and passes it back to the LANSA User Agent. The LANSA User Agent automatically writes out the received data to the file name specified in the original .bat file.
5. Function SET235S requests close and ends.
This Example Also Demonstrates:
- How to access spool files produced by web server jobs
- How to invoke the LANSA User Agent from a .bat file
- How to avoid losing leading spaces in JSM transfers of .csv data
- The LANSA User Agent and JSM provide an easy, standard method of uploading data from the user’s PC into LANSA functions running on the iSeries, and vice versa.
Example 235 | JSM |
upload | LANSA User Agent |