LANSA User Agent - Interactive File Conversion and Upload using JSM Direct

LANSA

LANSA User Agent - Interactive File Conversion and Upload using JSM Direct
Example 233 - Rating: specific
The Things that Make Up this ExampleTo Execute this Example

In this example the end user starts the LANSA user agent on the PC and uses it to load an Excel spreadsheet containing a list of employee numbers and new salaries, convert it to Comma Separated Values (CSV) format, and send it to LANSA server function SET233S on the iSeries. SET233S receives the .CSV file into a working list and then reads the list, updates the salaries on the iSeries database, and passes back a confirmation of the employees’ new salaries along the same path.







Sending an Excel Spreadsheet to a Server Function Using the LANSA User Agent

The user starts the LANSA User Agent, selects the host SET_233_CSV.lih and then selects an excel spreadsheet file, containing employee numbers and their new salaries, to send to the server:



The LANSA User agent converts the file to csv format and displays it. The user then chooses the Send option of the File menu and the .csv data is sent to the server function running on the iSeries, via JSM Direct.



The server function, SET233S, processes the salary increases sent to it, and sends back a response. The response from the server is displayed on the response tab:



and the user is able to save this data to clipboard, or as a .csv file, by right mouse clicking on any field:



Detailed Notes and Suggestions





1 The end-user initiates a series of events by pressing the send button in the LANSA User Agent. The LANSA User Agent looks up the file type of .xls in configuration file SET_233_CSV.lih, and determines that this type of file is processed by service SET_233_CSV at the web server ip address. As a result the LANSA User agent sends an instruction to JSM Direct to start service SET_233_CSV on the iSeries. JSM looks up service SET_233_CSV on file DC@W29 and identifies it as function SET233S in process SET_233 in partition <ppp>. JSM starts function SET233S.

2. Function SET233S starts by opening JSM and then requesting the load of the HTTPClient service. (This is a service shipped with JSM)

3. Function SET233S then requests the data to be processed (the file of employee numbers and new salaries). It does this with a JSM RECEIVE command. The original .xls file is converted by the LANSA user agent to comma separated values format, and sent to JSM, which passes it on to function SET233S. The handler that function SET233S specifies for the RECEIVE (handler ISVL) automatically converts the .csv data into a working list (#S_LSTRCV).

3a. Function SET233S reads through the received list of employees and the new salaries for those employees, updates the employee salaries in PSLMST, and writes an entry for each in a new working list (#S_LSTSND). This working list will be sent back to the user, to indicate the success or failure of the updates.

4. Function SET233S 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 displays the returned data in the response tab. From there, the end user can save the data as a .csv file, on their PC.

5. Function SET233S requests close and ends.

This Example Is Useful Because:
  • 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.
Keywords
Example 233JSM
JSM DirectLANSA User Agent
LANSA Integrator