COUNT
The COUNT primary command enables you to count segments, extract concatenated keys of segments, or both. Multiple COUNT primary commands can be specified in a single execution.

OPTION | Identifies special processing.
When specified with the SEGMENT object keyword, the concatenated key for only the specified segment name is provided. When specified with the CHILD object keyword, the concatenated key for all the segments under the current parent is provided. |
MAXIMUM | Defines the number of selected database segments to process, not counting segments that are skipped. See MAXIMUM Keyword for a complete description of this keyword.
|
START | Defines the occurrence number of the selected segment where processing is to begin. See START Keyword for a complete description of this keyword.
|
SKIP | Alters the processing sequence. See SKIP Keyword for a complete description of this keyword.
|
Examples
The following COUNT command statement causes all segments in the customer database to be counted:
PSB DBNAME=CUSTPDBD;
TITLE LINE01=’COUNT ALL SEGMENTS’;
COUNT SEGMENT=$ROOT MAX=ALL
CHILD MAX=ALL;
The following COUNT command statement causes all customer segments to be scanned and the concatenated keys to be written to an output PDS dataset member CUSTKEYS. A count of the total customer and customer remarks segments is given.
PSB DBNAME=CUSTPDBD;
SET OUTPUT=CUSTKEYS;
TITLE LINE01=’COUNT ALL CUSTOMER AND REMARKS SEGMENTS’;
COUNT SEGMENT=CUSTOMER MAX=ALL OPTION=CKEY
SEGMENT=CUSTRMKS MAX=ALL;
Following is an example of the format of an output dataset.
Column | Length | Description |
|---|---|---|
1 | 8 | segment name |
9 | 1 | unused |
10 | 1-n | concatenated key |
In this example, the COUNT command statement extracts the concatenated key of every hundredth customer segment and all the concatenated keys of the segment’s children. The data is written to an output dataset member (CUSTKEYS).
PSB PCB=2;
SET OUTPUT=CUSTKEYS;
TITLE LINE01=’CONCATENATED KEY OF EVERY 100TH CUSTOMER’;
COUNT SEGMENT=CUSTOMER MAX=ALL OPTION=CKEY START=100 SKIP=(1,99)
CHILD MAX=ALL OPTION=CKEY;
Related topics