You are on page 1of 27

Chapter 6 Analyze Transactions

ACL in Practice

Name: Yvonne Reina P. Totesora Course & Section: BSA 4C Date: April 24-25, 2014

NOTE: Rename or Save this file as your Surname4A_Ch6_prac and if youre finished, submit it to \\b501-
server under submit ---chap6 practice folder.

Points to Remember: You can use the Join and Relations commands to compare tables and to
combine data from tables. The Join command creates a new table that contains data from both of the original tables.
The Relations command does not physically combine the tables, but creates a virtual join among two or more tables.
Because the Join command creates a new table based on the two original tables, you generally use the Relations
command instead of Join if the original tables are very large. ACL provides two ways to create a report. You can
generate a standard ACL report, or you can create a report that you can view in Crystal Reports.

In this chapter you accomplished the following tasks:
Examined the tables that contain acceptable and unacceptable Merchant Category Codes to ensure that no codes
are listed in both tables.
Created a table with unacceptable transactions only.
Linked the employees who made unacceptable transactions to the employees departments.
Created a report that provides a detailed description of all unacceptable transactions in April.

Project: Open an existing project--- Surname4A_ACL_Tutorial_Metaphor
Tables: Surname4A_Credit_Cards_Metaphor; Surname4A_ Trans_April; Surname4A_
Unacceptable_Codes; Surname4A_ Company_Dept; Surname4A_ Employees;
Surname4A_Acceptable_Codes; Surname4A_Trans_by_Code ; Surname4A_
Trans_April_Travel ; Surname4A_ Trans_April_by_CCN
Additional Tables: Surname4A_ Codes_in_both_tables; Surname4A_ Trans_April_Unacceptable;
Surname4A_ CardNumTrim
Functions: SUBSTR ( ) --- See below the explanations
Command: Join; Relations --- See below the explanations



Determine which transactions are unacceptable
Tasks: Check the code tables for obvious errors. Identify transactions that have unacceptable codes.
Identify the employees who made the unacceptable transactions. Create a report of your results.

About the Join and Relations commands

Check the code tables for obvious errors
Compare the length and type of the key fields
(Insert your answer here)






Create a computed field in each of the Acceptable_Codes and Unacceptable_Codes tables
(Insert your answer here)







Determine whether the tables have any codes in common and save this file as Surname4A_
Codes_in_both_tables
(Insert your answer here)





Identify unacceptable transactions
View the table layout for Trans_April
(Insert your answer here)







Create a computed field in Trans_April
(Insert your answer here)






Use the Relations command to find unacceptable Transactions
(Insert your answer here)







Extract the records to a new table and save this file as Surname4A_ Trans_April_Unacceptable
(Insert your answer here)







Identify the employees
Tasks: Determine the department of employees whose cards were used for unacceptable transactions.
Create a list of employees whose cards were used for unacceptable transactions. Create a report of the
employees whose cards were used for unacceptable transactions.

Identify the employees departments

Create a computed field that contains the first digit of the Dept_Code field
(Insert your answer here)








Add the new computed field to the view
(Insert your answer here)






Create a computed field that displays the first digit of the EmpNo field
(Insert your answer here)




Relate the Employees and Company_Dept tables
(Insert your answer here)





Extract fields to a new table
(Insert your answer here)




Create a list of employees
Compare and harmonize the card number fields and save this file as Surname4A_ CardNumTrim
(Insert your answer here)






Create a detailed view of the unacceptable transactions
(Insert your answer here)









Report your findings
Create a standard ACL report
(Insert your answer here)








Your Log
(Insert here)

April 24, 2014







April 25, 2014








Your Folder
(Insert here)

April 24, 2014



April 25, 2014







EXPLANATIONS

