COMPUTE performs computations on fields in a report file. Computed fields can be manipulated similarly to database records.
To display a computed field in a structured report, specify the COLS= parameter in the DISPLAY commands.
Syntax:
►►─── COMpute ────────────────────────────────────────────────────────────────► ►─┬───────────────────────────────────────────────────────────────┬──────────► └─ REPort ─┬─────┬─ report-name ─┬────────────────────────────┬─┘ └─ = ─┘ └─ USEr ─┬─────┬─ user-name ─┘ └─ = ─┘ ►─── compute-name = expression ──────────────────────────────────────────────►◄
Parameters:
Identifies the saved report for which the computation is performed. If you don't specify the name of the report, the computations are performed on fields in the current report.
Specifies the field name to be used to reference the computation in any of the OLQ reporting functions (that is, DISPLAY COLS=, EDIT, SORT). A compute-name that contains embedded blanks or special characters must be enclosed in quotation marks.
Defines the computations used to create the new column.
Examples:
The following examples use the report built by the SELECT statement:
select emp-last-name-0415,salary-amount-0420,bonus-percent-0420 from employee, emposition where emp-emposition
Compute Bonus, Total Salary
COMPUTE commands are used to define the computation of the BONUS, and TOTAL SALARY fields:
compute bonus=salary-amount-0420 * bonus-percent-0420 compute 'total salary'=salary-amount-0420 + bonus display columns=emp-last-name-0415, 'total salary', bonus EMPLOYEE/EMPOSITION REPORT mm/dd/yy EMP-LAST-NAME-0415 TOTAL SALARY BONUS LINGER 38654.000 154.000 TERNER 13052.000 52.000 LINGER 42797.500 297.500 LINGER 38152.000 152.000 PENMAN 39156.000 156.000 LINGER 85850.000 850.000 LINGER 75750.000 750.000 LITERATA 37762.500 262.500 WILCO 80800.000 800.000 HEAROWITZ 33231.000 231.000 TYRO 20080.000 80.000 KAHALLY 20080.000 80.000 PAPAZEUS 101000.000 1000.000 PAPAZEUS 90900.000 900.000 - 1 -
To see more of the report, page down:
display next page EMPLOYEE/EMPOSITION REPORT mm/dd/yy EMP-LAST-NAME-0415 TOTAL SALARY BONUS ARM 46322.000 322.000 KING 14558.000 58.000 CLOUD 53119.250 369.250 HENDON 242400.000 2400.000 PEOPLES 80800.000 800.000 DOUGH 33231.000 231.000 ORGRATZI 39273.000 273.000 WAGNER 47329.000 329.000 GALLWAY 33231.000 231.000 GARDNER 14056.000 56.000 JACOBI 55385.000 385.000 WILDER 90900.000 900.000 MUNYON 36252.000 252.000 CLOTH 38266.000 266.000 - 2 -
Compute with a Built-In Function
This example uses a built-in function to define a compute statement:
compute name = concatenate(extract(emp-last-name-0415),',', emp-first-name-0415) ! display columns = name, salary-amount-0420 EMPLOYEE/EMPOSITION REPORT mm/dd/yy NAME SALARY-AMOUNT-0420 GRANGER,PERCY 34500.00 FERNDALE,JANE 22500.00 ZEDI,BETSY 37000.00 ANDALE,ROY 33500.00 CROW,CAROLYN 37500.00 GARFIELD,JENNIFER 65000.00 GARFIELD,JENNIFER 55000.00 GARFIELD,JENNIFER 45000.00 CRANE,HERBERT 75000.00 CRANE,HERBERT 70000.00 CRANE,HERBERT 60000.00 LIPSICH,HERBERT 18500.00 JENSON,RUPERT 82000.00 JOHNSON,CYNTHIA 13500.00 - 3 -
|
Copyright © 2013 CA.
All rights reserved.
|
|