Previous Topic: Output Variables

Next Topic: OPSWAIT Function

Types of OPSVSAM Functions

The following lists and describes the available OPSVSAM functions:

Example: OPSVSAM

This example illustrates performing VSAM file operations on a VSAM KSDS with a character key length of 10 that begins in position 1 of a maximum 100-byte record:

Signal On Syntax Name VSAM_ERROR /* Dynamically allocate and open the VSAM file */ vrc = Opsvsam('OPEN',,'TEST.VSAM.KSDS','O') If opsrc > 0 Then Signal VSAM_ERROR /* Insert a new record with key = OPSMVS */ newrec = Substr('OPSMVS',1,opskeyln) || 'TEST DATA RECORD' vrc = Opsvsam('INSERT',opsdd,newrec) If opsrc > 0 Then If opsrc = 8 & opsre = 8 Then Say 'Duplicate record:' newrec Else Signal VSAM_ERROR /* Retrieve and delete the record we just added */ vrc = Opsvsam('READUP',opsdd,Substr(newrec,1,opskeyln)) If opsrc = 0 Then vrc = Opsvsam('DELETE',opsdd) Else Signal VSAM_ERROR /* Clean up and exit */ Signal ALL_DONE /* VSAM error procedure */ VSAM_ERROR: Say 'OPSVSAM error: RC='opsrc 'REASON='opsre 'DD='opsdd Do While Queued() > 0 Pull xdqmsg Say xdqmsg End ALL_DONE: lrc = opsrc vrc = Opsvsam('CLOSE',opsdd) Exit lrc