Step 1. Build the Basic JSM functions
INT003 - Using the FTP Service
In this step, you will create a function which contains the basic RDMLX code required for your JSM functions. This function will be created using the JSMXSKEL template. You will build your function using repository fields which were imported for the SET218 example.
1. Create a new LANSA process named iiiPRO02 JSM Process, where iii is your unique 3 characters. (If the process already exists, select a different set of characters for iii.).
2. Create a new function named iiiFN03, belonging to process iiiFN02. The function will retrieve a list of files using the FTP Service. Make sure the JSMXSKEL as your template.
option is selected hoose3. Answer the template questions as shown in the table following:
Question |
Answer |
Comments |
Do you wish to load a JSM Service? |
FTPSERVICE |
|
4. At the beginning of your function, define two fields - W_TYPE defined as an Alpha field, length 1 and W_FILE defined as an Alpha field, length 80. These fields are required by the List JSM command of the FTP service.
Your RDMLX code might appear as follows:
* Working Fields
DEFINE FIELD(#W_TYPE) TYPE(*CHAR) LENGTH(1) DESC('Type of file')
DEFINE FIELD(#W_FILE) TYPE(*CHAR) LENGTH(80) COLHDG('File Name')
5. Right after the working field definitions, define a working list which will be used to receive the list of files returned by the FTP service.
- The working list should be named WL_218.
- Make sure to increase the default value for the ENTRYS parameter to, say, 500.
- Use fields W_TYPE and W_FILE as the working list entry fields.
Your RDMLX code might appear as follows:
* Working list to receive list of files
DEF_LIST NAME(#WL_218) FIELDS(#W_TYPE #W_FILE) TYPE(*WORKING) ENTRYS(500)
6. Specify WL_218 as a receive list in the Function statement:
FUNCTION OPTIONS(*DIRECT) RCV_LIST(#WL_218)
7. Save function iiiFN03
8. Create a new function named iiiFN04 Display FTP Service, belonging to process iiiPRO02, where iii is your unique 3 characters. Make sure the 'Enabled for RDMLX' box is NOT checked.,Do not choose a template.
9. Copy the definitions of fields W_TYPE and W_FILE and working list WL_218 from iiiFN03.
10.Define a browse list which will be used to display the list of files returned in W_218.
- The browse list should be named BL_218.
- Use the field W_FILE as the only browse list entry field.
Your code might appear as follows:
DEFINE FIELD(#W_TYPE) TYPE(*CHAR) LENGTH(1) DESC('Type of file')
DEFINE FIELD(#W_FILE) TYPE(*CHAR) LENGTH(80) COLHDG('File Name')
DEF_LIST NAME(#WL_218) FIELDS(#W_TYPE #W_FILE) TYPE(*WORKING) ENTRYS(500)
DEF_LIST NAME(#BL_218) FIELDS(#W_FILE) ENTRYS(500)
11.Create a GROUP_BY for the input fields (S_218HOST, S_218DIR, S_218USER, S_218PSWD) to appear on the screen panel. (These fields were imported with the SET Examples)
Your RDMLX code might appear as follows:
* Group for all input fields
GROUP_BY NAME(#GB_PNLDTA) FIELDS(#S_218HOST #S_218DIR #S_218USER #S_218PSWD)
If field S_218DIR is not defined, define it in your function as *CHAR, length 200:
DEFINE FIELD(#S_218DIR) TYPE(*CHAR) LENGTH(200) DESC('FTP Directory')
If you needed to define S_218DIR in iiiFN04, copy this definition back to iiiFN03 as well.
12.After the function definitions, add the following logic to the function:
a. Insert BEGIN_LOOP and END_LOOP commands.
b. Inside the loop, insert a REQUEST command to request the GB_PNLDTA group of fields and include the browse list BL_218.
c. Clear both the working and browse list.
d. Exchange fields Group GB_PNLDTA.
e. Call iiiFN03, passing the working list WL_218.
f. Loop through the working list and add entries to the browselist
Your code might appear as follows:
BEGIN_LOOP
REQUEST FIELDS(#GB_PNLDTA) BROWSELIST(#BL_218)
CLR_LIST NAMED(#WL_218)
CLR_LIST NAMED(#BL_218)
EXCHANGE FIELDS(#GB_PNLDTA)
CALL PROCESS(*DIRECT) FUNCTION(IIIFN03) PASS_LST(#WL_218)
SELECTLIST NAMED(#WL_218)
ADD_ENTRY TO_LIST(#BL_218)
ENDSELECT
END_LOOP
13.Compile function iiiFN04.