VSAMRecordCountGen
The VSAMRecordCountGen counts the number of records in a VSAM (Virtual Storage Access Method) file. It supports both fixed-length and variable-length VSAM records and handles common encoding formats used in mainframe environments.
Comparison with FileRowCountGen
| Feature | FileRowCountGen | VSAMRecordCountGen |
|---|---|---|
File Type |
Text files |
VSAM files |
Record Detection |
Line-based (newline) |
Byte-based with configurable delimiters |
Encoding Support |
Default system encoding |
EBCDIC (cp037, cp500, etc.) and ASCII |
Use Case |
Regular text files |
Mainframe VSAM files |
Required Parameters
| Parameter | Type | Description |
|---|---|---|
| filePath | String | Base directory path where the VSAM file is located |
| fileName | String | Name of the VSAM file to count records from |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fileSubDir |
String |
- |
Optional subdirectory under filePath |
recordLength |
Integer |
- |
Length of each record in bytes (required for fixed-length records) |
recordsToIgnore |
Long |
0 |
Number of records to subtract from the total count |
refresh |
Boolean |
false |
If true, recalculates the count on each iteration |
variableLengthRecords |
Boolean |
false |
Set to true for variable-length records |
recordDelimiter |
String |
null |
Required for variable-length records. Delimiter used to separate records. Supports escape sequences: \r, \n, \t, \0. No default value. |
fileEncoding |
String |
cp037 |
Character encoding (e.g., cp037, cp500 for EBCDIC). Used for encoding delimiters (except ASCII control characters which always use US-ASCII). |
Record Format Support
Fixed-Length Records (Default)
For fixed-length VSAM files:
- Set recordLength to the number of bytes per record (e.g. 80).
- The generator reads the file in fixed-size chunks.
- Partial records at the end are counted as one record.
Variable-Length Records
For variable-length VSAM files:
- Set variableLengthRecords to ‘true’.
-
Specify recordDelimiter using one or more of the following supported escape sequences:
- \r – Carriage return (CR)
- \n – Line feed (LF)
- \r\n – Carriage return and line feed (CRLF)
- \t – Tab
- \0 – Null
- Optionally, set fileEncoding to specify the encoding used for delimiter characters (default: cp037).
- Control characters (\r, \n, \t, \0) are automatically encoded as US-ASCII regardless of fileEncoding.
- Other delimiter characters use the specified encoding, ensuring delimiters work correctly across EBCDIC and ASCII files.
File Encoding Support
The generator supports various EBCDIC encodings, as well as ASCII encoding:
| Encoding | Description |
|---|---|
cp037 |
US/Canada EBCDIC (default) |
cp500 |
International EBCDIC |
cp1047 |
Latin-1 EBCDIC |
| cp273 | German EBCDIC |
| cp277 | Danish/Norwegian EBCDIC |
| cp278 | Finnish/Swedish EBCDIC |
| cp280 | Italian EBCDIC |
| cp284 | Spanish EBCDIC |
| cp285 | United Kingdom (UK) EBCDIC |
| cp297 | French EBCDIC |
US-ASCII |
ASCII encoding |
Generator Usage Examples
Example 1 - Count Fixed-Length VSAM Records
- filePath = #{resource.output.directory}
- fileSubDir = vsamFiles
- fileName = CUSTOMER.KSDS
- recordLength = 100

Example 2 - Count Variable-Length Records
- filePath = #{resource.output.directory}
- fileSubDir = vsamFiles
- fileName = TRANSACTION.ESDS
- variableLengthRecords = true
- recordDelimiter = \n
- fileEncoding = cp037

Example 3 - Dynamic Count with Refresh
For scenarios where the VSAM file might change during processing:
- filePath = #{resource.output.directory}
- fileSubDir = vsamFiles
- fileName = ACTIVE.KSDS
- recordLength = 150
- refresh = true

Error Handling
- File not found or cannot be opened: Verify that the file path, name, and optional subdirectory are correct.
- Missing recordLength: Specify recordLength for fixed-length records.
- Missing recordDelimiter: Specify recordDelimiter for variable-length records.
- Invalid recordsToIgnore: The value must be a non-negative integer.
- Negative record count: The value of recordsToIgnore exceeds the calculated record count.
- File reading errors: An I/O error occurs while reading the file.
Important Considerations
- Performance: The generator reads the entire file to count records, which may take time for large files. For very large files, consider setting refresh to ‘false’ to avoid recounting on every iteration.
- RealData Mode: The count is performed during initialization when using RealData mode. In non-RealData modes, the generator returns a value of 1.
- File Paths: Both absolute and relative paths are supported.
Related Components
- VSAMFileMaskReceiver: Reads and masks records in VSAM files, rather than counting them.
Article Feedback: Was this helpful?
Give feedback