Step 1. Build the Basic JSM functions

INT002 - 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 need to be created if they do not exist in your system.

1.Check if fields below are defined in the Repository as these fields are required for this exercise. If these fields do not exist, you must create them as follows.  Even if they do exist, ensure they all allow lower case characters to be entered. 

2.  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.).

3.  Create a new function named iiiFN02 Use FTP Service, belonging to process iiiPRO02. The function will retrieve a list of files using the FTP Service. Make sure the Enabled for RDMLX option is selected. Choose JSMXSKEL as your template.

4.  Answer the template questions as shown in the table following:

Question

Answer

Comments

Do you wish to load a JSM Service?

FTPSERVICE

 

 

5.  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')

 

6.  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.

     Your RDMLX code might appear as follows:

* Working list to receive list of files

DEF_LIST NAME(#WL_FILES) FIELDS(#W_TYPE #W_FILE) TYPE(*WORKING) ENTRYS(*max)

 

7.  Specify WL_FILES as a receive list in the Function statement:

FUNCTION OPTIONS(*DIRECT) RCV_LIST(#WL_FILES)

8.  Save function iiiFN02

9.  Create a new Form/Basic Form named iiiFRM02 – Display FTP Service, where iii is your unique 3 characters. 

10. Copy the definitions of fields W_TYPE and W_FILE and working list WL_FILES from iiiFN02.

11. Drag a List View control onto your form which will be used to display the list of files returned in WL_FILES.

     Your code might appear as follows:

Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(301) Componentversion(2) Left(839) Top(285)

Define_Com Class(#PRIM_LTVW) Name(#ListView1) Columnbuttonheight(27) Componentversion(2) Displayposition(1) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(56) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(1) Top(37) Height(228) Width(393)

Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView1) Source(#STD_QSEL) Widthtype(Remainder)

 

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_FILES) Fields(#W_TYPE #W_FILE) Type(*WORKING) Entrys(*MAX)

 

Evtroutine Handling(#com_owner.CreateInstance)

 

Set Com(#com_owner) Caption(*component_desc)

 

Endroutine

 

End_Com

12. Drag the fields S_HOST, S_DIR, S_USER, S_PSWD onto the form above the List View control.  Adjust the size and position of the List View control as needed. 

13. Drag a Push Button control onto the form, give it a caption of Connect and add a click event.

14. In the click event handler, add the logic to perform the following:

Clear both the working and the List View control

Exchange fields S_HOST, S_DIR, S_USER, S_PSWD.

Call iiiFN02, passing the working list WL_FILES.

Loop through the working list and add entries to the List View control after you have set STD_QSEL to W_FILE.

     Your code might appear as follows:

CLR_LIST NAMED(#WL_FILES)

CLR_LIST NAMED(#ListView1)

EXCHANGE FIELDS(#S_HOST #S_DIR #S_USER #S_PSWD)

CALL PROCESS(*DIRECT) FUNCTION(IIIFN02) PASS_LST(#WL_FILES)

SELECTLIST NAMED(#WL_FILES)

#STD_QSEL := #W_FILE

ADD_ENTRY TO_LIST(#ListView1)

ENDSELECT

 

15. Compile form iiiFRM02.