Presenting Data Values: Verbs

Topics:

You can present data in the reporting language using a choice of four display commands, commonly called verbs. You can use one or more verbs in a single request. Using multiple verbs in a single request is explained in Advanced Features. Each verb, PRINT, LIST, SUM, and COUNT, displays data in a unique way.

The following display commands display each record:

The following display commands process multiple records:

Displaying Field Values: PRINT

The PRINT command displays all the values for each field you specify. The values retrieved for each field appear in a column. The PRINT command, by default, uses the field name or the value for the TITLE attribute in the Master File to name each column. The columns automatically display in the same order you request them when you use PRINT.

To create a report request that displays employee identification numbers (EMP_ID field), last names (LAST_NAME field), and salaries (CURR_SAL field), issue the following request:

TABLE FILE EMPLOYEE
PRINT EMP_ID LAST_NAME CURR_SAL

To complete the request and run it, issue the following command on a line by itself:

END

You must always type the END command on its own line. When you use END to complete a request, you are indicating that you are finished using the data source you identified in the request, in this case, EMPLOYEE. Therefore, in order to start another request, you must identify the data source again using the TABLE FILE command.

To see statistics after running a request, such as the number of records retrieved and how many lines appear on the report, you can use the Message Viewer or Session Viewer, depending on the product you are using. This output is not displayed for every example in this Primer. The information is shown below, though:

NUMBER OF RECORDS IN TABLE=       12  LINES=      12

Run the request. The output is:

The report you produce shows field values displayed in columns from left to right in the same order in which you specified them in your request. Each column uses the field name or the value for the TITLE attribute in the Master File as its title. You can also specify edit options, such as date formats, floating dollar signs, commas, and zero suppression. Notice that alphanumeric data is left-justified and numeric data is right-justified.

Alphanumeric data consists of characters and/or digits that cannot be used in calculations. For example, the EMP_ID field consists of only numbers, yet the numbers are not the type you use in calculations. Therefore, the data stored in EMP_ID is alphanumeric.

Numeric data, which includes decimal and integer values, contain numbers for use in calculations. Field formats identify the type of data a field stores. You see that there is no apparent order to the values in this report. You learn how to organize, or sort values in Sorting Records.

Correcting Errors

When you run a request, error messages display when you make mistakes. Mistakes can be typos or using the wrong command format. To see an example of an error message, type the same request you just entered. But this time, include a typo by typing PRINTE, instead of PRINT.

The following message displays:

ERROR AT OR NEAR LINE      2  IN PROCEDURE procedure_name
(FOC002) A WORD IS NOT RECOGNIZED: PRINTE

Correct the word PRINT to fix the typo.

Listing Field Values: LIST

If you want to display the values for the field or fields you request in a numbered list, use LIST instead of PRINT. The LIST command numbers each row of data.

Issue the previous request, but use LIST instead of PRINT.

TABLE FILE EMPLOYEE
LIST EMP_ID LAST_NAME CURR_SAL
END

Run the request. The output is:

Notice that there is an additional column titled LIST, which includes a number for each row in the report. The contents and order of the columns remain the same. The only difference is that LIST numbered each row for you.

Adding Field Values: SUM

The SUM command adds the values of numeric fields. Because SUM acts on multiple records, it is known as an aggregating verb. If you use SUM with an alphanumeric field, only the last value retrieved for that field is displayed, by default. A command you can use interchangeably with SUM is WRITE. SUM is used in our examples.

Unlike PRINT and LIST, which display individual field values, SUM uses the values to create new information.

Issue the following request:

TABLE FILE EMPLOYEE
SUM CURR_SAL
END

Look at the statistics for this report. Even though there are 12 records, only one line of information is produced:

NUMBER OF RECORDS IN TABLE=       12  LINES=      1

Run the request. The output is:

SUM adds the values for CURR_SAL and produces one line of aggregated data, not individual values. This is why 12 records were retrieved, but only one line of data displays.

Counting Field Values: COUNT

The COUNT command, like SUM, is an aggregating verb. It uses data you select to create new information. The difference is that COUNT tells you the number of occurrences of values that exist for a field, instead of calculating the summed value. The values counted do not have to be unique. By default, the result of COUNT is limited to five (5) digits.

COUNT has the same effect on both alphanumeric and numeric fields. You can see how COUNT differs from SUM when you compare the following request and report to the ones you produced using SUM.

Issue the following request:

TABLE FILE EMPLOYEE 
COUNT CURR_SAL
END

Once again, the statistics indicate that the number of records exceeds the number of lines in the report.

NUMBER OF RECORDS IN TABLE=       12  LINES=      1

Run the request. The output is:

You have just completed several requests that show you the differences among the four verb commands available to you. Although the sample requests in this Primer use one verb command at a time, you can use up to 64 verbs in a single request. A brief description of a multi-verb request in included in Advanced Features.

WebFOCUS

Feedback