Wednesday, August 26, 2009

(Tips) Copying data using Client Access Data Transfer Function

The Client Access Data Transfer applications have the advantage of an easy-to-follow graphical interface, and automatic numeric and character data conversion. However, Data Transfer requires the installation of the Client Access product and requires use of both PC and iSeries server resources and communications between the two.

If you have Client Access installed on the PC and your server, you can use the Data Transfer applications to transfer data between stream files and database files. You can also transfer data into a new database file based on an existing database file, into an externally-described database file, or into a new database file definition and file.

* Transfer data from a database file to a stream file.
* Transfer data from a stream file to a database file.
* Move data into a newly created database file definition and file.
* Create a format description file.

Transfer data from a database file to a stream file

To transfer a file from a database file to a stream file on your server:

1. Establish a connection to the server.
2. Map a network drive to the appropriate path in the iSeries file system.
3. Select the Data Transfer from AS/400 icon from the Client Access Express window.
4. Select the server you want to transfer from.
5. Select the file names, using the iSeries database library and file name to copy from, and the network drive for the location of the resulting stream file. You can also choose PC File Details to select the PC file format for the stream file. Data Transfer supports common PC file types, such as ASCII text, BIFF3, CSV, DIF, Tab-delimited Text, or WK4.
6. Click the Transfer data from AS/400 button to run the file transfer.

You can also perform this data movement in a batch job with the Data Transfer applications. Proceed as above, but select the File menu option to save the transfer request. The Data Transfer To AS/400 application creates a .DTT or a .TFR file. The Data Transfer from AS/400 application creates a .DTF or a .TTO file. In the Client Access directory, two programs can be run in batch from a command line:

* RTOPCB takes either a .DTF or a .TTO file as a parameter
* RFROMPCB takes either a .DTT or a .TFR file as a parameter

You can set either of these commands to run on a scheduled basis by using a scheduler application. For example, you can use the System Agent Tool (a part of the Microsoft Plus Pack) to specify the program to run (for instance, RTOPCB MYFILE.TTO) and the time at which you want to run the program.

Transfer data from a stream file to a database file

To transfer data from a stream file to a database file on your server:

1. Establish a connection to the server.
2. Map a network drive to the appropriate path in the iSeries file system.
3. Select the Data Transfer to AS/400 icon from the Client Access Express window.
4. Select the PC file name you want to transfer. For the PC file name, you can choose Browse for the network drive you assigned, and choose a stream file. You can also use a stream file located on the PC itself.
5. Select the server on which you want the externally described database file to be located.
6. Click the Transfer data to AS/400 button to run the file transfer.

Note: If you are moving data to an existing database file definition on the server, the Data Transfer To AS/400 application requires you to use an associated format description file (FDF). An FDF file describes the format of a stream file, and is created by the Data Transfer from AS/400 application when data is transferred from a database file to a stream file. To complete the transfer of data from a stream file to a database file, click the Transfer to AS/400 button. If an existing .FDF file is not available, you can quickly create an .FDF file.

You can also perform this data movement in a batch job with the Data Transfer applications. Proceed as above, but select the File menu option to save the transfer request. The Data Transfer To AS/400 application creates a .DTT or a .TFR file. The Data Transfer from AS/400 application creates a .DTF or a .TTO file. In the Client Access directory, two programs can be run in batch from a command line:

* RTOPCB takes either a .DTF or a .TTO file as a parameter
* RFROMPCB takes either a .DTT or a .TFR file as a parameter

You can set either of these commands to run on a scheduled basis by using a scheduler application. For example, you can use the System Agent Tool (a part of the Microsoft Plus Pack) to specify the program to run (for instance, RTOPCB MYFILE.TTO) and the time at which you want to run the program.

Move data into a newly created database file definition and file

To move data into a newly created database file definition and file:

1. Establish a connection to the server.
2. Map a network drive to the appropriate path in the iSeries file system.
3. Select the Data Transfer to AS/400 icon from the Client Access Express window.
4. Open the Tools menu of the Data Transfer to AS/400 application.
5. Select Create AS/400 database file.

