Using Temporary Fields With DEFINE

Topics:

If you want to use a temporary field in a report request for a session, as if it were a real field in the data source, you create it using the DEFINE command before writing the report request.

The basic format of a DEFINE command is:

DEFINE FILE filename
field/format=expression;
.
.
.
END

In this structure, filename represents the name of the data source you are using. Field is the name you give the temporary field you are creating. You define the field format with a slash (/) and the desired format. On the right side of the equation, expression represents a formula you specify that indicates how to calculate values for the new field. You complete the DEFINE command with the command END. A DEFINE command alone does not produce any display on your screen.

To illustrate the difference between creating temporary fields using DEFINE and COMPUTE, you now create FULL_NAME using DEFINE.

Issue the following DEFINE command:

DEFINE FILE EMPLOYEE
FULL_NAME/A30=FIRST_NAME || (' '| LAST_NAME);
END

Now, issue the following request:

TABLE FILE EMPLOYEE
PRINT CURR_JOBCODE
BY FULL_NAME
END

Run the request. The output is:

Unlike a temporary field created by a COMPUTE command, you can sort the field FULL_NAME and it continues to exist after the report is finished.

Adding More Temporary Fields

When you issue a new DEFINE, it erases existing temporary fields, unless you start the DEFINE command as follows:

DEFINE FILE filename ADD

ADD prevents existing temporary fields from being erased and lets you add new ones. Right now, FULL_NAME is the only temporary field that exists. In the next example, you will add another.

WebFOCUS

Feedback