Modernization Hub

BSAM - Basic Sequential Access Method

Enhanced Definition

BSAM (Basic Sequential Access Method) is a fundamental data access method in IBM z/OS that provides low-level control for reading and writing records to sequential data sets. It offers direct control over I/O operations, requiring the application program to manage buffering, error handling, and synchronization. BSAM is typically used when fine-grained control over I/O is necessary, often in system utilities or assembler language programs.

Key Characteristics

    • Low-Level Control: Provides direct access to physical I/O operations, giving the programmer explicit control over data transfer.
    • Sequential Processing: Primarily designed for reading or writing records in a strictly sequential order from beginning to end.
    • Programmer Responsibility: The application program is responsible for managing I/O buffers, handling end-of-file conditions, and implementing error recovery routines.
    • Macro-Based API: Accessed through a set of assembler macros such as OPEN, CLOSE, READ, WRITE, GET, PUT, and CHECK.
    • Unbuffered or User-Buffered: While it can use system buffers, the programmer often manages their own buffers for optimal control and performance.
    • Device Independence: Can operate on various sequential devices, including DASD, tape, and unit record devices, with appropriate DCB definitions.

Use Cases

    • System Utilities Development: Used extensively by IBM system utilities (e.g., IEBGENER, IDCAMS) for high-performance data copying, merging, and manipulation.
    • Custom I/O Routines: When an application requires highly optimized or non-standard sequential I/O processing that higher-level access methods cannot provide.
    • Tape Data Processing: Efficiently reading from or writing to magnetic tape data sets, where sequential access is the natural mode of operation.
    • Assembler Language Programs: Frequently employed in assembler programs to achieve maximum performance and direct control over hardware resources.
    • Specialized Data Handling: For applications that need to process data records without the overhead or automatic features of queued access methods.

Related Concepts

BSAM is a foundational access method, often contrasted with QSAM (Queued Sequential Access Method). QSAM builds upon BSAM, providing automatic buffering, blocking/deblocking, and error handling, significantly simplifying sequential I/O for application programmers, especially in high-level languages like COBOL. Both BSAM and QSAM utilize a DCB (Data Control Block) to define the characteristics of a data set, and the data sets themselves are defined in JCL using DD statements. BSAM provides the underlying mechanism for sequential data set operations on z/OS.

Best Practices:
  • Optimize Buffer Management: Carefully manage I/O buffers (BUFNO, BLKSIZE) to align with device characteristics and application processing patterns for optimal performance.
  • Implement Robust Error Handling: Since BSAM does not automatically handle I/O errors, thoroughly implement error detection and recovery routines within the application program.
  • Proper Resource Management: Always ensure that data sets are properly OPENed before use and CLOSEd after processing to release system resources and ensure data integrity.
  • Consider QSAM for Applications: For most application programming tasks, especially in COBOL or PL/I, prefer QSAM over BSAM due to its simplified programming model and automatic I/O management, unless specific low-level control is absolutely critical.
  • Understand DCB Attributes: Have a clear understanding of all relevant DCB attributes (e.g., RECFM, LRECL, BLKSIZE) and their impact on BSAM operations and data set organization.

Related Vendors

Data Access

1 product

IBM

646 products

Tone Software

14 products

Trax Softworks

3 products

Macro 4

20 products

UNICOM Systems

35 products

Related Categories

Operating System

154 products

Administration

395 products

Automation

222 products

Browse and Edit

64 products

CICS

214 products