SUBSTRING( )
SUBSTRING( ) returns a substring of a character expression or field value.
Use SUBSTRING( ) to isolate a portion of a character expression or field value.
Function format
SUBSTRING(string, start, length)
SUBSTRING( ) returns a substring of the character expression or field value string.
start specifies the start position in string.
length specifies the length of the result in characters.
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)
JOIN
Syntax
Before issuing the JOIN command, use the OPEN command to open a secondary table. For
example, to join the primary table to a secondary table named Abc, first open the secondary
table using this command:
OPEN "Abc" SECONDARY
Then issue the JOIN command.
JOIN {PRIMARY | SECONDARY | PRIMARY SECONDARY | BOTH | UNMATCHED |
MANY} PKEY primary_key_fields FIELDS primary_fields SKEY secondary_key_field
<WITH secondary_fields> <IF test> <WHILE test> <FIRST|NEXT range> TO "table_name"
<LOCAL> <OPEN> <APPEND> <PRESORT> <SECSORT>
PRIMARY includes matched records from the primary and secondary tables and unmatched
records from the primary table in the output table.
BOTH produces the same results.
SECONDARY includes matched records from the primary and secondary tables and unmatched
records from the secondary table in the output table.
PRIMARY SECONDARY includes all records from both the primary and secondary tables in
the output table.
UNMATCHED includes only unmatched records from the primary table in the output table.
MANY includes matched records from the primary table and matched records from the
secondary table in the output table. If there is more than one key field match in the secondary
table, ACL uses all of the matched records it finds.
primary_key_field specifies the key fields or expressions in the primary table.
primary_fields specifies the fields or expressions from the primary table to include in the output.
secondary_key_fields specifies the key fields or expressions in the secondary table.
secondary_fields specifies the fields or expressions from the secondary file to include in the
output.
PRESORT sorts the primary table on the primary key before joining the tables. This option
cannot be used in a group.
SECSORT sorts the secondary table on the primary key before joining the tables. This option
cannot be used in a group.
Joining tables
Use the Join command to combine fields from two tables into a third table. Choosing the
appropriate join type determines which records are included in the output table.
You typically use Join to match records in a transaction table with those in a master table. For
example, you can compare customer account balances to customer credit limits to see whether
customers have exceeded their limits.
When you join a transaction table and a master table, you usually make the transaction table the
primary table so that you capture all transactions. Carefully identify your primary and secondary
tables because results differ if you reverse the tables, depending on the type of join.
Tables that you join must belong to the same project, and server-based tables must reside on the
same server. You cannot join a table on the local drive to a table on the server.
If any fields in the primary and secondary tables have the same name, Join automatically assigns
a new name to the secondary field in the output table. For example, if both tables contain an
Amount field, Join tries to name the secondary field Amount2, Amount3, and so on, until it finds
a name that does not conflict with any field names in the output table. However, column titles
remain unchanged.
Secondary tables must be sorted in ascending sequence on key fields. To store a temporary sort
file requires at least two and a half times the disk space of the data file itself. If there is
insufficient disk space on the drive that contains the ACL project, ACL returns the message,
Command canceled.
To use the Join command
Select Data from the menu bar and choose Join Tables to display the Join dialog box.
From the Primary Table group box, you select key fields and those fields from the primary
table that you want to include in the output table. From the Secondary Table group box, you can
select key fields and those fields from the secondary table that you want to include in the output
table.
Choosing the appropriate join type
The Join command has six join types, based on key field comparisons. The output option you
choose determines which records are included in the output table.
Join type Matched
primary
Matched
secondary
Unmatched
primary
Unmatched
secondary
Matched
primary records
X X
Matched
primary records:
Include all
primary
X X X
Matched
primary records:
Include all
secondary
X X X
Matched
primary records:
Include all
primary
Include all
secondary
X X X X
Unmatched
primary records
X
Many-to-many
matched records
X X
Matched primary records
Creates an output table of selected fields from the primary and secondary tables for primary table
records with key field matches in the secondary table.
If there is more than one key field match in the secondary table, ACL uses the first matched
record it finds. If no matching record is found, no output record is produced.
Matched primary records: all primary
Creates an output table of selected fields from the primary and secondary tables for all records in
the primary table, including those with no matches in the secondary table. The fields for those
records with no secondary table match are filled with blanks or nulls, depending on the data type.
Non-matching records from the secondary table are ignored.
Matched primary records: all secondary
Creates an output table of selected fields from the primary and secondary tables for all records
from the secondary table, including those with no match in the primary table. Fields for those
records with no match in the primary table are filled with blanks or nulls, depending on the data
type.
Non-matching records from the primary table are ignored.
Matched primary records: all primary and all secondary
Creates an output table of selected fields for all records from both primary and secondary tables,
whether the records have matches or not. The fields for unmatched records from either table and
duplicates from the secondary table are filled with blanks or nulls, depending on the data type.
Unmatched primary records
Creates an output table of all records from the primary table that had no matches in the
secondary table. The output table includes primary fields only because there is no secondary
information if records have no match.
Many-to-many matched records
Creates an output table of selected fields from the primary and secondary tables for primary table
records with key field matches in the secondary table.
This option differs from the Matched Primary Records option if there is more than one key
field match in the secondary table, ACL uses all matched records it finds. If no matching record
is found, no output record is produced.
Users with a client/server connection to an IMS database can also perform joins that include an
IMS data set as the secondary table, provided the database supports Hierarchical Direct Access
Method (HDAM). Select the Many-to-Many Matched Records option to perform a one-to-many
type of join with an IMS data set as the secondary table.
ACL supplies an error message to the command log if the IMS secondary table does not support
HDAM.

