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.
DEFINE FILE filename dfieldname[/format] [WITH rfield] [MISSING {ON|OFF} [[NEEDS] [SOME|ALL] [DATA]] [TITLE 'line1[,line2 ...'] [DESCRIPTION 'description'] = expression; . . . END
where:
Is the name of the file for which the virtual field is being defined.
Is the name of the virtual field.
Is the format of the virtual field. The default format is D12.2.
Associates a virtual field with a data source segment containing a real field.
Are the lines of the default column title to be displayed for the virtual field unless overridden by an AS phrase.
Is the description to be associated with the virtual field.
Is the expression that, when evaluated, defines the virtual field value.
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:
Is the name of the DEFINE FUNCTION.
Are the function input arguments and their formats.
Is the name of the virtual field.
Is the format of the virtual field. The default format is D12.2.
Are the lines of the default column title to be displayed for the virtual field unless overridden by an AS phrase.
Is the description to be associated with the virtual field.
Is the expression that, when evaluated, defines the DEFINE FUNCTION return value.
The following request against the EMPDATA data source creates two virtual fields:
EMPLOYEE FULL NAME
MONTHLY SALARY
Its description is:
Monthly Salary or missing
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 |