We shall read all member names using LISTDS "Dataset" Members. But however, I felt that this technique requires some logic to ignore certain statements before we could really get hold of the member name.
So,how to read all members of a Dataset without having any additional logical overhead?
It is possible via LMMLIST. We will go through the steps briefly in this post.
Step 1: LMINIT
LMINIT generates a DataId for the dataset.
REXX can be executed in foreground or background. When we execute from background, the DDNAMES are already allocated. In Foreground, we have to allocate the DDNames. This DDName can be provided in the LMINIT or we shall directly provide the Dataset Name. When we are providing DDname, we should use the keyword DDNAME. When we are providing the dataset, we should use the keyword DATASET.
In our example, we are using DATASET.
Dataset = "DATASET('"Your-Dataset"')"
address "ISPEXEC"
"LMINIT" Dataset "DATAID(DataId) ENQ(SHR)"
Step 2: LMOPEN
LMOPEN opens dataset associated with DataId generated using the LMINIT step.
Option INPUT means its only read only.
Option OUTPUT means its for writing the dataset. When opened with OUTPUT option, then it is necessary to have a matching LMCLOSE. If LMCLOSE is not issued for the DataID, then the DataID is not released until ISPF terminates.
"LMOPEN DATAID("DataID") OPTION(INPUT)"
Step 3:
DO FOREVER
"LMMLIST DATAID("DataId") OPTION(LIST) MEMBER(Member) STATS(NO)" IF RC = 8 THEN LEAVE
SAY MEMBER
END
This step displays you all the member names.
Step 4:
"LMCLOSE DATAID("DATAID")"
Close the DataID.
Step 5:
"LMFREE DATAID("DATAID")"
Free the DataID.
Incase of questions, please drop your questions in the comments.
Subscribe to:
Post Comments (Atom)
Featured Post
REXX Skeleton: Submitting jobs through Rexx
Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....
-
Abend S013 SYSTEM COMPLETION CODE=013 REASON CODE=00000018 AN OPEN WAS ISSUED FOR A PARTITIONED DATASET. THE SPECIFIED MEMBER NAME WAS N...
-
A word is defined as a blank delimited set of characters within a string in REXX. The characters in a word can be alpha, numeric, alphanume...
-
String functions interrogate, compare, and manipulate character strings of data. Some of the built-in function are listed below: COPIES...
I've lately noticed all sorts of people writing
ReplyDeleteaddress 'TSO' or
address 'ISPEXEC'
Quoting the address specification is useless/redundant. The language spec REQUIRES a constant there. There is little you can do to get around that. Quoted or unquoted, the interpreter sees a constant.
Why do you think people do this?
Normally REXX is seldom learnt from Authenticated tutorials. People learn through examples from their colleagues or through internet. Over the internet, you shall see people using Quoting over ISPEXEC and TSO. The usage of Quoting and Unquoting wasn't consistent.
ReplyDeletenot sure why the command is returning RC = -3
ReplyDeleteaddress "ISPEXEC"
"LMINIT" Dataset "DATAID(DataId) ENQ(SHR)"
Not able to find the root cause.