Hi,
I'm new to REXX and have been trying to create a utility that will do the following:
1. Accept the PDS name and the member from the user.
2. Open this DSN i.e. PDS(MEM)
3. Find all the lines with string 'DSN=', and copy them in an output file.
I have coded Panel to accept the values from user and that is working fine, but I'm facing the problem in integrating step 2 and step 3. Once I open the dataset in view mode then the control is being passed to the user, and once the user exits the DSN, only then the control is passed back to the REXX code. So, find/del commands are not working therefore, step 3 is not executing.
Is there any other way which can be used to open the dataset and execute the find commands?
I did look into REXX manuals, but I wasn't able to find any clarity.
I am using the below code for step 2:
ADDRESS ISPEXEC 'VGET (HQL DSN) PROFILE'
QUAL = STRIP(HQL)
JCLDSN = STRIP(DSN)
ADDRESS ISPEXEC "EDIT DATASET("JCLDSN")"
ADDRESS ISREDIT "MACRO";;
ADDRESS ISREDIT ;;
'X ALL "//*"'
'DEL ALL X'
'F ALL "DSN="' /*SEARCHING DSN=*/
J = 1
DO WHILE RC= 0 /*MAIN LOOP*/
SAY 'INSIDE MAIN LOOP'
'(LINEDD) = LINE .ZCSR' /*GETTING CURSOR DETAILS*/
.......... /*Rest of the processing*/
'F NEXT "DSN."'
END
You don't specify where tthe copy is to me made... I'd suggest your REXX first copy the member to the target dataset and then have your EDIT chnage the target dataset using your macro to:
Code:
ADDRESS ISREDIT ;;
'X ALL'
'F ALL "DSN="' /*SEARCHING DSN=*/
'X ALL "//*"'
SAVE
I have one correction in my code, I'm using the view command not the edit command i.e. ADDRESS ISPEXEC "VIEW DATASET("JCLDSN")".
I don't want to edit the original dataset.
I'll try creating separate macro member and try it calling from my rexx.
Let me give you an example of what I'm looking for:
Let's say the original dataset: TEST.XYZ.JCLLIB(JCL1) is stated below:
Once the rexx code runs, it will search for all the óccurences of 'DSN=' and write them in an output file. The output file should look something like this:
TEST.XYZ.JCLLIB.OUT-
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
My suggestion was that you first create TEST.XYZ.JCLLIB.OUT in your REXX by copying the source PDS member. This could be done by reading the member into a stem variable & writing to the desired final output dataset. Then your REXX can invoke the EDIT macro against TEST.XYZ.JCLLIB.OUT which will leave just the lines with DSN= in the TEST.XYZ.JCLLIB.OUT dataset and the original input unchanged.
Once this is done, your REXX can return to loop prompting the user for DSN+MEMBER.
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
At some stage you will want to do this with a single combined REXX exec/edit macro, so that everything stays together. Just put something into the shared pool before you invoke the view or edit with the same code, retrieve it, test it, and branch accordingly.
I've been doing this for years, and it keeps things tidy.
I tried copying the original member into another dataset and then running the edit macro but that didn't work for me.
But I did try the view command with a separate Macro and it worked perfectly i.e.
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
prino wrote:
At some stage you will want to do this with a single combined REXX exec/edit macro, so that everything stays together. Just put something into the shared pool before you invoke the view or edit with the same code, retrieve it, test it, and branch accordingly.
I've been doing this for years, and it keeps things tidy.
And here's an example, which I've been using for years. It allows me to update the normally in-use ISPF command tables. You still have to get out of ISPF and back in, but the changes are permanent, if you want temporary changes, there are plenty of execs around to achieve that.
It's invoked as a TSO command, and near the bottom it's used as a macro, and as you can see, by using the first two statements, it can even find its own name, so you can call it whatever you like.
Code:
/* REXX exec to update my command tables */
/*** trace ?r ***************************************************** \| *
* (C) Copyright Robert AH Prins, 2009-2011 *
************************************************************************
* ------------------------------------------------------------------ *
* | Date | By | Remarks | *
* |------------+------+----------------------------------------------| *
* | | | | *
* |------------+------+----------------------------------------------| *
* | 2011-04-18 | RAHP | Correct setting of dates | *
* |------------+------+----------------------------------------------| *
* | 2010-05-13 | RAHP | Use ISPTABL, not ISPPROF | *
* |------------+------+----------------------------------------------| *
* | 2009-04-16 | RAHP | Now RAHP- and HERECMDS | *
* |------------+------+----------------------------------------------| *
* | 2009-04-08 | RAHP | Initial version | *
* |------------+------+----------------------------------------------| *
************************************************************************
* UCMDS is a REXX exec to update my site-independent (RAHPCMDS) and *
* site-specific (HERECMDS) tables. Because it is not possible to *
* update an open ISPF command table, this exec copies it to $$$$CMDS, *
* invokes ISPUCM (the command table update program) with a parameter *
* of $$$$ and then copies the updated table back to USERCMDS. Note *
* that is necessary to restart ISPF to enable any new commands. *
* *
* Copies of the new command tables are saved to my exec library. *
************************************************************************
* Send questions, suggestions and/or bug reports to: *
* *
* robert{a}prino{d}org *
* *
* Robert AH Prins *
* Ozkiniu gatve 48 *
* 08410 Vilnius *
* Lithuania *
************************************************************************
* This program is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/> *
***********************************************************************/
parse source source
parse value source with . . moi .
user.1 = 'RAHP'
user.2 = 'HERE'
user.0 = 2
"ispexec vget (ucmds) shared"
if rc = 0 then
do
"ispexec verase (ucmds) shared"
temp = copies('$', length(ucmds))
"isredit macro"
"isredit (MEM) = member"
now = date('S')
now = substr(now, 1, 4) || '/' ||,
substr(now, 5, 2) || '/' ||,
substr(now, 7, 2)
select
when mem = temp'CMDS' then
"isredit c '"temp"CMDS' '"ucmds"CMDS' first"
/*
when mem = 'REXXDATE' then
do u = 1 to user.0
"isredit f 'm.q."user.u"CMDS = ' first"
if rc = 0 then
do
"isredit level 0"
"isredit (L) = line .zcsr"
l = overlay(now, l, 36)
"isredit line .zcsr = (L)"
end
end
*/
otherwise
end
You need to change the "user." stem variables with your to-be-updated command tables. The "getvar()" rourtine is external and returns data based on the key passed, I use it to make all of my execs nearly site-independent, if I move to a new site, it's the only member I have to update.
The commented out "REXXDATE" member is used by another exec, it builds a Windows batch file with "touch file date time" commands that is embedded as a message in the XMIT files I create to make off-z/OS backups of my stuff, and allows me to set the Windows last modification date of the extracted members to the same date as on z/OS.
You are on the right track. I suggest that you split your program into 2 parts, a driver REXX and an ISPF edit macro. In the macro there is really no need to loop over find, you can just write the lines remaining after a find/delete sequence. Do remember to CANCEL afterwards, even though you are using VIEW.
And here's an example, which I've been using for years. It allows me to update the normally in-use ISPF command tables. You still have to get out of ISPF and back in, but the changes are permanent, if you want temporary changes, there are plenty of execs around to achieve that. ...
Thank you for this, it is actually going come in quite handy.
You are on the right track. I suggest that you split your program into 2 parts, a driver REXX and an ISPF edit macro. In the macro there is really no need to loop over find, you can just write the lines remaining after a find/delete sequence. Do remember to CANCEL afterwards, even though you are using VIEW.
Yes, I have split the REXX into two parts. One just has the macro commands. However, I did not use the CANCEL command, I think that's the reason why the the DSN is opened in view mode and I have to press F3 to execute the rest of the REXX.