IBM Books

Net.Data Reference

FFI Built-in Functions

DTWF_APPEND


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Writes the contents of a table variable to the end of a file.

The current contents of a file affect the results of using DTWF_APPEND, especially the contents of the last column of the last row. If a new-line character follows the last column value of the last row of the file, appended data is placed in a new row. Otherwise, appended data becomes part of the last row of the file.

Format

@DTWF_APPEND(filename, transform, delimiter, table, retry, rows)

@DTWF_APPEND(filename, transform, delimiter, table, retry)

@DTWF_APPEND(filename, transform, delimiter, table)

Values

Table 92. DTWF_APPEND Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to which the variable's contents are being added. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table IN The table variable from which the records are read.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

integer retry IN The number of times to retry if the file cannot be appended to immediately. The default is not to retry.
integer rows IN The maximum number of rows from table to append. The default is to append all the rows. Specifying 0 appends all rows.

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_APPEND(myFile, "DELIMITED", " ;", myTable)

Example 2:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_APPEND(myFile, "ASCIITEXT", " ;", myTable)

Example 3:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_APPEND(myFile, "ASCIITEXT", " ;", myTable, "0", "10")

DTWF_CLOSE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Closes a file opened by DTWF_OPEN.

Format

@DTWF_CLOSE(filename, retry)

@DTWF_CLOSE(filename)

Values

Table 93. DTWF_CLOSE Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to close. On successful completion of the call, this parameter returns the fully qualified file name.
integer retry IN The number of times to retry if the file cannot be closed immediately. The default is not to retry.

Examples

Example 1:

@DTWF_CLOSE(myFile, "5")

DTWF_DELETE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Deletes records from a file. (Does not delete empty files.)

Format

@DTWF_DELETE(filename, transform, delimiter, retry, rows, startrow)

@DTWF_DELETE(filename, transform, delimiter, retry, rows)

@DTWF_DELETE(filename, transform, delimiter, retry)

@DTWF_DELETE(filename, transform, delimiter)

Values

Table 94. DTW_DELETE Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file whose records are to be deleted. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
integer retry IN The number of times to retry if the records cannot be deleted immediately. The default is not to retry.
integer rows IN The maximum number of rows to delete. The default is to delete all the rows. Specifying 0 deletes all rows.
integer startrow INOUT The row number from which to begin deleting. A value of 1 means to begin deleting at the first row. If this value is greater than the number of rows in the file, the value is changed to the last record and returned as an error. The default is to start at 1.

Examples

Example 1:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myWait = "5000"
   myRows = "2"
%}
@DTWF_DELETE(myFile, "Delimited", "|", myWait, myRows)

Example 2:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myStart = "1"
   myRows = "2"
%}
@DTWF_DELETE(myFile, "Asciitext", "|", "0", myRows, myStart)

DTWF_INSERT


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Inserts records into a file.

Format

@DTWF_INSERT(filename, transform, delimiter, table, retry, rows, startrow)

@DTWF_INSERT(filename, transform, delimiter, table, retry, rows)

@DTWF_INSERT(filename, transform, delimiter, table, retry)

@DTWF_INSERT(filename, transform, delimiter, table)

Values

Table 95. DTWF_INSERT Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to which records are inserted. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table IN The table variable from which records are inserted into the file.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

integer retry IN The number of times to retry if the file cannot be written to immediately. The default is not to retry.
integer rows IN The maximum number of rows to insert from table. The default is to insert all the rows. A value of 0 inserts all the rows.
integer startrow INOUT The row number from which to begin inserting. Specifying 1 means to begin inserting at the first row. If this value is greater than the number of rows in the file, the value is changed to the last record and returned as an error. The default is to start at 1.

Examples

Example 1:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myWait = "3000"
%}
@DTWF_INSERT(myFile, "Delimited", "|", myTable, myWait)

Example 2:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myStart = "1"
   myRows = "2"
%}
@DTWF_INSERT(myFile, "Asciitext", "|", myTable, "0", myRows, myStart)

DTWF_OPEN


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Explicitly opens a file. When the file does not exist, an absolute path for the filename should be specified, and the directory where the file is to be created must match a directory specified in FFI_PATH. If an absolute path is not used, the file will be opened in the current working directory. DTWF_OPEN keeps the file open, otherwise, the file is closed after each flat file operation.