Relations
DEFINE RELATION
Syntax
DEFINE RELATION key_field_name WITH related_table_name INDEX index_name <AS
relation_name>
key_field_name specifies the key field of the parent table. You can select only one field for each
relationship.
WITH related_table_name specifies the child table.
INDEX index_name specifies the index for the key field of the child table. You must index the
child table on the key field before you can relate the table.
AS relation_name specifies a unique name for the relation. By default, DEFINE RELATION
uses the name of the child table as the relation name. When specifying additional relationships to
the same child, specify a different, unique name.
Example
Relate the open table to the Customer table by using the customer number field as the key field:
DEFINE RELATION Number WITH Customer INDEX Customer_on_number
Customer_on_number is the index of the Customer table, where the Number field is the key
field.
Accessing fields in a related table
After establishing relations, you can access fields from child tables in the view, field selection
dialog boxes, and the Expression Builder.
Field selection dialog boxes allow you to access fields in the related table. Using the From
Table drop-down list, choose the related table. Fields are displayed in relation name.field name
format to show from which table the fields came.
Here are only a few examples of dialog boxes in which you can select fields from a related table:
In the view, right-click and select Add Columns. Your column can show fields from a
related table.
In the view, click the Edit View Filter button to open the Expression Builder. You can
build expressions using fields from a related table.
Select Analyze Total Fields and click Total Fields. For commands in which you
choose fields like the Total dialog box you can select fields from the related table.
Accessing data in related tables
You can use the Relations command to simultaneously access data from two or more tables, two
tables at a time. You can analyze the combined data as though it existed in a single table. You
can add fields from related tables to a view or use the Extract command to create a new table of
related fields.
Relations produces results similar to the Join command with the All Primary option selected.
Both of the tables that you relate must contain a field in common that you can use as a key field.
Tables that you relate must belong to the same project and server-based tables must reside on the
same server. You cannot relate a table on the local drive to a table on the server.
To use the Relations command
Select Data from the menu bar and choose Relate Tables to display the Relations dialog box.
The Relations dialog box displays relationships graphically, so that you can easily manage
multiple relationships. 4
You can:
Add tables. To add tables to the Relations dialog box, click the Add Table button.
Remove tables. To remove a table that does not have a relationship, right-click the table
and select Remove Table.
Add, edit, and delete relationships. To create relationships, drag a key field to its
corresponding key field in another table. To edit or delete a relationship, right-click a
relationship arrow to display a pop-up menu.
Arrange tables in the display. To tidy the Relations dialog box, right-click any empty
space in the dialog box and select Arrange Tables.
Add new expressions. To add a new expression, right-click the parent table and select
New Expression.
Rename and save an index. If it detects no existing indexes when you relate tables,
ACL automatically creates an index that you can rename and save:

1. In the Relations dialog box, right-click and drag the parent key field to the child key
field.

2. From the pop-up menu, select Relate using Named Index to display the Create Index
dialog box.

3. Specify a name and location for the index, then click OK.

