LIST
The LIST command will return a list of file names found within a specified directory.
This command may be useful if a number of XML documents need to be processed. The command could be used to populate a working list with all the documents that have been placed in a specific directory, then place the READ, BIND, and GET commands with a SELECT_LIST working on this list.
LIST ------------- DIR --------- directory path ---------------->
>-- EXT --------- file extension ---------------->
>-- SORT -------- *NONE ------------------------->
*NAME
*MODIFIED
>-- REVERSE ----- *YES --------------------------|
*NO
Keywords
DIR |
This keyword is used to specify the directory that is to be searched. It is recommended to use the forward slash as the path separator and to avoid the use of the DOS drive designator. The format of the path should be as follows: For Windows you can specify:
For the IBM i you can specify:
This keyword is optional. |
EXT |
This keyword is used to filter the list returned based on the file extension. The filtering match is case insensitive. This keyword is optional. |
SORT |
The optional sort keyword allows sorting on file name or modified date. The default value is *NONE. |
REVERSE |
The optional reverse keyword allows the sorted order to be reversed. The default value is *NO. |
Comments / Warnings
If you do not specify the DIR value, then it will automatically return a list of files from the JSM instance directory.
Lists and Variables
This keyword requires a single field working list to receive the canonical file paths. To enable this, you should do the following:
1. Define a single field working list that will hold the returned list of files. The field needs to be long enough to hold the full canonical path and file name.
2. Use the SERVICE_LIST keyword with the LIST command. The service list value should include the name of the single field defined in the working list without the '#'.
3. In the TO_GET portion of the JSM_COMMAND Built-In Function, include the name of the working list defined above.
Examples
RDML
* Define the fields used by the JSM Commands
Define Field(#JSMSTS) Type(*CHAR) Length(020)
Define Field(#JSMMSG) Type(*CHAR) Length(256)
Define Field(#JSMCMD) Type(*CHAR) Length(256)
* Define field to hold file names
DEFINE FIELD(#FILENAME) TYPE(*CHAR) LENGTH(250)
DEF_LIST NAME(#FILELSTW) FIELDS(#FILENAME) COUNTER(#LISTCOUNT) TYPE(*WORKING)
#JSMCMD := 'LIST DIR(NEWORDERS) SERVICE_LIST(FILENAME) EXT(XML)'
USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG #FILELSTW)
RDMLX
* Define the fields used by the JSM Commands
Define Field(#JSMSTS) Type(*CHAR) Length(020)
Define Field(#JSMMSG) Type(*CHAR) Length(256)
Define Field(#JSMCMD) Type(*CHAR) Length(256)
Define Field(#JSMHND) Type(*CHAR) Length(4)
* Define field to hold file names
Define Field(#FILENAME) Type(*CHAR) Length(250)
Def_List Name(#FILELSTW) Fields(#FILENAME) Counter(#LISTCOUNT) Type(*WORKING)
#JSMCMD := 'LIST DIR(NEWORDERS) SERVICE_LIST(FILENAME) EXT(XML)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMHND #JSMCMD) To_Get(#JSMSTS #JSMMSG #FILELSTW)