Performance tip: Use DTWF_OPEN to reduce the number of times a file is open.

The file is left open until it is closed using DTWF_CLOSE or macro processing ends.

Format

@DTWF_OPEN(filename, mode, retry)

@DTWF_OPEN(filename, mode)

Values

Table 96. DTWF_OPEN Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to open. On successful completion of the call, this parameter returns the fully qualified file name.
string mode IN The type of access requested:

  • r - opens an existing file for reading.

  • w - creates a file for writing. (Destroys existing file of same name, if it exists.)

  • a - opens a file for appending. Net.Data creates the file if it is not found.

  • r+ - opens an existing file for reading and writing.

  • w+ - creates a file for reading and writing. (Destroys existing file of same name, if it exists.)

  • a+ - opens a file in append mode for reading or appending. Net.Data creates the file if it is not found.
integer retry IN The number of times to retry if the file cannot be opened immediately. The default is not to retry.

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myMode = "r+"
%}
@DTWF_OPEN(myFile, myMode, "1000")

DTWF_READ


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Reads records from a file into a table variable.

Format

@DTWF_READ(filename, transform, delimiter, table, retry, rows, startrow, columns)

@DTWF_READ(filename, transform, delimiter, table, retry, rows, startrow)

@DTWF_READ(filename, transform, delimiter, table, retry, rows)

@DTWF_READ(filename, transform, delimiter, table, retry)

@DTWF_READ(filename, transform, delimiter, table)

Values

Table 97. DTWF_READ Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file whose records are read into a table variable. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table OUT The table variable into which the file records are read.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

integer retry IN The number of times to retry if the file cannot be read immediately. The default is not to retry.
integer rows INOUT The maximum number of file records to read into table. The default is to read all the records, or until the table is full. A value of 0 means to read until the end of the file. The number of rows in the resulting table is returned.
integer startrow IN The record in the file from which to start reading. The default is to start reading at the first record.
integer columns OUT Returns the number of columns in the table.

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
  myWait = "1000"
%}
@DTWF_READ(myFile, "DELIMITED", ";", myTable, myWait)

Example 2:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
  myWait = "0"
  myRows = "0"
  myStartrow = "1"
  myColumns = ""
%}
@DTWF_READ(myFile, "DELIMITED", ";", myTable, myWait, myRows,
             myStartrow, myColumns)

Example 3:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_READ(myFile, "ASCIITEXT", ";", myTable)
@DTW_TB_TABLE(myTable,"BORDER","")

DTWF_REMOVE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Deletes an entire file.

Format

@DTWF_REMOVE(filename, retry)

@DTWF_REMOVE(filename)

Values

Table 98. DTW_REMOVE Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to delete. On successful completion of the call, this parameter returns the fully qualified file name.
integer retry IN The number of times to retry if the file cannot be deleted immediately. The default is not to retry.

Examples

Example 1:

%DEFINE myFile = "c:/private/myfile"
@DTWF_REMOVE(myFile)

Example 2:

%DEFINE {
  myFile = "c:/private/myfile"
  myWait = "2000"
%}
@DTWF_REMOVE(myFile, myWait)

DTWF_SEARCH


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns result of a string search to a table variable.

Format

@DTWF_SEARCH(filename, transform, delimiter, table, searchFor, retry, rows, startrow)

@DTWF_SEARCH(filename, transform, delimiter, table, searchFor, retry, rows)

@DTWF_SEARCH(filename, transform, delimiter, table, searchFor, retry)

@DTWF_SEARCH(filename, transform, delimiter, table, searchFor)

Values

Table 99. DTWF_SEARCH Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to search. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table OUT The table variable into which the search results are placed. Three columns are returned if transform is DELIMITED:

  • The row in which the match was found.

  • The column in which the match was found.

  • The matching column from the file.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

string searchFor IN The string of characters to search for.
integer retry IN The number of times to retry if the file cannot be searched immediately. The default is not to retry.
integer rows INOUT The maximum number of rows to read into table. The default is to read all the rows or until table is full. Specifying 0 reads to the end of the file. The number of rows in the resulting table is returned by this parameter.
integer startrow IN The record in the file to start searching from. The default is 1, which begins the search at the first record.

