# Basic sequential access method

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Basic_sequential_access_method
> Markdown URL: https://mediated.wiki/source/Basic_sequential_access_method.md
> Source: https://en.wikipedia.org/wiki/Basic_sequential_access_method
> Source revision: 1296442980
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Access method to read and write datasets sequentially}}
In [IBM mainframe](/source/IBM_mainframe) [operating system](/source/operating_system)s, '''Basic sequential access method''' ('''BSAM''')<ref>{{cite book|publisher=IBM|title=IBM System/360 Operating System Sequential Access Methods Program Logic Manual|id=Y28-6604-1|date=January 1967|url=http://www.bitsavers.org/pdf/ibm/360/os/plm_1966-67/Y28-6604-1_Sequential_Access_Methods_PLM_Jan67.pdf}}</ref> is an [access method](/source/access_method) to read and write [dataset](/source/data_set_(IBM_mainframe))s sequentially. BSAM is available on [OS/360](/source/OS%2F360), [OS/VS2](/source/OS%2FVS2), [MVS](/source/MVS), [z/OS](/source/z%2FOS), and related operating systems.

BSAM is used for devices that are naturally sequential, such as [punched card](/source/punched_card) readers, punches, [line printer](/source/line_printer)s, and [magnetic tape](/source/Magnetic_tape_data_storage). It is also used for data on devices that could also be addressed directly, such as [magnetic disks](/source/Disk_storage). BSAM offers device independence: to the extent possible, the same [API](/source/Application_programming_interface) calls are used for different devices.

BSAM allows programs to read and write physical [blocks](/source/Block_(data_storage)) of data, as opposed to the more powerful but less flexible [Queued Sequential Access Method](/source/Queued_Sequential_Access_Method) (QSAM) which allows programs to access logical records within physical blocks of data.
The BSAM user must be aware of the possibility of encountering short (truncated) blocks (blocks within a dataset which are shorter than the BLKSIZE of the dataset), particularly at the end of a dataset, but also in many cases within a dataset. QSAM has none of these limitations.

==Application program interface==
The programmer specifies <code>DSORG=PS</code> in his [Data Control Block](/source/Data_Control_Block) (DCB) to indicate use of BSAM.
As a ''basic'' access method BSAM reads and writes member data in [blocks](/source/Block_(data_storage)) and the I/O operation proceeds [asynchronously](/source/Asynchronous_I%2FO) and must be tested for completion using the <code>CHECK</code> macro.<ref name=Macro>{{cite book|last1=IBM Corporation|title=OS Data Management Macro Instructions|date=June 1973|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/os/R21.7_Apr73/GC26-3794-1_OS_Data_Management_Macro_Instructions_Rel_21.7_Jun73.pdf|accessdate=August 19, 2016}}</ref> BSAM uses the standard system macros <code>OPEN</code>, <code>CLOSE</code>, <code>READ</code>, <code>WRITE</code>, and <code>CHECK</code>. The <code>NOTE</code> macro instruction returns position of the last block read or written, and the <code>POINT</code> macro will reposition to the location identified by a previous <code>NOTE</code>.<ref name=Macro />

If the dataset is unblocked, that is, the logical record length (LRECL) is equal to the physical block size (BLKSIZE), BSAM may be utilized to simulate a directly accessed dataset using <code>NOTE</code> and <code>POINT</code> on any supported direct access device type (DEVD=DA), and some primitive applications were designed in this way.

==Similar facilities==
The BSAM application program interface can be compared with the interface offered by ''open'', ''read'', ''write'' and ''close'' calls (using file handles) in other operating systems such as [Unix](/source/Unix) and [Windows](/source/Microsoft_Windows). <code>POINT</code> provides an analog of ''seek'' or ''lseek'', and ''ftell'' is the equivalent of <code>NOTE</code>.

==See also==
*[Queued Sequential Access Method](/source/Queued_Sequential_Access_Method) (QSAM)
*[Hierarchical Sequential Access Method](/source/Hierarchical_Sequential_Access_Method) (HSAM)
*[Basic Indexed Sequential Access Method](/source/Basic_Indexed_Sequential_Access_Method) (BISAM)
*[Queued Indexed Sequential Access Method](/source/Queued_Indexed_Sequential_Access_Method) (QISAM)
*[Hierarchical Indexed Sequential Access Method](/source/Hierarchical_Indexed_Sequential_Access_Method) (HISAM)

==References==
<references />

{{Mainframe I/O access methods}}

Category:IBM mainframe operating systems

---
Adapted from the Wikipedia article [Basic sequential access method](https://en.wikipedia.org/wiki/Basic_sequential_access_method) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Basic_sequential_access_method?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
