The Number 1 independent website for ACL information!

TexasACL User Group
About Us
Training
Why ACL
Essays & Scripts
ACL News
Events
Links
FAQ
Site Map
Support Us
GROUPs are a highly effective way to perform complex analysis.  GROUPs allow you to perform a number of actions on every individual line.  The GROUP command  will concurrently process a set of commands in one pass of the table. This can significantly reduce processing time.
 
There are three types of GROUPs: Basic, Conditional, and Nested. 
 
 

The Basic Group:
 
The basic group will perform a series of commands on individual lines in one pass of the data.  This is a highly effective way to analyze data.  For example the following script will analyze a table five times:

OPEN TABLE
 
COUNT
STATISTICS
TOTAL IF <condition1 >
TOTAL IF <condition 2>
VERIFY
 
Placing the same command in a GROUP, will allow ACL to perform all five commands on one pass of the data:
 
OPEN TABLE
 
GROUP 
  COUNT
  STATISTICS
  TOTAL IF <condition1 >
  TOTAL IF <condition 2>
  VERIFY
END
 

The CONDITIONAL GROUP:
 
The conditional GROUP will perform commands based upon the first conditional statement that is true.  If no conditions are true, then the GROUP will go to the next ELSE or if there are no conditional statements that are true, the code will advance to the next record.  The following code assumes that there is a key field, the key field is has a corresponding field that should be sequential.  The code identifies the cases wherein the sequence is broken.  Notice when using a conditional statement in this manner, there is some redundancy in the code.

OPEN table
SORT ON type invoice TO TEMP1 OPEN

v_type = blank(3)       
v_inv_num = 0

GROUP IF v_inv_num +1 <> invoice AND v_type = type
     EXTRACT v_type v_inv_num invoice to temp2
     v_inv_num = invoice
     v_type = type
ELSE
     v_inv_num = invoice
     v_type = type
END 
 
The NESTED GROUP:
 
The Nested Group is an option that can often be used instead of a conditional GROUP when there are repeated commands.  A nested GROUP will only perform the activities on the current line if the conditions for nested GROUP is TRUE.  A nested GROUP will not perform all of the actions on the rest of the file, it will only look at the current record. 
 
OPEN table
SORT ON group invoice TO TEMP1 OPEN

v_type = blank(3)       
v_inv_num = 0

GROUP
  GROUP IF v_inv_num +1 <> invoice AND v_type = type
     EXTRACT v_type v_inv_num invoice to temp2
  END
  v_inv_num = invoice
  v_type = type
END