$FDef: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $FDEF to $FDef: Lower case change)
m (misc formatting)
Line 1: Line 1:
<p>The $FDEF function lets you access the attributes of a field from within a <var class="product">Model&nbsp;204</var> procedure. $FDEF maps the attributes of a field, whose values can then be read via an image similar to the ZFIELD image described in [[#$FDEF|$FDEF]]. Unlike $DSCR, which $FDEF supplants, the attributes are displayed in a readable fashion without parsing. $FDEF works only for files (not groups).</p>
<p>
<b>Syntax</b>
The <var>$FDef</var> function lets you access the attributes of a field from within a <var class="product">Model&nbsp;204</var> procedure. <var>$FDef</var> maps the attributes of a field, whose values can then be read via an image similar to the ZFIELD image described below in [[#The ZFIELD image|The ZFIELD image]]. Unlike <var>$Dscr</var>, which <var>$FDef</var> supplants, the attributes are displayed in a readable fashion without parsing. <var>$FDef</var> works only for files (not groups). </p>
<p>The format for the $FDEF function is:</p>
 
<p class="syntax">%<span class="term">image</span>:<span class="term">item</span> = $FDEF(<var>[</var>FILE<var>]</var> <span class="term">filename</span> <var>[</var>AT <span class="term">location</span><var>]</var>, fieldname)
==Syntax==
<p>
The format for the <var>$FDef</var> function is:
</p>
</p>
<p>where:</p>
<p class="syntax">%<span class="term">image</span>:<span class="term">item</span> = $FDef(<var>[</var>File<var>]</var> <span class="term">filename</span> <var>[</var>At <span class="term">location</span><var>]</var>, fieldname)
</p>
<p>
Where:</p>
<ul>
<ul>
<li>%<var class="term">image</var>:<var class="term">item</var> is the image item to which $FDEF returns the data.</li>
<li>%<var class="term">image</var>:<var class="term">item</var> is the image item to which <var>$FDef</var> returns the data. </li>
</li>
 
<li><var class="term">filename</var> is a %variable or a literal name of the file. A file synonym name can also be used. When <var class="term">filename</var>=<var class="term">groupname</var> the $FDEF function assumes that the name passed is a file name, not a group name.</li>
<li><var class="term">filename</var> is a %variable or a literal name of the file. A file synonym name can also be used. When <var class="term">filename</var>=<var class="term">groupname</var> the <var>$FDef</var> function assumes that the name passed is a file name, not a group name. </li>
</li>
<li><var class="term">location</var> is the name of the remote node where the file is located.</li>
<li><var class="term">location</var> is the name of the remote node where the file is located. </li>
</li>
<li><var class="term">fieldname</var> is a %variable or a literal name of the field to be described.</li>
<li><var class="term">fieldname</var> is a %variable or a literal name of the field to be described. </li>
</li>
</ul>
</ul>
<p>If the field specified in the $FDEF argument is not defined in the opened file specified by filename, $FDEF returns a U (undefined) in the second image item (DEFER.Y_N). If the file is not open, a U is returned in the second (DEFER.Y_N) image item and an N is returned in the third (FRV.Y_N) image item.</p>
<p>
<p>FIELD.CODE, which is returned in the 21st image item, is unique for each field within a file. However, this value cannot remain constant for any one field over time, and it cannot be the same for the same field name in different files. Field names do not always hash to the same field codes because of deleted fields and hash collisions. FIELD.CODE, which is returned in the ZFIELD image, is the same as that which appears in CCAJRNL RECTYPE=6 entries. This information is valuable for Technical Support in case you need to run REGENERATE but cannot because you are missing one or more CCAJRNL data sets since your last DUMP of the file.</p>
If the field specified in the <var>$FDef</var> argument is not defined in the opened file specified by filename, <var>$FDef</var> returns a <code>U</code> (undefined) in the second image item (<code>DEFER.Y_N</code>). If the file is not open, a <code>U</code> is returned in the second (<code>DEFER.Y_N</code>) image item, and an <code>N</code> is returned in the third (<code>FRV.Y_N</code>) image item.</p>
<b>The ZFIELD image</b>
<p>
<p>An image is required by the $FDEF and $LSTFLD functions. The ZFIELD image, which can give you complete field attribute information (see the $FDEF example below), is provided by the <var class="product">Model&nbsp;204</var> installation software. </p>
<code>FIELD.CODE</code>, which is returned in the 21st image item, is unique for each field within a file. However, this value cannot remain constant for any one field over time, and it cannot be the same for the same field name in different files. Field names do not always hash to the same field codes because of deleted fields and hash collisions. </p>
<p class="note"><b>Note:</b> When using ZFIELD, be aware that $FDEF output maps to the image of ZFIELD. Therefore, do not change the order of the image items in ZFIELD.</p>
<p>
<p>The location of ZFIELD for your site is listed in this table: </p>
The <code>FIELD.CODE</code> returned in the ZFIELD image is the same as that which appears in CCAJRNL <code>RECTYPE=6</code> entries. This information is valuable for Technical Support in case you need to run <var>REGENERATE</var> but cannot because you are missing one or more CCAJRNL data sets since your last <var>DUMP</var> of the file. </p>
 
==The ZFIELD image==
<p>
An image is required by the <var>$FDef</var> and <var>$LstFld</var> functions. The ZFIELD image, which can give you complete field attribute information (see [[#ZFIELD image for $FDEF and $LSTFLD|ZFIELD image for $FDEF and $LSTFLD]], below), is provided by the <var class="product">Model&nbsp;204</var> installation software.  
</p>
<p class="note"><b>Note:</b> When using ZFIELD, be aware that <var>$FDef</var> output maps to the ZFIELD image. Therefore, do not change the order of the image items in ZFIELD. </p>
<p>
The location of ZFIELD for your site is listed in this table: </p>
<table>
<table>
<tr class="head">
<tr class="head">
<th>IF your site runs under...</th>
<th>If your site runs under...</th>
<th>THEN the ZFIELD image is stored in...</th>
<th>Then the ZFIELD image is stored in...</th>
</tr>
</tr>
<tr>
<tr>
<td>z/OS</td>
<td>z/OS</td>
<td>The JCL library</td>
<td>The JCL library</td>
</tr>
</tr>
<tr>
<tr>
<td>z/VM</td>
<td>z/VM</td>
<td>On the 193 MAINT204 disk</td>
<td>On the 193 MAINT204 disk</td>
</tr>
</tr>
<tr>
<tr>
<td>z/VSE</td>
<td>z/VSE</td>
Line 39: Line 54:
</tr>
</tr>
</table>
</table>
<b>Example</b>
 
<p>In the example on the next page, you provide a field name and <var class="product">Model&nbsp;204</var> displays output that indicates if the field is KEY or preallocated. If the field is preallocated, <var class="product">Model&nbsp;204</var> also displays the number of occurrences and the length of the field. This procedure maps the $FDEF output to the ZFIELD image (shown on the following page). Therefore, if the field is KEY, then the KEY.Y_N image item contains a 'Y'.</p>
===Example===
<p>
In the following example, you provide a field name and <var class="product">Model&nbsp;204</var> displays output that indicates if the field is <var>KEY</var> or preallocated. If the field is preallocated, <var class="product">Model&nbsp;204</var> also displays the number of occurrences and the length of the field. This procedure maps the <var>$FDef</var> output to the ZFIELD image (shown in the following section). Therefore, if the field is <var>KEY</var>, then the <code>KEY.Y_N</code> image item contains a <code>Y</code>.  
</p>
<p class="code">PROCEDURE DISPFLD
<p class="code">PROCEDURE DISPFLD
OPEN DAILY
OPEN DAILY
Line 48: Line 66:
%FIELD IS STRING LEN 50
%FIELD IS STRING LEN 50
%FIELD = $READ('ENTER FIELDNAME')  
%FIELD = $READ('ENTER FIELDNAME')  
<b></b>*                                                     *
<b></b>*                                                           *
<b></b>* include the ZFIELD proc and prepare the ZFIELD image *
<b></b>* include the ZFIELD proc and prepare the ZFIELD image     *
<b></b>*                                                     *
<b></b>*                                                           *
INCLUDE ZFIELD
INCLUDE ZFIELD
PREPARE IMAGE ZFIELD
PREPARE IMAGE ZFIELD
<b></b>*                                                     *
<b></b>*                                                           *
<b></b>* use the FDEF image item in ZFIELD to check the fieldname  *
<b></b>* use the FDEF image item in ZFIELD to check the fieldname  *
<b></b>*                                                     *
<b></b>*                                                           *
%ZFIELD:FDEF = $FDEF('VEHICLES',%FIELD)  
%ZFIELD:FDEF = $FDEF('VEHICLES',%FIELD)  
IF %ZFIELD:KEY.Y_N = 'Y' THEN
IF %ZFIELD:KEY.Y_N = 'Y' THEN
Line 71: Line 89:
END
END
</p>
</p>
<p>The following is the output produced by the procedure DISPFLD for the field DEDUCTIBLE:</p>
<p>
<p class="code">INCLUDE DISPFLD
The following is the output produced by the procedure <code>DISPFLD</code> for the field <code>DEDUCTIBLE</code>: </p>
<p class="output">INCLUDE DISPFLD


??ENTER FIELD NAME
??ENTER FIELD NAME
Line 80: Line 99:
THE LENGTH OF DEDUCTIBLE IS 3
THE LENGTH OF DEDUCTIBLE IS 3
</p>
</p>
<b>ZFIELD image for $FDEF and $LSTFLD</b>
 
<p>The following image can be used by the $FDEF and $LSTFLD functions. If you write your own image, be aware that $FDEF maps to the locations of the image items, rather than the names.</p>
===ZFIELD image for $FDEF and $LSTFLD===
<p>
The following image can be used by the <var>$FDef</var> and <var>$LstFld</var> functions. If you write your own image, be aware that <var>$FDef</var> maps to the locations of the image items, rather than the names.  
</p>
<p class="code">IMAGE ZFIELD
<p class="code">IMAGE ZFIELD
NAME                IS STRING LEN 255
NAME                IS STRING LEN 255

Revision as of 19:59, 5 June 2018

The $FDef function lets you access the attributes of a field from within a Model 204 procedure. $FDef maps the attributes of a field, whose values can then be read via an image similar to the ZFIELD image described below in The ZFIELD image. Unlike $Dscr, which $FDef supplants, the attributes are displayed in a readable fashion without parsing. $FDef works only for files (not groups).

Syntax

The format for the $FDef function is:

%image:item = $FDef([File] filename [At location], fieldname)

Where:

  • %image:item is the image item to which $FDef returns the data.
  • filename is a %variable or a literal name of the file. A file synonym name can also be used. When filename=groupname the $FDef function assumes that the name passed is a file name, not a group name.
  • location is the name of the remote node where the file is located.
  • fieldname is a %variable or a literal name of the field to be described.

If the field specified in the $FDef argument is not defined in the opened file specified by filename, $FDef returns a U (undefined) in the second image item (DEFER.Y_N). If the file is not open, a U is returned in the second (DEFER.Y_N) image item, and an N is returned in the third (FRV.Y_N) image item.

FIELD.CODE, which is returned in the 21st image item, is unique for each field within a file. However, this value cannot remain constant for any one field over time, and it cannot be the same for the same field name in different files. Field names do not always hash to the same field codes because of deleted fields and hash collisions.

The FIELD.CODE returned in the ZFIELD image is the same as that which appears in CCAJRNL RECTYPE=6 entries. This information is valuable for Technical Support in case you need to run REGENERATE but cannot because you are missing one or more CCAJRNL data sets since your last DUMP of the file.

The ZFIELD image

An image is required by the $FDef and $LstFld functions. The ZFIELD image, which can give you complete field attribute information (see ZFIELD image for $FDEF and $LSTFLD, below), is provided by the Model 204 installation software.

Note: When using ZFIELD, be aware that $FDef output maps to the ZFIELD image. Therefore, do not change the order of the image items in ZFIELD.

The location of ZFIELD for your site is listed in this table:

If your site runs under... Then the ZFIELD image is stored in...
z/OS The JCL library
z/VM On the 193 MAINT204 disk
z/VSE The JCL library

Example

In the following example, you provide a field name and Model 204 displays output that indicates if the field is KEY or preallocated. If the field is preallocated, Model 204 also displays the number of occurrences and the length of the field. This procedure maps the $FDef output to the ZFIELD image (shown in the following section). Therefore, if the field is KEY, then the KEY.Y_N image item contains a Y.

PROCEDURE DISPFLD OPEN DAILY OPENC VEHICLES XXXX BEGIN %FIELD IS STRING LEN 50 %FIELD = $READ('ENTER FIELDNAME') * * * include the ZFIELD proc and prepare the ZFIELD image * * * INCLUDE ZFIELD PREPARE IMAGE ZFIELD * * * use the FDEF image item in ZFIELD to check the fieldname * * * %ZFIELD:FDEF = $FDEF('VEHICLES',%FIELD) IF %ZFIELD:KEY.Y_N = 'Y' THEN PRINT %FIELD ' IS KEY' ELSE PRINT %FIELD ' IS NOT A KEY FIELD' END IF IF %ZFIELD:OCCURS > '0' THEN PRINT %FIELD ' IS PREALLOCATED, WITH ' - %ZFIELD:OCCURS ' VALUES' PRINT 'THE LENGTH OF ' %FIELD ' IS ' %ZFIELD:LENGTH ELSE PRINT %FIELD ' IS NOT PREALLOCATED' END IF END

The following is the output produced by the procedure DISPFLD for the field DEDUCTIBLE:

INCLUDE DISPFLD ??ENTER FIELD NAME DEDUCTIBLE DEDUCTIBLE IS KEY DEDUCTIBLE IS PREALLOCATED WITH 1 VALUES THE LENGTH OF DEDUCTIBLE IS 3

ZFIELD image for $FDEF and $LSTFLD

The following image can be used by the $FDef and $LstFld functions. If you write your own image, be aware that $FDef maps to the locations of the image items, rather than the names.

IMAGE ZFIELD NAME IS STRING LEN 255 DEFER.Y_N IS STRING LEN 1 FRV.Y_N IS STRING LEN 1 KEY.Y_N IS STRING LEN 1 MANY.VALUED.Y_N IS STRING LEN 1 CODED.Y_N IS STRING LEN 1 STRING.Y_N IS STRING LEN 1 NUMERIC.RANGE.Y_N IS STRING LEN 1 INVISIBLE.Y_N IS STRING LEN 1 SECURED.Y_N IS STRING LEN 1 UPDATE.IN.PLACE.Y_N IS STRING LEN 1 OCCURS.Y_N IS STRING LEN 1 FLOAT.Y_N IS STRING LEN 1 ORD.NUM.Y_N IS STRING LEN 1 ORD.CHAR.Y_N IS STRING LEN 1 PURE.DBCS.Y_N IS STRING LEN 1 MIXED.DBCS.Y_N IS STRING LEN 1 UNIQUE.Y_N IS STRING LEN 1 OCCURS.ONCE.Y_N IS STRING LEN 1 CLOB.Y_N IS STRING LEN 1 BLOB.Y_N IS STRING LEN 1 FUTURE.EXPANSION IS STRING LEN 34 FIELD.CODE IS BINARY LEN 4 UNSIGNED ORDERED.Y_N IS STRING LEN 1 LENGTH IS BINARY LEN 1 UNSIGNED LEVEL IS BINARY LEN 1 UNSIGNED LRESERVE IS BINARY LEN 1 UNSIGNED NRESERVE IS BINARY LEN 1 UNSIGNED SPLITPCT IS BINARY LEN 1 UNSIGNED NO.OF.IMMEDIATES IS BINARY LEN 1 UNSIGNED OCCURS IS BINARY LEN 1 UNSIGNED PAD.CHAR IS STRING LEN 1 FDEF IS STRING LEN 67 AT DEFER.Y_N BIN1 IS BINARY LEN 4 UNSIGNED BIN2 IS BINARY LEN 4 UNSIGNED BIN3 IS BINARY LEN 4 UNSIGNED BIN4 IS BINARY LEN 4 UNSIGNED LOOPVAR IS STRING LEN 16 AT BIN1 END IMAGE