Summarizing the records in a result set

If you want to analyze or modify a large number of records in a result set, you might find it useful to summarize those records.

The GROUP command lets you summarize the records in a result set based upon the value of some resource table attribute.
Note: You can summarize only on those attributes that have a length of 251 or less.

When you issue a GROUP command, CICSPlex® SM summarizes the records in one result set to create a new, summarized result set. A summarized result set is a special type of result set. It contains summary resource table records that correspond to one or more records in the source result set.

For example, you could use the GROUP command to summarize a result set that contains LOCTRAN resource table records. If you want to group the records according to the value of the STATUS attribute, the summarized result set would contain, at most, two records: one representing those records with a STATUS value of ENABLED, and one representing those with a STATUS of DISABLED. Figure 1 illustrates this use of the GROUP command.
Figure 1. Using GROUP to summarize result set records
This figure illustrates the use of the command GROUP BY(STATUS) FROM (TOKENA) TO(TOKENB).. to summarize result set records for OBJSTAT and LOCKTRAN data.
In general, you can work with a summarized result set in the same ways that you do a regular result set. You can use the FETCH command to retrieve records from a summarized result set. You can also retrieve the individual records of the source result set on which the summary is based. The DETAIL option of the FETCH command lets you retrieve that subset of records in the source result set that correspond to a particular summary record.
Figure 2 shows an example of fetching the detail records associated with a summary record. In this case, the summary record was a LOCTRAN record that represented all enabled transactions.
Figure 2. Sample FETCH DETAIL output
This figure illustrates the use of the command FETCH DETAIL RESULT(TOKENB) INTO(AREA3)... to retrieve detail records.

You can modify the records in a summarized result set using the PERFORM or SET commands. This is equivalent to modifying all the records in the source result set that are represented by a given summary record. However, since each record in a summarized result set has a single OBJSTAT record associated with it (rather than one for each of the source records being modified), you may want to use the FETCH DETAIL command to determine the results of a summary action.

Another method of working with individual records from a summarized result set is by using the EXPAND command. This is similar to the FETCH command when used with the DETAIL option, but EXPAND creates a new result set containing one record for each of the records summarized by GROUP in an individual summary record. This allows you to perform further actions on the result set including using additional GROUP or FETCH commands. EXPAND includes a number of options for manipulating the record counter in order to select the summarized record you want to work with. It can also be used in conjunction with the MARK and UNMARK commands.

The OBJSTAT records in a source result set are not summarized when you issue a GROUP command. So the OBJSTAT records in a summarized result set do not represent the OBJSTAT information for all of the source records. However, the OBJSTAT records in a summarized result set do include a summary count, which indicates how many source records were combined to produce each summary record.

A summarized result set and its source result set should be thought of as a pair to be used together. They share certain attributes and the summarized result set has certain dependencies on the source result set:
  • A summarized result set cannot exist without the source result set from which it was built. If you discard a source result set, all the summarized result sets that were built from it are also discarded.
  • You can reuse a summarized result set only to resummarize the records in the same source result set. An existing summarized result set cannot be used as the target of a GROUP command for a different source result set.
  • A summarized result set cannot be used as the source of a COPY command.
  • If you modify a source or summarized result set in any way, all the summarized result sets that have been built from the source result set are rebuilt.
    Note: To prevent this from happening, you can specify the NOREFRESH option on the PERFORM or SET command.