KeyEQ (Dataset function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{Template:Dataset:KeyEQ subtitle}} ==Syntax== {{Template:Dataset:KeyEQ syntax}} ===Syntax terms=== <table class="syntaxTable"> <tr><th>dataset</th> <td>Position to a specifi...")
 
No edit summary
Line 1: Line 1:
{{Template:Dataset:KeyEQ subtitle}}
{{Template:Dataset:KeyEQ subtitle}}
This function sets the read position of a VSAM dataset to the record key specified. A subsequent read of the <var>Dataset</var> object will return the specified record.


==Syntax==
==Syntax==
{{Template:Dataset:KeyEQ syntax}}
{{Template:Dataset:KeyEQ syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>dataset</th>
<tr><th>%boolean</th>
<td>Position to a specific key within a VSAM dataset in order to read beginning from that record within a <var>Dataset</var> object.</td></tr>
<td>A variable to receive the result of the position function of the <var class="term">dataset</var> object.
<tr><th>sl</th>
</td></tr>
<td>A <var>Stringlist</var> object; items from this are written to <var class="term">dataset</var>.</td></tr>
<tr><th>Key</th>
<tr><th><var>From</var></th>
<td>The value used to position the <var>Dataset</var> object.
<td>A number specifying one less than the number of the first item of <var class="term">sl</var> to write.  It must be less than the value of <var class="term">sl</var>:<var>[[Count (Stringlist function)|Count]]</var>.<br/>The default value of this argument is 0.</td></tr>
</td></tr>
<tr><th><var>For</var></th>
<td>The number of <var class="term">sl</var> items to write.<br/>The default value of this argument is <var class="term">sl</var>:<var>[[Count (Stringlist function)|Count]]</var> - <var class="term">From</var>.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<li>The default for <var>Key</var> is nulls.
Setting the value to nulls will cause reads to begin from the first record.</li>.
</ul>
==Examples==
==Examples==
ALLOCATE DATASET VSAMALT WITH SCOPE=SYSTEM DSN=RDP.VSAM.AIX -
VSAM KEYED OLD SHARE
ALLOCATE DATASET VSAMDS WITH SCOPE=SYSTEM DSN=RDP.VSAM -
VSAM KEYED OLD SHARE
Begin
%l is longstring
%ds is object dataset
%ds = new('VSAMALT')
if %ds:open then
print "Error opening dataset"
stop
end if
%key is string len 4 initial('AAAA')
print %ds:keyeq(%key)
%l = %ds:readRecord
%ds:close
%ds = new('VSAMDS')
if %ds:open then
print "Error opening dataset"
stop
end if
print %ds:keyge(%l:Substring(10,8))
repeat forever
%l = %ds:readRecord
if %ds:state eq afterEnd then
print 'end of rec'
loop end
end if
print %l
end repeat
%ds:close
End
FREE VSAMALT
FREE VSAMDS
==See also==
==See also==
{{Template:Dataset:WriteRecords footer}}
{{Template:Dataset:KeyEQ footer}}

Revision as of 16:06, 14 April 2021

Template:Dataset:KeyEQ subtitle

This function sets the read position of a VSAM dataset to the record key specified. A subsequent read of the Dataset object will return the specified record.

Syntax

Syntax

Template loop detected: Template:Dataset:KeyEQ syntax

Syntax terms

%boolean A Boolean enumeration value
key A key object.

Syntax terms

%boolean A variable to receive the result of the position function of the dataset object.
Key The value used to position the Dataset object.

Usage notes

  • The default for Key is nulls. Setting the value to nulls will cause reads to begin from the first record.
  • .

Examples

ALLOCATE DATASET VSAMALT WITH SCOPE=SYSTEM DSN=RDP.VSAM.AIX - VSAM KEYED OLD SHARE ALLOCATE DATASET VSAMDS WITH SCOPE=SYSTEM DSN=RDP.VSAM - VSAM KEYED OLD SHARE Begin %l is longstring %ds is object dataset %ds = new('VSAMALT') if %ds:open then print "Error opening dataset" stop end if %key is string len 4 initial('AAAA') print %ds:keyeq(%key) %l = %ds:readRecord %ds:close %ds = new('VSAMDS') if %ds:open then print "Error opening dataset" stop end if print %ds:keyge(%l:Substring(10,8)) repeat forever %l = %ds:readRecord if %ds:state eq afterEnd then print 'end of rec' loop end end if print %l end repeat %ds:close End FREE VSAMALT FREE VSAMDS

See also

Template:Dataset:KeyEQ footer