PUT

LANSA Integrator

PUT

The PUT command will send the contents of a local file to the remote FTP server.

The file specified by the FROM keyword is sent to the remote FTP server, using the DATALINK mode. The remote FTP server will store the file using the path specified by the TO keyword.

 

 PUT --------- FROM ------------- file path ---------------------->

 

           >-- TO --------------- file path ---------------------->

 

                                                           Optional

 

           >-- FROM_ENCODING ---- value -------------------------->

 

           >-- TO_ENCODING ------ value -------------------------->

 

           >-- CONVERT ---------- *NO ---------------------------->

                                  *YES

 

           >-- RECORD_SIZE ------ 1024 --------------------------->

                                  *NOMAX

                                  integer

 

           >-- RECORD_DELIMITER - *NONE -------------------------->

                                  *LF

                                  *CRLF

 

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

                                  *PORT

 

 

Keywords

FROM

Nominate the local file path to be copied to the remote FTP server. This value can be a relative or absolute path. If the path is relative, the current working directory is the JSM instance directory.

See Comments / Warnings below.

TO

Nominate the remote file path where the file is to be placed on the remote FTP server. This value can be a relative or absolute path. If the path is relative, the current working directory is the remote FTP server's current directory.

See also GETDIR command.

FROM_ENCODING

Encoding is used to convert the FROM file content to an intermediate Unicode string.

A default value is obtained from the 'from.encoding' property resource. If no property resource is located the value defaults to Cp037.

Only use this keyword when CONVERT is set as *YES.

TO_ENCODING

Encoding is used to convert the intermediate Unicode string to target encoding.
A default value is obtained from the 'to.encoding' property resource. If no property resource is located the value defaults to ISO8859_1.

Only use this keyword when CONVERT is set as *YES.

CONVERT

The default conversion value is *NO.

A value of *YES indicates that after each record size read, the data will be converted to the specified target encoding and sent to the FTP server.

RECORD_SIZE

The default value is 1024 bytes.

A value of *NOMAX sets the read size to the length of the source file.

Nominating an integer value specifies the read size, in bytes, to be used on the source file.

Refer to Comments / Warnings below.

RECORD_DELIMITER

The default value is *NONE.

A value is only required when keyword CONVERT is set as *YES. In this case the end of record marker to be added to the end of each converted record read can be nominated as either *LF (Line Feed) or *CRLF (Carriage Return, Line Feed).

For more information refer to 5.1.7 Carriage Return, Line Feed and New Line.

DATALINK

The DATALINK keyword determines how the "control" session is initiated. The default value is *PASV.

In passive mode, *PASV, the FTP the client initiates both connections to the remote FTP server. Passive mode causes the FTPService to send a PASV subcommand to the remote FTP server, the FTP server returns the port number of the socket server it has started and a data transfer channel is established from the local server using this port number. This is known as "Passive FTP" and is often used to get around firewall difficulties. Using "Passive" FTP the local server establishes the second connection, not the remote FTP server. Most firewalls will allow your computer to transfer files in this second connection to the remote FTP server (just as it allowed your computer to establish the first connection).

Port mode, *PORT, causes the FTPService to start a socket server and informs the remote FTP server via the PORT subcommand of the port number this socket server is listening on, the remote FTP server then connects to this socket server and a data transfer channel is established.

Refer to Technical Specification for more information.

Comments / Warnings

If the FROM file is an IBM i physical file:

  • The RECORD_SIZE must match the total record length of the file.
  • Use the DSPFD command to determine the total record length.
  • All fields in the file should be of type CHAR.
  • A deleted record in the file will be read as a blank record, so use the RGZPFM command to removed deleted records from the file.

Normal stream files can also be converted:

  • After each record size read the data is converted.
  • The FROM file content must be single byte encoded, unless the RECORD_SIZE (*NOMAX) option is used, in which case the file is processed in one read and the conversion is applied to the entire file content.
  • For more information refer to 5.1.7 Carriage Return, Line Feed and New Line.

Examples

RDML

 

CHANGE FIELD(#JSMCMD) TO('PUT FROM(order.xml) TO(/xmldata/order.xml)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

or

 

CHANGE FIELD(#JSMCMD) TO(PUT FROM(order.xml) TO('/xmldata/order.xml) CONVERT(*YES) FROM_ENCODING(ISO8859_1) TO_ENCODING(UTF-8)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

or

 

CHANGE FIELD(#JSMCMD) TO('PUT FROM(order.xml) TO(/xmldata/order.xml) CONVERT(*YES) RECORD_SIZE(*NOMAX) FROM_ENCODING(ISO8859_1) TO_ENCODING(UTF-8)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

From an IBM i file to a text file:

 

CHANGE FIELD(#JSMCMD) TO(PUT FROM('/QSYS.LIB/JSMLIB.LIB/[email protected]/[email protected]) TO(dcw29.txt) CONVERT(*YES) RECORD_SIZE(166) RECORD_DELIMTER(*CRLF) FROM_ENCODING(Cp037) TO_ENCODING(ISO8859_1)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

RDMLX

 

#jsmcmd := 'put from(' + #jsmfrom + ') to(' + #jsmto + ')'

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