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.
S_HOST ALPHA(100) - Host
S_USER ALPHA(20) - User
S_PSWD ALPHA(20) - Password
S_DIR ALPHA(200) – Directory
Answer the template questions as shown in the table following:
Question | Answer | Comments |
|---|---|---|
Do you wish to load a JSM Service? | FTPSERVICE |
* Working FieldsDEFINE FIELD(#W_TYPE) TYPE(*CHAR) LENGTH(1) DESC('Type of file')
The working list should be named WL_FILES.
Change the value for the ENTRYS parameter to *MAX.
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_FILES) FIELDS(#W_TYPE #W_FILE) TYPE(*WORKING) ENTRYS(*max)
FUNCTION OPTIONS(*DIRECT) RCV_LIST(#WL_FILES)
Save function iiiFN02.
Drag the field STD_QSEL onto the List View.
Set the WidthType to Remainder.
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
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
Compile form iiiFRM02.