1. Introduction

The following report presents some AS/400 File Transfer utilities that allow an easies integration with Linux or Unix or PCs applications.

Data transfers between separate machines can easily be performed with FTP, but , when AS/400 and Linux/Unix/PC machines are involved, some data format conversion is often required as described below:

  • The AS/400 uses the EBCDIC character set, whereas Linux, Unix and PC machines use ASCII. The conversion is normally done automatically by FTP.
  • Numbers are often stored on the AS400 in Packed Decimal format (2 digits per byte) that is not directly supported by Linux, Unix and PC. Packed decimal fields must therefore be unpacked when copying data for Linux.
  • In the AS/400 files the decimal point is implied according to the field definition. For instance if a field is 11 digits long with 2 decimals, no decimal point exists in the epresentation of the numbers, but the system automatically treats the last 2 digits as decimals. When numeric fields with decimals must be transferred to Linux, an explicit decimal point must be added in the correct position.

It is normally difficult to use direct transfers, because of packed fields and fixed length field requirements on the AS/400 files described above.

We have therefore developed some utilities that allow to make easier transfers from AS/400 database files to stream files and from stream files to the AS/400 database files.

2. Database File to Stream File Copy

The utility consists of a command (UCRTFTPFIL) and some programs that perform all needed data conversions. The AS/400 packed fields are converted into numeric fields and
an explicit decimal point is added when there are decimals. Moreover a field separator is added to identify the end of each field.

The command prompts the command parameters in the following mask:

Create FTP File command

It should be noticed that the user can select the separator (e.g. the pipe character) and the decimal point to use (dot or comma).

3. Stream File to Database File Copy

The utility assumes that the stream file contains fields separated by a separator. It is not requested to have the fields in the same sequence as those on the AS/400 database file.

The mapping of the fields can be entered by using the utility program UFMAP01L, that displays the following screen:

Field Mapping Utility command

When one select one row by entering a ‘2’, the program displays a list of the fields in database files and allows to enter the sequence number of the corresponding field on the stream file (described on the screen as FTP file because it is normally received by FTP).

See the example below:

Field Mapping display

In the example above, the field number 1 of the stream file (see From FldNo) is mapped to the field CT0010 of the AS/400 database file, the field number 2 is mapped to CT0030 and the field number 3 is mapped to CT0020.

Once the mappings have been defined, it is possible to perform the copy by using the command UCPYFTP that prompts the user for the following data:

Copy to Stream File command

Also in this case the user is required to specify the separator and the decimal point used for the numbers.

It should be mentioned that the field mappings must be specified only once for each couple of files and that the copy command uses them automatically.

You can download the AS/400 and Linux/Unix/PC File Transfer Utilities from:

==> Utilities Download Page

Incoming search terms for the article: