GET (QSAM)
Syntax:
GET(ddname)
Arguments:
-
ddname
-
is the 1 to 8 character name that identifies the data set
you want to process. This name needs to have been
previously associated with the data set, either via the
ALLOCATE command or JCL DD statement, and opened via the
OPEN
function.
Module Name:
SWXGET
Service Description:
The GET function is used to retrieve records from sequential data
sets (permanent and temporary), SYSIN data sets, and PDS members.
Before you can use the GET function you must first allocate and
open (using the
OPEN
function) the data set associated with the
ddname argument. If you do not, an error will occur. Each
invocation of GET retrieves the next record (or an end-of-file
indication if there are no more records).
GET also is used to update records. If you wish to update
records, you must
OPEN
the ddname using the 'UPDATE' option. After you have read a
record using GET, the next
PUT
will re-write the record to the file.
Returned Information:
The GET function, if successful, returns the record requested. If
the GET request fails, a null string (zero length) is returned.
If the GET function is CALLed, the REXX special variable, RESULT,
will contain the returned record.
After completion of a GET function call, the RC and REASON
variables will contain return code information. You should treat
these variables as "read only" and make no attempt to modify any
of them. The variables are:
-
RC
-
Contains the QSAM GET return code. An RC of zero means the
operation was completed successfully. A return code of 8
indicates that no more records are available (end-of-file).
-
REASON
-
Contains the QSAM GET reason code.
Examples:
-
Sequentially retrieve records from a data
set:
record = get('indd')
do while rc = 0
parse var record 22 ssn +11 lname +10 fname +10
say left(fname,10) left(lname,10) left(ssn,11)
record = get('indd')
end
-
Count the records of a RECFM=FB data set. We can use the fact that
a zero-length record is impossible to simplify our logic:
i=0; do while get('indd')<>''; i=i+1; end
© Copyright 1998 by Open Software Technologies, Inc.