Professional Documents
Culture Documents
Course Objectives
For the students to learn how to use ACL,
particularly the commonly used
commands and functions as well as to
create, run, update scripts/batches and
analyze the corresponding results.
Coverage
Uses of ACL
How does ACL read data?
What kinds of data can ACL read?
ACL User Working Knowledge
Navigating the ACL program window
How do I apply ACL to my project?
Organizing your project items
Viewing and modifying your tables
Organizing your work using ACL projects
ACL commands
Log file activities
Expressions
Functions
LIST command
ACL Scripts
Creation of Scripts & Sample Exercises
Source Data
Table
View
CR files
CR/LF files
Data sources with file layout
Data sources without file layout
Databases
Delimited files
Fixed-length files
Flat files
Hierarchical and relational databases
LF files
Mainframe databases
Multiple-record-type files
Proprietary variable-length files
Report files
Segmented files
Variable-length files
Total value
Absolute value
Minimum value
Maximum value
MATCH()
MATCH()
MATCH( ) compares an expression or field value
of any type to a series of specified expressions
or field values to determine whether there is at
least one match. The value returned is either
true or false.
Use MATCH( ) to eliminate the need to repeat
arguments in a test.
Function format
MATCH(comparison_value, test1,test2 <,test
3...>)
MATCH()
IF LOC = 7 OR LOC = 9 OR LOC = 13 OR
LOC = 21 OR LOC = 44
can be replaced with:
IF MATCH(LOC, 7, 9, 13, 21, 44)
ACCEPT
Use ACCEPT to create an interactive
script that pauses to display a dialog box
that prompts for information that ACL uses
in subsequent processing.
Syntax
ACCEPT "message_text" <FIELDS
"list_item"> TO variable_name
OPEN
Use the OPEN command to open a table
or dBASE file or to associate source data
with a table.
Syntax
OPEN table_name
SORT
Syntax
SORT ON key_field <D>... TO table-name
<IF test> <WHILE test> <FIRST|NEXT
range> <APPEND> <OPEN>
STRING( )
converts a numeric expression or field value into a string
of characters.
Function format:
STRING(number, length <,format>)
STRING( )
STRING(125.2, 7) = "
125.2"
STRING(-125.2, 4) = "25.2"
STRING(-125.2, 10,
"(9,999.99)") = " (125.20)"
VALUE( )
converts a character expression or field
into a numeric equivalent.
returns the numeric equivalent of a
character expression or field value with a
specified number of decimal places.
if the decimal adjustment results in a loss
of decimals, the result is rounded.
Function format:
VALUE(string, decimals)
VALUE( )
Examples
VALUE("123.4-", 3) = -123.400
VALUE("$123,456", 2) = 123456.00
VALUE("77.45CR", 2) = -77.45
VALUE(" (123,456.78)", 0) = -123457
HTML
Log File
Script
WordPad
Text
AGE( )
returns the age, in days, of a specified
date compared to a specified cutoff date.
when comparing two dates to determine
overdue accounts or to perform aged
analyses of balances.
Function format:
AGE(date <,cutoff_date_yyyymmdd>)
AGE( )
Examples
Current system date of January 1, 1996:
AGE(`951220`) = 12
AGE(`19960108`) = -7
AGE(`19941220`,`950101`) = 12
AGE(Invoice_date) = 65
AGE(Invoice_date,`961231`) = 80
To extract the name, amount, and invoice date for
all items more than 180 days old:
AGE(Invoice_date,`961231`) > 180
CTOD( )
converts a character or numeric
expression into a valid date expression
to create a date for purposes of
comparison with date field values,
especially if the date is not a constant
short for Character To Date
Function format:
CTOD(field <,"date_format">)
CTOD( )
Examples:
1. Due < CTOD(950701)
2. CTOD("951231")
3. CTOD(311295,"DDMMYY")
4. CTOD("19951231")
5. CTOD("951231", "YYMMDD")
6. CTOD("311295", "DDMMYY")
7. CTOD(951231)
8. CTOD(95365, "YYDDD")
9. CTOD("31/12/1995", "DD/MM/YYYY")
10.CTOD("951220") = "12/20/95"
11.CTOD("DEC2095","MMMDDYY") = "12/20/95"
SUBSTRING( )
returns a substring of a character
expression or field value
to isolate a portion of a character
expression or field value
Function format:
SUBSTRING(string, start, length)
start specifies the start position in string.
length specifies the length of the result in
characters.
SUBSTRING( )
Examples
SUBSTRING("ABCDEF", 2, 3) = "BCD"
To extract the year out of a character field
containing a date of the form
MM/DD/YYYY, specify:
SUBSTRING(DATE, 7, 4)
UPPER( )
converts all alphabetic characters of an
expression or field value to uppercase.
when you search for data in mixed or
unknown case.
Function format:
UPPER(string)
UPPER( )
Examples
UPPER("ABC") = "ABC"
UPPER("abc 123 DEF") = "ABC 123 DEF"
UPPER("AbCd 12") = "ABCD 12"
If capitalization is a concern, you can
identify all customers named Smith by:
UPPER(NAME) = "SMITH"
DOW()
DOW( ) returns a numeric value containing a
digit from 1 to 7 which represents the day of the
week. The digit 1 represents Sunday.
To display the name of the day of the week, use
the CDOW( ) function.
Function format
DOW(date)
Example
To display the day of the week as a single digit
number:
DOW(`19991124`) = 4
DEC()
DEC( ) allows you to specify the number of
decimal places for a numeric expression or field
value. Use it when you want to adjust decimal
places in mathematical calculations, or when
you want to round a result to a specified number
of decimal places.
Function format
DEC(number, decimals)
Examples
DEC(7, 2) = 7.00
DEC(7.5647, 3) = 7.565
LIST command
to display selected output data in a columnar list
format
allows you to select information from the table to
view on screen, send to a printer, or save to a
text file. Unless otherwise specified, output is
sent only to the screen
Syntax:
LIST {<FIELDS> field_names | ALL} <TO
file_name> <LINE n> field_names
<UNFORMATTED> <IF test> <WHILE test>
<FIRST|NEXT range> <HEADER header>
<FOOTER footer> <SKIP n> <EOF> <APPEND>
LIST command
Examples:
LIST Product_number Description
Quantity Unit_cost Value HEADER
"Inventory List
LIST Product_number Description
Quantity Unit_cost Value IF Quantity < 0
OR Unit_cost < 0 HEADER "Negative
Values"
IF
IF is a scope parameter that causes a
command to be executed on records that
satisfy a specified test. IF filters out all
records that fail the test. IF is not
dependent on current record position.
Syntax
command IF test
AS
AS is used to specify a replacement name
for an existing field or ad hoc expression.
Syntax
command AS "replacement_name"
ALL
ALL is used to specify the extent to which
a command is executed either on fields or
on records. ALL specifies that a command
is to be executed on all fields,
expressions, or variables of an appropriate
type, usually numeric.
Syntax
TOTAL ALL
FILE
FILE specifies that output from a
command is to be saved in a separate file
or table.
The parameter FILE is usually omitted
from commands as it is assumed by
default.
Syntax
command TO "file_name.txt"
command TO "table_name"
OPEN
OPEN is a parameter that is used to open
a table that has been created by a
command. The newly created table is
used as the current table. This parameter
is valid only when the command creates
an output table.
Syntax
command TO "table_name" OPEN
PIC
PIC specifies how to format a date or
numeric field.
Syntax
command date_or_numeric_field PIC
"format"
Example:
LIST Acct_no Amount PIC "9,999,999.99"
TO Screen
SCREEN
SCREEN specifies that output from a
command is to be displayed for on-screen
review
Example:
CLASSIFY ON Location SUBTOTAL Value
TO SCREEN
TO
TO is used to specify the output format of
a command.
Syntax
command TO SCREEN
command TO PRINT
command TO GRAPH
command TO "table_name_or_file_name"
COMMENT
Use the COMMENT command to insert a remark
or explanation into the ACL Log file without
affecting processing or execution. COMMENT
allows you to document a session, including
such items as purposes, descriptions, and other
required explanations.
Syntax
COMMENT comment_text
WIDTH
WIDTH specifies the display width of a
specified field or expression in a report.
The default display width is the fields
defined length. The WIDTH parameter
overrides this default.
Syntax
command FIELDS field_names WIDTH
field_width
5.
DEFINE FIELD
Use the DEFINE FIELD command to create either data
fields or computed fields. You can execute this command
from the command line or from within a script, except
when you create conditional computed fields, which
require multiline syntax. Then you can only use a script.
Data fields
Data fields contain values from corresponding fields in
the source data. Enter the data field syntax on a single
line, with no carriage returns.
Syntax
DEFINE FIELD field_name data_type start_position
field_length <decimals|date_format> <AS
"alternate_column_title"> <WIDTH> <PIC "format">
ALLTRIM()
ALLTRIM( ) returns a variable length string
with leading and trailing blanks removed.
Blanks inside the character string are not
removed.
Function format
ALLTRIM(string)
Examples
ALLTRIM(" abc ") = "abc"
ALLTRIM(" a bc ") = "a bc"
Session
In the context of the command log,
sessions give you the ability to label a
series of commands for historical
purposes. When you start a session, you
can give it a descriptive name. When you
later review your log, you can easily see
the commands in the session, and the
descriptive name reminds you why you
performed the commands.
Scope parameter
A scope parameter is a statement that can
be included in an ACL command to limit
how much of a file is processed, or to limit
the execution of a command or script.
Examples are IF, WHILE, NEXT, and
FIRST.