READ

LANSA Integrator

READ

The READ command processes the nominated FILE and returns the information in a working list (unless the SVTABLE keyword is used).

To read a file from the local file system only requires the FILE keyword.

To read a file from a remote file system using the FTP protocol requires the HOST keyword with appropriate USER, PASSWORD and access details for the remote server.

The service also determines the encoding to apply to the read byte content to convert it to Unicode content and determines if the Unicode data needs to be archived.

 

                                                           Required

 

 READ ---------- FILE ----------- file path ---------------------->

 

                                                        Conditional

 

             >-- HOST ----------- host:port ---------------------->

 

             >-- USER ----------- value -------------------------->

 

             >-- PASSWORD ------- value -------------------------->

 

             >-- NAMEFMT -------- none --------------------------->

                                  0

                                  1

 

             >-- DATALINK ------- *PASV -------------------------->

                                  *PORT

 

             >-- MODE ----------- *BINARY ------------------------>

                                  *ASCII

 

                                                           Optional

 

             >-- CONTENT -------- *CSV --------------------------->

                                  *TSV

                                  *SV

 

             >-- SEPARATOR ------ value -------------------------->

                                  *COMMA

                                  *SEMICOLON

                                  *TAB

                                  *TILDE

 

             >-- ENCODING ------- *DEFAULT ----------------------->

                                  value

 

             >-- SVROW ---------- value -------------------------->

 

             >-- SVROWLIMIT ----- value -------------------------->

                                  *NONE

                                  *LIST

                                  *AVAILABLE

 

             >-- SVMODE --------- *NONE -------------------------->

                                  *IGNORE

                                  *USE

 

             >-- SVHEAD --------- value -------------------------->

 

             >-- SVLABEL -------- value -------------------------->

 

             >-- SVTABLE -------- table name --------------------->

 

             >-- SVCOLUMN ------- value -------------------------->

 

             >-- NUMBERFORMAT --- *NONE -------------------------->

                                  *DEFAULT

                                  *CLIENT

                                  *USERAGENT

                                  value

 

             >-- ARCHIVE -------- file path ----------------------|

 

Keywords

FILE

Nominate the path and file name.

This value can be a relative or absolute path. If the path is relative, the current working directory is the JSM instance directory.

HOST

This keyword is only required when reading from a remote file system.

Nominate a FTP server to connect to. The FTP server can be specified as an IP address, nnn.nnn.nnn.nnn:port, or a domain name.

If a port number is not supplied on an IP address the default value 21 is used unless the keyword SECURE (*IMPLICIT) is used in which case the default port value is 990.

USER

Only required when reading from a remote file system.

PASSWORD

Only required when reading from a remote file system.

The password for the database server that corresponds to the USER keyword.

NAMEFMT

Only valid when reading from a remote file system.

A value of 0 indicates an IBM i path name format library/file.member is to be used.

A value of 1 indicates a Windows path name format /directory/directory/file is to be used.

DATALINK

Only valid when reading from a remote file system.

The possible values are *PASV (Passive) or *PORT (Port). *PASV is the default value.

MODE

Only valid when reading from a remote file system.

The default value is *BINARY. Use a value of *ASCII if required.

CONTENT

By default the nominated file is processed as *CSV.

Alternately the content can be processed as a Tab separated variables (*TSV) or separated by a variable (*SV) as specified in the separator keyword. If processing content that includes a separator variable, refer to the SEPARATOR, SVHEAD,  SVMODE, SVTABLE, SVCOLUMN, SVLABEL, NUMBERFORMAT, TRIM and TRUNCATE keywords for additional processing options.

The working list used to store the content must be defined with an appropriate number of columns to store the data.

SEPARATOR

This keyword is to indicate what character is used as a separator. The separator does not need to be defined if the content is indicated as *CSV or *TSV.

If the SEPARATOR keyword is present and no CONTENT keyword is supplied CONTENT(*SV) is assumed.

Refer to SEPARATOR for more information.

ENCODING

ENCODING is used to specify what encoding must be applied to a byte content to convert it to a Unicode string. The default value for the ENCODING keyword is *DEFAULT.

Refer to ENCODING for more information.

SVROW

The SVROW keyword is used to specify the starting data record row.

Refer to SVROW for more information,

SVROWLIMIT

The SVROWLIMIT keyword is used to specify the number of data records to read. The possible values are *NONE, *LIST, *AVAILABLE or an integer value.

Refer to SVROWLIMIT for more information.

SVMODE

The SVMODE keyword is used by content handlers and services that process separated value data to indicate how to handle the inbound separated value data.

Refer to  SVMODE for more information.

SVHEAD

The optional keyword SVHEAD is used to describe the field layout of the separated value data.

Refer to SVHEAD for more information.

SVTABLE

If the SVTABLE keyword is present then the separated variable file data is inserted into the specified table using the current database connection. If no value is provided for SVTABLE the file data is returned in the working list argument.

Refer to SVTABLE for more information.

SVCOLUMN

SVCOLUMN is only used in conjunction with the SVTABLE keyword. The SVCOLUMN separates value services to define the relational database columns. A look up on the service properties resource is done using the sv.column.{value}.

Refer to SVCOLUMN for more information.

SVLABEL

SVLABEL is only used in conjunction with the SVTABLE keyword. SVLABEL is used to include the keyword value as the first column value for database table inserts or as the where constraint for database table selects.

Refer to SVLABEL for more information.

NUMBERFORMAT

The optional keyword NUMBERFORMAT is used to handle numeric strings, where the decimal separator is not the decimal point character ".".

Refer to NUMBERFORMAT for more information.

ARCHIVE

Use the optional keyword ARCHIVE to nominate the path and file name used to archive content.

Refer to ARCHIVE for more information.

Examples

RDML

 

DEF_LIST NAME(#WRKLIST) FIELDS(#LINENUM #PARTNUM #PARTDSC #PARTAMT #PARTQTY) TYPE(*WORKING)

 

USE BUILTIN(JSM_COMMAND) WITH_ARGS('READ FILE(order.csv) SERVICE_LIST(LINENUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)') TO_GET(#JSMSTS #JSMMSG #WRKLIST)

 

or

 

USE BUILTIN(JSM_COMMAND) WITH_ARGS('READ FILE(order.csv) SEPARATOR(*TILDE) SERVICE_LIST(LINENUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)
') TO_GET(#JSMSTS #JSMMSG #WRKLIST)

 

or

 

USE BUILTIN(JSM_COMMAND) WITH_ARGS('READ FILE(order.csv) SVTABLE(ORD) SVCOLUMN(ORDER) SVLABEL(23)') TO_GET(#JSMSTS #JSMMSG)

 

RDMLX

 

#jsmcmd := 'read file(' + #jsmfile + ') content(*sv) separator(' + #separator + ')'

use builtin(jsmx_command) with_args(#jsmhandle #jsmcmd) to_get(#jsmsts #jsmmsg #valueslst)