A wizard will appear that allows you to create an new AS/400 database file from an existing PC file. You will be required to specify the name of the PC file from which the AS/400 file will be based, the name of the AS/400 file which to create, and several other necessary details. This tool parses a given stream file to determine the number, type, and size of the fields that are required in the resulting database file. The tool can then create the database file definition on your server.

Integrated File System Introduction

Create a format description file

If you are moving data to an existing database file definition on the server, the Data Transfer To AS/400 application requires you to use an associated format description file (FDF). An FDF file describes the format of a stream file, and is created by the Data Transfer from AS/400 application when data is transferred from a database file to a stream file. To create a .FDF file:

1. Create an externally described database file with a format that matches your source stream file (number of fields, types of data).
2. Create one temporary data record within the database file.
3. Use the Data Transfer from AS/400 function to create a stream file and its associated .FDF file from this database file.
4. Now, you can use the Data Transfer to AS/400, and specify this .FDF file with the source stream file you want to transfer.


Source : Iseries Information Center

Read More...

Monday, August 17, 2009

(Tips) AS/400 Built In Functions %EOF

%EOF returns ’1’ if the most recent read operation or write to a subfile ended in an
end of file or beginning of file condition; otherwise, it returns ’0’.
The operations that set %EOF are:
“READ (Read a Record)”
“READC (Read Next Changed Record)”
“READE (Read Equal Key)”
“READP (Read Prior Record)”
“READPE (Read Prior Equal)”
“WRITE (Create New Records)” subfile only).

The following operations, if successful, set %EOF(filename) off. If the operation is
not successful, %EOF(filename) is not changed. %EOF with no parameter is not
changed by these operations.
“CHAIN (Random Retrieval from a File)”
“OPEN (Open File for Processing)”
“SETGT (Set Greater Than)”
“SETLL (Set Lower Limit)”

When a full-procedural file is specified, this function returns ’1’ if the previous
operation in the list above, for the specified file, resulted in an end of file or
beginning of file condition. For primary and secondary files, %EOF is available
only if the file name is specified. It is set to ’1’ if the most recent input operation
during *GETIN processing resulted in an end of file or beginning of file condition.
Otherwise, it returns ’0’.

This function is allowed for input, update, and record-address files; and for display
files allowing WRITE to subfile records.

Read More...

Saturday, August 15, 2009

(Tips) AS/400 Built In Functions %Equal

%EQUAL (Return Exact Match Condition)
%EQUAL returns ’1’ if the most recent relevant operation found an exact match;
otherwise, it returns ’0’.

The operations that set %EQUAL are:
“SETLL (Set Lower Limit)”
“LOOKUP (Look Up a Table or Array Element)”

If %EQUAL is used without the optional file_name parameter, then it returns the
value set for the most recent relevant operation.

For the SETLL operation, this function returns ’1’ if a record is present whose key
or relative record number is equal to the search argument.

For the LOOKUP operation with the EQ indicator specified, this function returns
’1’ if an element is found that exactly matches the search argument.

If a file name is specified, this function applies to the most recent SETLL operation
for the specified file.

Examples:

Read More...

(Tips) AS/400 Built In Functions %Found

%FOUND (Return Found Condition)
%FOUND returns ’1’ if the most recent relevant file operation found a record, a
string operation found a match, or a search operation found an element.
Otherwise, this function returns ’0’.

The operations that set %FOUND are:
File operations:
– “CHAIN (Random Retrieval from a File)”
– “DELETE (Delete Record)”
– “SETGT (Set Greater Than)”
– “SETLL (Set Lower Limit)”

String operations:
– “CHECK (Check Characters)”
– “CHECKR (Check Reverse)”
– “SCAN (Scan String)”
Note: Built-in function %SCAN does not change the value of %FOUND.

Search operations:
– “LOOKUP (Look Up a Table or Array Element)”

If %FOUND is used without the optional file_name parameter, then it returns the
value set for the most recent relevant operation. When a file_name is specified,
then it applies to the most recent relevant operation on that file.

For file operations, %FOUND is opposite in function to the ″no record found NR″
indicator.

For string operations, %FOUND is the same in function as the ″found FD″
indicator.

For the LOOKUP operation, %FOUND returns ’1’ if the operation found an
element satisfying the search conditions.

Examples:


Read More...