Usage

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
  myWait = "1000"
  mySearch = "0123456789abcdef"
@DTWF_SEARCH(myFile, "DELIMITED", ";",
               myTable, mySearch, myWait)

Example 2:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
  mySearch = "answer:"
  myWait = "0"
  myRows = "0"
  myStartrow = "1"
%}
@DTWF_SEARCH(myFile, "DELIMITED", ";", myTable,
               mySearch, myWait, myRows, myStartrow)

DTWF_UPDATE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Updates records of a file from a table variable. When the file does not exist, an absolute path for the filename should be specified, and the directory where the file is to be created must match a directory specified in FFI_PATH. If an absolute path is not used, the file will be opened in the current working directory.

Format

@DTWF_UPDATE(filename, transform, delimiter, table, retry, rows, startrow)

@DTWF_UPDATE(filename, transform, delimiter, table, retry, rows)

@DTWF_UPDATE(filename, transform, delimiter, table, retry)

@DTWF_UPDATE(filename, transform, delimiter, table)

Values

Table 100. DTWF_UPDATE Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file whose records are updated from a table variable. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table IN The table variable from which the file records are updated.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

integer retry IN The number of times to retry if the file cannot be written to immediately. The default is not to retry.
integer rows IN The maximum number of records to be updated from table. The default is to update all the records. A value of 0 means to update all rows in the file.
integer startrow INOUT The first file record to update. The default is 1, which means to start updating at the beginning of the file. If the value is greater than the number of records in a file, the value is changed to indicate the number of the last record in the file and an error is returned.

Examples

Example 1:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myWait = "1500"
   myRows = "2"
%}
@DTWF_UPDATE(myFile, "Delimited", "|", myTable, myWait, myRows)

Example 2:

%DEFINE {
   myFile = "c:/private/myfile"
   myTable = %TABLE
   myStart = "1"
   myRows = "2"
%}
@DTWF_UPDATE(myFile, "Asciitext", "|", myTable, "0", myRows, myStart)

DTWF_WRITE


AIX HP-UX OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Writes the contents of a table variable to a file. When the file does not exist, an absolute path for the filename should be specified, and the directory where the file is to be created must match a directory specified in FFI_PATH. If an absolute path is not used, the file will be opened in the current working directory.

Format

@DTWF_WRITE(filename, transform, delimiter, table, retry, rows, startrow)

@DTWF_WRITE(filename, transform, delimiter, table, retry, rows)

@DTWF_WRITE(filename, transform, delimiter, table, retry)

@DTWF_WRITE(filename, transform, delimiter, table)

Values

Table 101. DTWF_WRITE Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file the records of the table variable are written to. On successful completion of the call, this parameter returns the fully qualified file name.
string transform IN The format of the file:

  • ASCIITEXT - writes the table to the file with a new-line character between column values and ignores the delimiter parameter.

  • DELIMITED - writes the table to the file with the delimiter specified in the delimiter parameter.
Net.Data macro table for ASCIITEXT and DELIMITED transforms.
string delimiter IN A character string to indicate the ends of values. This parameter is case sensitive. Ignored if transform is ASCIITEXT.
table table IN The table variable used to export rows to the file.

For non-OS/400 users: The maximum length of a row in an FFI table is 16383 characters. This limit includes a null character for each column in the Net.Data macro table.

integer retry IN The number of times to retry if the file cannot be written to immediately. The default is to not retry.
integer rows IN The maximum number of file records to write. The default is to write the entire table. A value of 0 means to write all records to the end of the file.
integer startrow INOUT The record number to start writing to in the file. The default is 1, which means to start at the first record. If a value beyond the end of the file is specified, the last row of the file is returned with an error.

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_WRITE(myFile, "DELIMITED", ";", myTable)

Example 2:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_WRITE(myFile, "ASCIITEXT", ";", myTable, "5000")

Example 3:

%DEFINE {
  myFile = "c:/private/myfile"
  myTable = %TABLE
%}
@DTWF_WRITE(myFile, "ASCIITEXT", ";", myTable, "5000", "10", "50")


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]