Focus Funda11
Focus Funda11
Focus Funda11
FOCUS ENVIRONMENT FOCUS is an environment in itself FOCUS environment constitutes mainly of Text editor TED
File definitions
File Definition describes the components of a Master File Description Master File defines the complete structure and format of your data Before you can use FOCUS to write reports, you must create a Master File for each data file you wish to use, regardless of whether the file is a FOCUS file or a non-
MFD
Master File Description is a file that describes a data file to FOCUS. The MFD contains information about the names and formats of the fields in each file segment. It also holds information about the relationship of fields and segments to each other.
Master File
Describes logical construction of data file.
FOCEXEC
user-written FOCUS report procedure
Report Definitions
Table Command
Use the TABLE command to begin report requests Use END or RUN commands to terminate Report requests.
Report headings and footings may be added by typing the words "HEADING" or "FOOTING.
HEADING
creates a report heading
format is HEADING(CENTER)
PRINT Verb
The PRINT verb prints fields specified on the report in the order requested
Print Command
TABLE FILE MAST PRINT AREA SALES1 DATE1 DATE2 END The output of the focexec is shown below. AREA SALES1 DATE1 DATE2 ------- -------- -------- --------HUSTON 111111 98/02/23 00/11/01 CALCUT 888888 98/02/27 00/02/23 BOMBAY 888888 98/03/01 00/02/23 CALCUT 888888 98/03/02 00/02/23 TEXAS 888888 98/03/03 00/02/23 CALCUT 888888 00/02/28 00/02/23 MADRAS 888888 00/02/29 00/02/23 CALCUT 888888 01/03/01 00/02/23
PRINT Verb
PRINT field [AS 'title'] field...
END
List Verb
The LIST verb prints the fields specified on the report in the order requested and counts the number of records on the report
LIST Verb
LIST field [AS 'title'] field...
SUM
The SUM verb adds numeric fields specified
SUM Verb
SUM [prefix.]field [AS title'] field... computes a summary for the fields within the category specified by the BY variable
SUM-An example
TABLE FILE FRSMTD SUM TT_CD_AMT - selects the FRS Month-to-Date Transaction data file - sums the amounts of all transactions - selects the first 500 records in the file
WHERE RECORDLIMIT EQ 10
END
SUM-An example(contd.)
PAGE 1 TT_CD_AMT ---------
$284.65
Count
The COUNT verb shows the number of records (does not show individual records)
Count
TABLE FILE FRSSL - selects the FRS Subsidiary Ledger data file COUNT ACCID - counts the number of Account ID's WHERE READLIMIT EQ 500 - selects the first 500 records in the file WHERE RECORDLIMIT EQ 10 - selects the first 10 records that match END - end of the focexec
Count(contd.)
PAGE 1 ACCID
COUNT
----2
Basic Sorting
Most reports are sorted in FOCUS by use of the BY option using BY HIGHEST will result in fields sort from highest to Lowest order default is lowest to highest
Noprint
NOPRINT indicates you wish to sort the report but not display the sort field format is : BY [HIGHEST] field [NOPRINT]
Record Selection
use WHERE and IF conditions to select a subset of records for printing WHERE and IF Conditions
WHERE
WHERE field rel val [OR val]
specifies a selection criterion, The OR criterion is used with the EQ relational operator.
WHERE
WHERE field LIKE 'mask' a screening of alphanumeric data.;
Where
WHERE field LIKE % WHERE field LIKE _' use % to match any number of characters use _ to match any single character.
Record selection(contd.)
READLIMIT Specifies the total number of records to be read from the data file RECORDLIMIT Specifies the total number of records selected for the report
Examples of Readlimit,Recordlimit
WHERE READLIMIT EQ 100
WHERE RECORDLIMIT EQ 10
TOTALS AND SUBTOTALS With FOCUS, you can add grand totals and subtotals when a specified sort field changes by using the SUMMARIZE option with the BY statement
example :
TABLE FILE filename
PRINT fieldnames
BY sortfield SUMMARIZE END
Some useful commands relating to Files ? F Filename - Lists fields described in MFD
TABLE FILE filename PRINT LIST SUM COUNT BY [HIGHEST][n]sortfieldn ACROSS [HIGHEST] [n] sortfieldn WHERE field relation expression END [SEG.]field [prefix.field]
TABLE FILE EMPLOYEE PRINT EMPLOYEE_ID AND MONTHLY_SAL AND CURR_SAL END
Note: Once the temporary field is defined, you can use it in report requests for the remainder of your FOCUS session
PAGE
SEX --F M
PAGE
SEX
F M -----------------------526000 808000
PAGE
SEX F M DEPT_ID --------------------------------D0001 110000 180000 D0002 210000 270000 D0003 108000 204000 D0004 98000 154000
DEPT_ID D0001
D0002
D0003
D0004
SEX ----------------------------------------------------F 110000 210000 108000 98000 M 180000 270000 204000 154000
PAGE
DEPT_ID D0001
D0002
D0003
D0004
SEX ----------------------------------------------------F 10000 . . . . . 12000 . 10000 . . . . . 12000 . 10000 . . . 10000 . . . 10000 . . . 10000 . . . 10000 . . . . . 12000 . . 15000 . . . 15000 . . . . 12000 . . . . 14000 ........... M 10000 . . . 10000 . . . . . 12000 . 10000 . . . 10000 . . . . . 12000 . . 15000 . . 10000 . . . . . 12000 . . 15000 . . . . 12000 . . 15000 . . 10000 . . . . . . 14000
PAGE
SEX F M DEPT_ID --------------------------------D0001 10000 . . 10000 . 10000 10000 . . 10000 . 10000 10000 . . 10000 10000 . 10000 . 10000 . 10000 . . 10000 . 10000 ............ D0002 . 15000 . 15000 . 15000 . 15000 . 15000 15000 . 15000 . . 15000 . 15000 . 15000 . 15000 . 15000 15000 .
LAST_NAME --------BERMUDEZ CHAN CHAPMAN CHIZEK CRUZ DAS DAZQUEZ DENNISON DIAZ EASTERLY EL FRAZIER GAUTAM
SALARY -----15000 15000 15000 15000 15000 15000 15000 15000 15000 15000 15000 15000 15000
SUBTOTALS - ON CLAUSE
PRINT SALARY
BY DEPT_ID BY LAST_NAME WHERE SALARY GT 10000 ON DEPT_ID SUBTOTAL END
1 SALARY -----15000 15000 15000 15000 15000 15000 15000 15000 480000 12000 12000 12000 12000 12000 12000 12000 12000 12000
LAST_NAME --------BERMUDEZ CHAN CHAPMAN CRUZ .......... GUNTER HALE HESS D0002 TRINNKER *TOTAL DEPT_ID D0002 D0003 CAPETILLO CARRERO DAK DAVIS FITZGERALD FOX ............ WAGONER WATZ WILLIAMS
312000
14000 14000 14000 252000
TOTAL
1044000
LAST_NAME --------ALEMANY ALVAREZ ANDAYA BATTIATO BERMUDEZ BLACKMER BRILL BROWN CAPETILLO CARRERO CHAN CHAPMAN CHENG
SALARY DEPT_ID ------ ------10000 D0001 10000 D0001 14000 D0004 10000 D0001 15000 D0002 *** EMP_ID: K0053 SALARY EXCEEDS 14000. 10000 D0001 14000 D0004 10000 D0001 12000 D0003 12000 D0003 15000 D0002 *** EMP_ID: K0054 SALARY EXCEEDS 14000. 15000 D0002 *** EMP_ID: K0040 SALARY EXCEEDS 14000. 14000 D0004
LAST_NAME --------ALEMANY -----------ALVAREZ -----------ANDAYA -----------BATTIATO -----------BERMUDEZ -----------BLACKMER -----------BRILL -----------BROWN ------------
COUNT VERB
TABLE FILE EMPLINFO COUNT EMPL BY DEPT_ID BY SALARY BY SEX END
PAGE 1
DEPT_ID ------D0001
SALARY -----10000 12000 14000 15000 12000 15000 12000 14000 10000 12000
D0002
D0003
D0004
SEX --F M F M F M M F F M F M F M M
PREFIX OPERATORS AVE - Average (Total / Count) ASQ - Average Sum of Squares MIN - Minimum MAX - Maximum FST - First LST - Last CNT - Count CNT.DST - Count Distinct PCT. - Percent to Column Total RPCT. - Percent to Row Total TOT. - Column Total
Syntax
display prefix.fieldname Note: Only SUM OR COUNT display verbs are allowed.
AVE- OPERATOR
PAGE
ASQ- OPERATOR
PAGE
AVE SALARY -----10000 10000 14000 14000 15000 15000 14000 14000
ASQ SALARY -----100000000 100000000 196000000 196000000 225000000 225000000 196000000 196000000
PAGE
PCT - OPERATOR TABLE FILE EMPLINFO SUM PCT.SALARY SALARY BY DEPT_ID END
PAGE
RPCT - OPERATOR TABLE FILE EMPLINFO SUM SALARY RPCT.SALARY BY SEX ACROSS DEPT_ID END
PAGE 1
DEPT_ID D0001
D0002
D0003
D0004
RPCT RPCT RPCT SEX SALARY SALARY SALARY SALARY SALARY SALARY SAL ----------------------------------------------------------------------------F 122000 22 207000 38 110000 20 98 M 226000 26 270000 31 204000 24 148
PAGE
PAGE
BY ROWS OVER - OPTION TABLE FILE EMPLINFO PRINT FN BY SEX ROWS M OVER F END
PAGE 1
M M M M M M M
ACROSS COLUMNS AND - OPTION TABLE FILE EMPLINFO PRINT FN ACROSS SEX COLUMNS M AND F END
PAGE 1
SEX M F ---------------------------. LARRY MICHAEL . SHANKAR . . GLEN GEORGE . WAH . . HECTOR . LUIS ANTONIO . SHAWN . TITO .
Numeric Data Ranges - OPTION TABLE FILE EMPLINFO PRINT FN BY SALARY IN-GROUPS-OF 1000 END
PAGE 1 SALARY -----10000 FIRST_NAME ---------LARRY SHANKAR GEORGE HECTOR ANTONIO ............. JOHN MARY ATANYA MELODY RAY DWAYNE AMANDA MICHAEL GLEN WAH LUIS
12000
Numeric Data Ranges - FOR OPTION TABLE FILE EMPLINFO PRINT FN FOR SALARY 13999 To 15100 OVER 9999 TO 10100 OVER 11000 TO 12450 PAGE END
13999 13999 13999 13999 13999 13999 13999 13999 13999 13999 9999 9999 9999 9999 9999 9999
FIRST_NAME ---------GEORGE DANNETTE ED ATUL PAUL MARTY REBECCA KELLY RAY RICHARD LARRY SHANKAR GEORGE HECTOR ANTONIO SHAWN
Sorting by Rank: HIGHEST/LOWEST OPTION TABLE FILE EMPLINFO PRINT FN BY HIGHEST 10 AGE PAGE END
AGE --59 57 56
53 52 51 49 48 47 46
FIRST_NAME ---------DANNETTE SCOTT CARLA BRYAN ALICE RASHED ALFREDO RAYMOND VANNESSA YVONE MELODY MARY SHAWN RICHARD MARTY AMANDA LUIS TINA TOM KARL JOBY JANE
Multiple SORT requests TABLE FILE SUM SALARY SUM SALARY SUM SALARY SUM SALARY END
SALARY -----334000 DEPT_ID ------D0001
SALARY -----290000
SEX --F
SALARY -----110000
180000
AGE --23 28 31 33 38 41 48 51 52 57 26 27 32 33 34 35
SALARY -----10000 10000 10000 10000 10000 10000 10000 10000 20000 10000 20000 10000 30000 20000 10000 10000
WHERE Cond.. TABLE FILE EMPLINFO PRINT LAST_NAME AND FIRST_NAME BY LAST_NAME NOPRINT WHERE (SAL GT 10000) AND (DEPT IS 'D0003') END
PAGE 1
LAST_NAME --------CAPETILLO CARRERO DAK DAVIS FITZGERALD FOX FRY GERRY MARCUS MATTHEWS
FIRST_NAME ---------NYDIA TITO MARTIN JANE ED PAUL SUE BRIAN DAN MICHAEL
WHERE Cond..
WHERE Cond..
PAGE
AGE --31 32 34 45
|-------------|----------------------------------------| |Operator |Meaning | |-------------|----------------------------------------| |EQ |Tests for and selects values equal to | |IS |the test expression. | |-------------|----------------------------------------| |NE |Tests for and selects values not equal | |IS-NOT |to the test expression. | |-------------|----------------------------------------| |GE |Tests for and selects values greater | | |than or equal to the test value (based | |-------------|----------------------------------------| |GT |Tests for and selects values greater | |EXCEEDS |than the test value. | |IS-MORE-THAN | | |-------------|----------------------------------------| |LT |Tests for and selects values less than | |IS-LESS-THAN |the test value. | |-------------|----------------------------------------| |LE |Tests for and selects values less than | | |or equal to the test value. | |-------------|----------------------------------------| |GE lower AND |Tests for and selects values within a | |... |range of values. | | LE upper | | |-------------|----------------------------------------| |LT lower OR |Tests for and selects values outside of | |... |a range of values. | | GT upper | | |-------------|----------------------------------------|
|-------------|----------------------------------------| |OMITS |Tests for and selects values that do not| |NOT LIKE |include a character string matching test| | |value. The string cannot occur in any | | |position in the value being tested.When | | |used with WHERE, can test alphanumeric | | |fields; when used with IF, can test both| | |alphanumeric and text fields. | |-------------|----------------------------------------| |INCLUDES |Tests whether a chain of values of a | | |given field in a child segment includes | | |all of a list of literals. | |-------------|----------------------------------------| |EXCLUDES |Tests whether a chain of values of a | | |given field in a child segment excludes | | |all of a list of literals. | |-------------|----------------------------------------| |IN (z,x,y) |Selects records based on values found in| | |an unordered list. | |-------------|----------------------------------------| |NOT ... IN |Selects records based on values not | |(z,x,y) |found in an unordered list. | |-------------|----------------------------------------| |IN FILE |Selects records based on values stored | | |in a sequential file. | |-------------|----------------------------------------| |NOT ... IN |Selects records with field values not | |FILE |found in a sequential file. | |-------------|----------------------------------------|
|-------------|----------------------------------------| |FROM lower |Tests for and selects values within a | | TO upper |range of values. | |-------------|----------------------------------------| |IS-FROM lower|Tests for and selects values within a | | |range of values. This is alternate | | TO upper |syntax for FROM lower to UPPER; both | | |operators produce identical results. | |-------------|----------------------------------------| |NOT-FROM | Tests for and selects values that are | |lower |outside a range of values. | | TO upper | | |-------------|----------------------------------------| |IS MISSING |Tests whether a field contains null | |IS-NOT |values-that is, if some instances of the| |MISSING |field contain no data (have "missing" | |NE MISSING |data). For a thorough examination of | | |missing data, see Section 4.7 . | |-------------|----------------------------------------| |CONTAINS |Tests for and selects values that | |LIKE |include a character string matching test| | |value. The string can occur in any | | |position in the value being tested. When| | |used with WHERE, can test alphanumeric | | |fields; when used with IF, can test both| | |alphanumeric and text fields. | |-------------|----------------------------------------|
WHERE Cond..
WHERE Cond..
WHERE Cond..
LIKE Operator
TABLE FILE EMPLINFO PRINT LN WHERE LN LIKE 'C%' END
PAGE
WHERE Cond..
LIKE Operator
TABLE FILE EMPLINFO PRINT LN WHERE LN LIKE %J%' END
PAGE
WHERE Cond..
LIKE Operator
TABLE FILE EMPLINFO PRINT DEPT_ WHERE DEPT_I LIKE '_0003' END
PAGE
WHERE Cond..
RECORDLIMIT Operator
TABLE PRINT WHERE WHERE END FILE EMPLINFO FN FN LIKE '%A' RECORDLIMIT EQ 4
PAGE
WHERE Cond..
READLIMIT Operator
TABLE PRINT WHERE WHERE END FILE EMPLINFO FN FN LIKE '%A' READLIMIT EQ 4
PAGE
IF
* * * *
Functionally Similar to WHERE Has a SUBSET of functions provided by WHERE Can use TEXT fields (not possible in WHERE) No difference in syntax, what so ever.
Both are temporary fields Can be created either in the report or specified in MFD. (In case of COMPUTE only in reports). DEFINE results are stored across session. COMPUTE results are deleted after the report gets executed. COMPUTE field is calculated after every record has been selected, sorted and summed. DEFINE operations are calculated on each retrieved record
DEFINE FILE EMPLINFO SALVSAGE = SALARY/AGE; END TABLE FILE EMPLINFO SUM SALARY AND SALVSAGE COMPUTE SALVAGE = SALARY/AGE; END
PAGE 1
SALARY -----1334000
SALVSAGE -------37,991.09
SALVAGE ------339.87
ADD - TO add additional fields to existing fields. CLEAR - To Clear the already Defined fields REDEFINES - When the field name is same across segments, to differentiate between the fields.
DEFINE FILE EMPLINFO SALVSAGE = SALARY/AGE; END DEFINE FILE EMPLINFO ADD SALHALF = SALARY/2; END DEFINE FILE EMPLINFO CLEAR END