Skip Sequential Access

In pure sequential access you read the file from start to finish (or from a START position to end) in key order. Sometimes you need to process only certain key ranges: for example, all records with keys from 1000 to 1999, then skip to 5000–5999, and so on. Reading the whole file and ignoring unwanted ranges wastes I/O. Skip sequential access lets you position (or "skip") to a key (or relative record number) and then read forward in key order from that point. You can later skip to another position (forward only—to a key greater than the current one) and read forward again. So you get sequential order within each range but can jump to the start of the next range. This page explains what skip sequential is, how it differs from pure sequential and dynamic access, how to use POINT/START and GET NEXT (or READ NEXT), and when to use it.

What Is Skip Sequential?

Skip sequential is an access pattern where records are read in ascending key (or RRN) order, but the starting position can be set to a specific key or RRN rather than always at the beginning of the file. You establish the initial position (e.g. with POINT or START), then issue GET NEXT (or READ NEXT) repeatedly to read records in order from that point. When you have finished one range, you can reposition to a key or RRN that is greater than the current position—that is the "skip"—and then continue reading forward from the new position. So you get multiple "forward passes," each starting at a chosen key. Backward skips (repositioning to a key lower than the current one) are not allowed in standard skip-sequential processing; the next position must be forward.

Skip Sequential vs Sequential vs Dynamic

Pure sequential access: you start at the beginning (or at a START key) and read forward to end of file in one pass. You do not reposition in the middle. Skip sequential: you can reposition to a key (or RRN) that is greater than the current position and then read forward again. So you might read keys 100–200, then skip to 500 and read 500–600, and so on. Dynamic access is more general: you can do random READ by key and READ NEXT, and START at any key; you can effectively do skip-sequential processing with dynamic access by using START at a key and then READ NEXT until you want to skip, then START at a higher key and READ NEXT again. So skip sequential is often implemented or used as a subset of dynamic behaviour: the constraint is that you only skip forward and then read forward. Some APIs or languages expose "skip sequential" as a distinct mode that enforces this pattern.

Sequential modes compared
ModeBehaviour
Pure sequentialStart at beginning (or START key); READ NEXT to end. One continuous forward pass.
Skip sequentialPosition at a key (POINT/START); READ NEXT forward. Can reposition to a key greater than current and read forward again. Multiple forward passes from different start points.
DynamicMix random and sequential; can START at any key and READ NEXT, or READ by key then READ NEXT. Similar to skip sequential but with full random access too.

Positioning: POINT and START

To begin a skip-sequential pass you must set the file position. In assembler or other low-level APIs this is often done with a POINT or similar call: you supply a key (or RBA, or RRN) and the access method sets the "current position" to that record (or the first record with key greater than or equal to the given key). In COBOL the equivalent is START: you move the key to the record key (or alternate key) and issue START file-name with a relational operator (e.g. KEY >= key-value). After START, the next READ NEXT returns the record at that position (or the first record in key order from that point). So POINT/START is the "skip": you skip to that key; then GET NEXT/READ NEXT is the "sequential" part: you read forward in order.

Forward-Only Skip

In standard skip-sequential semantics you are only allowed to skip to a position that is forward of the current one (a key greater than the current key, or an RRN greater than the current RRN). If you need to process an earlier range again, you would typically close and reopen the file, or use dynamic access and explicitly START at the earlier key (which may or may not be supported depending on the implementation). The forward-only rule keeps the implementation simple and avoids issues with buffer invalidation when moving backward. So when you design skip-sequential processing, order your ranges from low to high key and process them in that order.

Use Case: Multiple Key Ranges

A typical use is a batch job that must process only certain key ranges—for example, all orders for customer 1000–1999, then 3000–3999. With skip sequential you START at key 1000, READ NEXT until the key exceeds 1999 (or you hit end of file), then START at 3000 (a forward skip), READ NEXT until the key exceeds 3999, and so on. You never read the records between 2000 and 2999. That can significantly reduce I/O and CPU compared to reading the whole file and testing each key. The same idea applies when using alternate keys or RRN: you position at the start of the range and read forward until you leave the range, then skip to the next range.

Implementation in COBOL

In COBOL you use ACCESS MODE IS DYNAMIC (or the equivalent that supports both START and READ NEXT). Then for each range you move the low key to the record key, issue START with KEY >= key, and in a loop READ NEXT until the key is greater than the high key or you get end of file. To "skip" to the next range you move the next range's low key to the record key and issue START again. So skip-sequential is a way of using dynamic access: you restrict yourself to forward skips and forward reads. Some runtimes or products may offer a dedicated skip-sequential mode that enforces this and may optimize for it (e.g. buffer management).

Key Takeaways

  • Skip sequential means positioning at a key (or RRN) and then reading forward in key order with GET NEXT/READ NEXT; you can later skip to a new position (forward only) and read forward again.
  • Skips are allowed only to a key or position greater than the current one; backward skip-sequential is not supported.
  • Use POINT or START to set the position, then GET NEXT or READ NEXT to read in order. Repeat for each key range.
  • Useful when processing multiple key ranges without reading the whole file; order ranges from low to high and process in that order.
  • In COBOL, implement with ACCESS IS DYNAMIC, START at each range start, and READ NEXT until past the range end.

Explain Like I'm Five

Imagine a long line of toys in order. With normal sequential you start at the first toy and look at each one. With skip sequential you can run forward and "land" at toy number 10, then look at 10, 11, 12… until you decide to run forward again and land at toy 20, then look at 20, 21, 22… You are only allowed to run forward to a higher number, not backward. So you can look at different sections in order without looking at every toy in between.

Test Your Knowledge

Test Your Knowledge

1. In skip sequential, what direction can you skip?

  • Only backward
  • Only forward (to a key greater than current)
  • Both directions
  • Neither

2. What do you use after positioning for skip sequential read?

  • READ by key
  • GET NEXT / READ NEXT to read forward in key order
  • Only POINT
  • WRITE

3. Why use skip sequential instead of full sequential?

  • It is faster for every case
  • To process only certain key ranges without reading the whole file
  • To allow backward reads
  • To avoid using an index
Published
Updated
Read time4 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: IBM z/OS 2.5 documentationSources: IBM DFSMS Access Method Services, z/OS VSAM documentationApplies to: z/OS 2.5