INT003 - Using the LANSA User Agent
In this step, you will modify function iiiFN03 to ignore the column headings and map the data using the fields defined in the working list S_RECEIVE
1. Edit function iiiFN03.
Locate the definition of the working list used to receive the data from the User Agent. The working list is called #S_RECEIVE and it might appear as follows:
DEF_LIST NAME(#S_RECEIVE) FIELDS(#EMPNO #SALARY) TYPE(*WORKING)
2. Modify the definition of S_RECEIVE so that it matches the format of the CSV file. Your code might appear as follows:
DEF_LIST NAME(#S_RECEIVE) FIELDS(#EMPNO #SALARY #STARTDTER #DEPTMENT #SECTION) TYPE(*WORKING)
3. Locate the commands that execute the KEYWRD subroutine to build the RECEIVE command. Change the value of the SVMODE keyword to *IGNORE. One example of why you might use *IGNORE is when the column headings are not LANSA field names. For example, the server might receive a CSV file where the column heading use the label 'Employee Number' instead of the field name EMPNO.
Your code might appear as follows:
CHANGE FIELD(#JSMXCMD) TO(RECEIVE)
EXECUTE SUBROUTINE(KEYWRD) WITH_PARMS(#JSMXCMD HANDLER InboundSeparatedValue)
EXECUTE SUBROUTINE(KEYWRD) WITH_PARMS(#JSMXCMD SVMODE '*IGNORE')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMSTS #JSMMSG #S_RECEIVE)
4. Compile function iiiFN03.
5. Use the User Agent to test the function as before. The result should be exactly the same.
6. Optional. Edit your CSV file to contain column headings such as "Number, Annual Salary, Start Date, Department, Section Code" and save your changes. If the User Agent is still open, use File / Close Source and then open your modified CSV file and send it. Once again, you should get the same results.