Choosing tables to relate
There are several factors to consider before deciding which table should be the parent, and which
should be the related or child table.
Consider the many-to-one relationship between the keys of the parent table and the keys of the
related table. ACL matches each key in the parent table with the first matching key in the related
table.
Another way of saying this is that the parent table should contain all the records you want to
analyze. For example, if you have an Accounts Receivable (Ar) table with 500 invoices (records)
and a Customer table with 100 records, choosing the Ar table as the parent table allows you to
analyze all 500 invoices. On the other hand, if you choose the Customer table as the parent table,
you can only analyze 100 records, that is, one invoice for each customer.
Consider also that the relationship is established in one direction, from the parent to the child.
Only a parent table can access fields from a child table. A child table has no information about
its parent table.
Key fields
Tables that you join or relate must contain a common field that you can use as a key field. ACL
bases the join or relationship on this key field.
Preparing key fields
You can use any type of field as a key field, provided you match fields of the same type. For
example, if you select a numeric field as the primary or parent key, then you must also select a
numeric field as the secondary or child key.
Key fields must match in data type, length, justification, and case. If key fields are not alike, you
can create a computed field to modify such fields so that they are alike. You can then use this
computed field as a key field. For example, conversion functions provide the ability to convert
fields from one data type to another. Other functions provide the ability to change items such as
case, field length, and justification.
Selecting key fields
When you join two tables, you can select more than one key field in each table. For example, to
capture records for a vendor with outlets at more than one location, you select both vendor and
location fields as key fields.
When you relate tables, you can select only one key field per relationship, but you can relate
many tables. For example, to capture records for a vendor with outlets at more than one location,
you select both vendor and location fields as key fields in the parent table. Then you select
vendor as the key field in one child table and location as the key field in another child table.
Modifying and deleting relationships
You can change the index or the fields on which your tables are related at any time. You can also
delete any relationship that has no dependent relations and no related fields referenced in either
the current view or in an active computed field.
To modify a relationship 4
1. In the Relations dialog box, right-click the arrow representing the relationship that you
want to modify and select Edit Relation from the pop-up menu. The Edit Relation
dialog box appears.
2. Change the parent key field, child key field, or child index as needed and click OK.
To delete a relationship 4
1. In the Relations dialog box, right-click the relationship arrow and select Delete.
2. ACL deletes the relationship.
3. Right-click the child table and select Remove Table. This step is optional, as ACL will
remove any unrelated tables from the work area when you close the Relations dialog
box.
Parent and child relations
Data relationships created with the Relations command are hierarchical. The primary table is
called the parent table, and the dependent tables are called related or child tables. A parent can
have many child tables. Child tables can be parents, too, with child tables of their own. A
grandchild relation has to be created from its parent.
Once a relationship is established, you can add fields from the child table to the view, or
access them in other ways for analysis. The related fields can be viewed only in the
parent table.
An originating ACL parent table can actively reference information in up to 17 related
tables.
A child table should not have duplicate or missing records in the key field.
ACL compares the two tables according to the contents of the key field, record by record.
The contents of the key field in each table must be identical to obtain a match. When the
data in the key field is identical, ACL can relate, or virtually join, the record data in the
child table to the corresponding record in the parent table.
When there are duplicate records in the key field of the child table, ACL matches to the
first occurrence of the key. Remaining duplicate keys are ignored. When there is no
matching key in the related table, ACL displays a blank for character and date fields, zero
for numeric fields, and F for logical fields.
Planning relations between tables
Successful data relations require careful planning. Determine which tables contain fields you
need to relate, and consider the most effective way to relate them.
For example, you may need to analyze data that is found in several different tables. You will
need to identify which tables contain the data fields you need, and which additional fields could
serve as key fields. It is often useful to create a diagram to identify the relationship possibilities.
4

The Ar table and the Customer table, for example, both contain a Customer Number field that
can be used as a key field in forming a relationship between these two tables. Such a relationship
provides access to all fields in the Ar table as well as to relevant fields in the Customer table:
Name and Credit Limit.
Once you have established a relationship between the two tables, you can access the Customer
Name and Credit Limit fields in commands that you issue from the parent Ar table. If you want,
you can also add these fields to the view of the Ar table.
The Ar table also contains a Contract Number field, which it holds in common with the Contract
table, so a relationship can be established between these two tables as well. Once the relationship
is established, the Sales Rep Number field can be accessed from the Ar table. If you want, you
can add this field to the view of the Ar table.
You can now use the Sales Rep Number field as a key field to relate the Ar table to the Sales Rep
table, and add the Sales Rep Name field to the Ar table's view. Now all the fields of interest are
in the Ar parent tables view, and can be analyzed as though they existed within the Ar data
table.
You can work with fields from related tables whether or not you have added them to the parent
tables view. Once you have established the relationships, all the related fields are available for
analysis from the parent table, and appear in field selection lists in commands and in the
Expression Builder.
Relating tables
To relate two tables
1. Open the parent table by double-clicking it in the Overview.
2. Select Data from the menu bar and choose Relate Tables to display the Relations dialog
box.
3. Click Add Table. The Add Table dialog box appears.
4. In the field list, select one or more tables to add to the Relations dialog box and click
Add. To select multiple tables, hold down the Ctrl key while selecting tables.
5. Click OK to return to the Relations dialog box.
6. From the parent table, click and drag the key field onto the key field in the child table.
The screen displays an arrow, which represents the new relationship.
7. Click Finish to close the Relations dialog box.
You can have more than one relation to the same table. To do this, add another instance of the
table to the Relations dialog box.

You might also like