In this section: |
An expression can be one of the following:
COMPUTE BONUS/D12.2 = CURR_SAL * 0.05 ;
A numeric expression returns a numeric value. For details, see Creating a Numeric Expression.
COMPUTE DELIVERY/MDY = SHIPDATE + 5 ;
There are two types of date expressions:
COMPUTE FIRST_INIT/A1 = EDIT (FIRST_NAME, '9$$$$$$$$$') ;
A character expression returns an alphanumeric value. For details, see Creating a Character Expression.
Note: Text fields can be assigned to alphanumeric fields and receive assignment from alphanumeric fields. Text fields can also participate in expressions using the operators CONTAINS and OMITS.
When you use an expression to assign a value to a field, make sure that you give the field a format that is consistent with the value returned by the expression. For example, if you use a character expression to concatenate a first name and last name and assign it to the field FULL_NAME, make sure you define the field as character.
The following example contains a character expression that concatenates a first name and last name to derive the full name. It assigns the field FULL_NAME an alphanumeric format of sufficient length to accommodate the concatenated name:
DEFINE FILE EMPLOYEE FULL_NAME/A25 = FIRST_NAME | LAST_NAME; END TABLE FILE EMPLOYEE PRINT FULL_NAME WHERE LAST_NAME IS 'BLACKWOOD' END
The output is:
FULL_NAME --------- ROSEMARIE BLACKWOOD