Previous Topic: DBCS Considerations When Using Files

Next Topic: Data Conversion and Unmapped Format UDBs

&FILE GET Statement and Unmapped Format UDBs

The &FILE GET statement is used to retrieve data from any type of UDB and when issued causes NCL to present data to the NCL procedure in a series of variables, or as an MDO.

It is only possible to use the MDO= operand for mapped format processing. As described earlier, if the UDB is a delimited format file, each variable on the &FILE GET statement is returned with the contents of field, where the fields are segments in the record delimited by X'FF'.

However, if the UDB is an unmapped format UDB, NCL cannot provide the data to the procedure as a set of individual fields-NCL has no knowledge of field boundaries within the record.

Therefore, for unmapped format UDBs, NCL treats the record read from a UDB as a single string and then splits this string into as many full-length variables as are required to hold all the data, or as many as are provided on the &FILE GET statement, whichever is the smaller number.

A full-length variable is 256 characters long. It is also possible to indicate explicitly how many bytes are to be placed into each variable.

For example:

&FILE GET ID=MYFILE VARS=(A(10),B(100),C(40))

indicates that the first 10 contiguous bytes of the record being read will be placed unchanged into the variable &A, the next 100 bytes will be placed into variable &B, the next 40 bytes will be placed into variable &C, and any remaining bytes will not be placed into any variable (that is, they will be ignored).

The following shows an example of using &FILE GET on an unmapped format file.

&FILE OPEN ID=MYFILE FORMAT=UNMAPPED
&FILE SET ID=MYFILE KEY= 'RECORD1
'&FILE GET ID=MYFILE ARGS
Record contents
|C1|C2|C3|15|C4|15|F3|C5|15|15|15|F1|15||C1|C2|C3|15|C4|15|F3|C5|15|15|15|F1|15|
:&1 contents after &FILE GET:
|C1|C2|C3|15|C4|15|F3|C5|15|15|15|F1|15||C1|C2|C3|15|C4|15|F3|C5|15|15|15|F1|15|