Referring to Fields in a Report Request

In this section:

When creating a report, you refer to fields in several parts of the request-for example, in display commands (PRINT, SUM), in sort phrases (BY, ACROSS), and in selection criteria (WHERE, WHERE TOTAL, IF).

Several methods are available for referring to a field. You can:

You can also view a list of all the fields that are included in a data source, or a specified Master File. For details, see Displaying a List of Field Names and Listing Field Names, Aliases, and Format Information.


Top of page

x
Referring to an Individual Field

You can refer to an individual field in any one of the following ways:



Example: Referring to an Individual Field

In the following requests, DEPARTMENT is the complete field name, DPT is the alias, and DEP is a unique truncation of DEPARTMENT. All these examples produce the same output.

 
1. TABLE FILE EMPLOYEE
   PRINT DEPARTMENT
   END
  
2. TABLE FILE EMPLOYEE
   PRINT DPT
   END
  
3. TABLE FILE EMPLOYEE
   PRINT DEP
   END

Note: If you use a truncation that is not unique, the following message appears:

(FOC016) THE TRUNCATED FIELDNAME IS NOT UNIQUE : D

Top of page

x
Referring to Fields Using Qualified Field Names

In a request, you can qualify field names with the Master File name and/or the segment name. Field names are always displayed as column titles in reports, unless a TITLE attribute or an AS phrase is used to provide an alternative name. For related information, see Customizing Tabular Reports.

You may use the file name, segment name, or both as a qualifier for a specified field. This is useful when structures contain duplicate field names. All referenced field names and aliases may be qualified.



Example: Using a Qualified Field Name to Refer to a Field
EMPLOYEE.EMPINFO.EMP_ID

Is the fully-qualified name of the field EMP_ID in the EMPINFO segment of the EMPLOYEE file.


Top of page

x
Referring to All of the Fields in a Segment

If you want to generate a report that displays all of a segment's fields, you can refer to the complete segment without specifying every field. You only need to specify one field in the segment-any field will do-prefixed with the SEG. operator.



Example: Referring to All Fields in a Segment

The segment PRODS01in the GGPRODS Master File contains the PRODUCT_ID, PRODUCT_DESCRIPTION, VENDOR_CODE, VENDOR_NAME, PACKAGE_TYPE, SIZE, and UNIT_PRICE fields.

SEGMENT=PRODS01
FIELDNAME = PRODUCT_ID
FIELDNAME = PRODUCT_DESCRIPTION
FIELDNAME = VENDOR_CODE
FIELDNAME = VENDOR_NAME
FIELDNAME = PACKAGE_TYPE
FIELDNAME = SIZE
FIELDNAME = UNIT_PRICE

To write a report that includes data from every field in the segment, you can issue either of the following requests:

 
1. TABLE FILE GGPRODS
   PRINT PRODUCT_ID AND PRODUCT_DESCRIPTION AND VENDOR_CODE AND
   VENDOR_NAME AND PACKAGE_TYPE AND SIZE AND UNIT_PRICE
   END
  
2. TABLE FILE GGPRODS
   PRINT SEG.PRODUCT_ID
   END

Top of page

x
Displaying a List of Field Names

If you want to see a list of all the fields that are included in a data source, you can issue the ?F field name query.

This is useful if you need to refer to a list of field names, or check the spelling of a field name. It also shows you the entire field name. More information on all of the query (?) commands appears in the Developing Applications manual.


Top of page

x
Listing Field Names, Aliases, and Format Information

The ?FF query displays field name, alias, and format information for a specified Master File, grouped by segment. Like the ?F query, you may issue ?FF:

Note:


Information Builders