TITLE and DESCRIPTION for a Virtual Field

How to:

In a DEFINE FILE command or a DEFINE FUNCTION, you can specify a TITLE and a DESCRIPTION for each virtual field, just as you can for a DEFINE in a Master File.


Top of page

x
Syntax: How to Add a TITLE and DESCRIPTION to a Virtual Field
DEFINE FILE filename dfieldname[/format] [WITH rfield] [MISSING {ON|OFF} 
 [[NEEDS] [SOME|ALL] [DATA]]
 [TITLE 'line1[,line2 ...']
 [DESCRIPTION 'description'] = expression;
   .
   .
   .
END

where:

filename

Is the name of the file for which the virtual field is being defined.

dfieldname

Is the name of the virtual field.

format

Is the format of the virtual field. The default format is D12.2.

rfield

Associates a virtual field with a data source segment containing a real field.

line1, line2...

Are the lines of the default column title to be displayed for the virtual field unless overridden by an AS phrase.

description

Is the description to be associated with the virtual field.

expression

Is the expression that, when evaluated, defines the virtual field value.


Top of page

x
Syntax: How to Add a TITLE and DESCRIPTION to a Virtual Field in a DEFINE FUNCTION
DEFINE FUNCTION functionname (argument1/format1,..., argumentn/formatn) dfieldname[/format] [MISSING {ON|OFF}] 
 [[NEEDS] [SOME|ALL] [DATA]]
 [TITLE 'line1[,line2 ...']
 [DESCRiption 'description'] = expression;
   .
   .
   .functionname/format = [result_expression];
END

where:

functionname

Is the name of the DEFINE FUNCTION.

argument1/format1, ..., argumentn/formatn

Are the function input arguments and their formats.

dfieldname

Is the name of the virtual field.

format

Is the format of the virtual field. The default format is D12.2.

line1,line2 ...

Are the lines of the default column title to be displayed for the virtual field unless overridden by an AS phrase.

description

Is the description to be associated with the virtual field.

result_expression

Is the expression that, when evaluated, defines the DEFINE FUNCTION return value.



Example: Assigning a TITLE and DESCRIPTION to a Virtual Field

The following request against the EMPDATA data source creates two virtual fields:

The request follows.

DEFINE FILE EMPDATA                                                 
NAME/A50 TITLE 'EMPLOYEE,FULL NAME' = FIRSTNAME || (' ' | LASTNAME);
MSALARY/D12.2 TITLE 'MONTHLY,SALARY'                                
DESCRIPTION 'Monthly Salary or missing'                             
MISSING ON = IF JOBCLASS EQ '019PVB'                                
          THEN MISSING ELSE  SALARY / 12;                           
END                                                                 
TABLE FILE EMPDATA                                                  
SUM MSALARY                                                         
BY NAME BY JOBCLASS IN 20                                           
WHERE PIN FROM '000000100' TO '000000200'                           
END

The output is:

EMPLOYEE                            MONTHLY
FULL NAME          JOBCLASS         SALARY 
---------          --------         -------
ANTHONY RUSSO      38909           1,608.33
KAREN LASTRA       019PVB                 .
KARL WHITE         064PSA          3,408.33
KATE WANG          064PSB          4,125.00
LAURA GORDON       38913           2,116.67
MARCUS CVEK        019PTB          5,208.33
MARK MEDINA        257PRB          3,250.00
ROSE HIRSCHMAN     019PTB          5,208.33
TIM ANDERSON       38910           2,700.00
VERONICA WHITE     019PUA          5,208.33
WILLIAM MORAN      38914           2,566.67

If you add a HOLD command to the request and SET HOLDATTR=ON, the TITLE and DESCRIPTION attributes are propagated to the HOLD Master File.

SET HOLDATTR = ON                                                   
DEFINE FILE EMPDATA                                                 
NAME/A50 TITLE 'EMPLOYEE,FULL NAME' = FIRSTNAME || (' ' | LASTNAME);
MSALARY/D12.2 TITLE 'MONTHLY,SALARY'                                
DESCRIPTION 'Monthly Salary or missing'                             
MISSING ON = IF JOBCLASS EQ '019PVB'                                
          THEN MISSING ELSE  SALARY / 12;                           
END                                                                 
TABLE FILE EMPDATA                                                  
SUM MSALARY                                                         
BY NAME BY JOBCLASS IN 20                                           
WHERE PIN FROM '000000100' TO '000000200'                           
ON TABLE HOLD AS DEFINE1 FORMAT ALPHA                               
END

The DEFINE1 Master File has the TITLE and DESCRIPTION attributes assigned to the virtual fields.

FILENAME=DEFINE1 , SUFFIX=FIX     , IOTYPE=STREAM, $                    
  SEGMENT=DEFINE1, SEGTYPE=S2, $                                        
    FIELDNAME=NAME, ALIAS=E01, USAGE=A50, ACTUAL=A50,                   
      TITLE='EMPLOYEE,FULL NAME', $                                     
    FIELDNAME=JOBCLASS, ALIAS=E02, USAGE=A8, ACTUAL=A08, $              
    FIELDNAME=SALARY, ALIAS=E03, USAGE=D12.2, ACTUAL=A12,               
      MISSING=ON,                                                       
      TITLE='MONTHLY,SALARY', DESCRIPTION='Monthly Salary or missing', $

Information Builders