IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to open a DSN using REXX & execute edit macro commands


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Y Marwaha

New User


Joined: 05 Jun 2020
Posts: 5
Location: India

PostPosted: Fri Jun 05, 2020 7:30 pm
Reply with quote

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
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Jun 05, 2020 8:38 pm
Reply with quote

First, your edit command should invoke the macro which should be a separate member to yiour REXX code e.g.
Code:
ADDRESS ISPEXEC "EDIT DATASET("JCLDSN") MACRO(your_macro) "


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


Garry
Back to top
View user's profile Send private message
Y Marwaha

New User


Joined: 05 Jun 2020
Posts: 5
Location: India

PostPosted: Fri Jun 05, 2020 10:44 pm
Reply with quote

Thank you for your reply.

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:

Code:
//STEP01 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=A
//SYSIN DD DUMMY
//SYSUT1 DD DSN=TEST.IEBGNR.IN.FILE,DISP=OLD
//SYSUT2 DD DSN=TEST.IEBGNR.OUT.FILE,DISP=(NEW,CATLG,DELETE),
// UNIT=PROD1,SPACE=(CYL,(5,5)),
// DCB=(RECFM=FB,LRECL=110,BLKSIZE=1100)
//*
//STEP02 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DUMMY,DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
//SYSUT2 DD DSN=PRT.TST.OUT.EMPT1,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,2))
//SYSIN DD DUMMY



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-
Code:

DSN=TEST.IEBGNR.IN
DSN=TEST.IEBGNR.OUT
DSN=PRT.TST.OUT.EMPT1
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Jun 05, 2020 11:14 pm
Reply with quote

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.

Garry.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Jun 06, 2020 12:17 am
Reply with quote

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.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Sat Jun 06, 2020 7:15 am
Reply with quote

I think you should use the Searchfor utility, then post process it's print file to get into a format that you like.
Back to top
View user's profile Send private message
Y Marwaha

New User


Joined: 05 Jun 2020
Posts: 5
Location: India

PostPosted: Sat Jun 06, 2020 8:16 am
Reply with quote

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.
Code:
ADDRESS TSO "VIEW DATASET("JCLDSN") MACRO (DSNLIST)"


Thank you everyone for your valuable inputs!
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Jun 06, 2020 12:58 pm
Reply with quote

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

    "isredit end"

    exit
  end

!tabl = getvar('ispTABL')

drop isptabl
drop exec

"ispexec lminit dataid("isptabl") ddname(isptabl) enq(shrw)"
"ispexec lminit dataid("exec")",
               "dataset('"getvar('execRAHP')"') enq(shrw)"

do u = 1 to user.0
  temp  = copies('$', length(user.u))
  ucmds = user.u

  "alloc f(i) da('"!tabl"("user.u"cmds)') shr reu"
  "alloc f(o) da('"!tabl"("temp"cmds)') shr reu"

  "execio * diskr i (finis"
  "execio" queued() "diskw o (finis"

  "ispexec select pgm(ispucm) parm("temp")"

  "ispexec vput (ucmds) shared"
  "ispexec edit   dataid("isptabl") member("temp"cmds) macro("moi")"

  "execio * diskr o (finis"
  "execio" queued() "diskw i (finis"

  "free f(i)"
  "free f(o)"

  "ispexec lmcopy fromid("isptabl")   todataid("exec")",
                 "frommem("temp"cmds) tomem("user.u"cmds) replace"
end

"ispexec vput (ucmds) shared"
"ispexec edit   dataid("exec") member(rexxdate) macro("moi")"

"ispexec lmfree dataid("exec")"
"ispexec lmfree dataid("isptabl")"
exit


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.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Sat Jun 06, 2020 3:17 pm
Reply with quote

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.

1. Driver REXX
Code:
ADDRESS ISPEXEC 'VGET (HQL DSN) PROFILE'
QUAL = STRIP(HQL)
JCLDSN = STRIP(DSN)
p='name.of.output.dataset'
ADDRESS ISPEXEC "VIEW DATASET("JCLDSN") macro(filter) parm(p)"


2. Edit macro names 'FILTER'
Code:
ADDRESS ISREDIT "MACRO noprocess (outds)"
ADDRESS ISREDIT
'X ALL'
'F ALL "DSN="'
'DEL ALL X'
"Create '"outds"' .zfirst .zlast"
"Cancel"
exit

Yes, you can combine the programs into one, but that gets slightly complicated
Back to top
View user's profile Send private message
Y Marwaha

New User


Joined: 05 Jun 2020
Posts: 5
Location: India

PostPosted: Sat Jun 06, 2020 4:18 pm
Reply with quote

Quote:
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.
Back to top
View user's profile Send private message
Y Marwaha

New User


Joined: 05 Jun 2020
Posts: 5
Location: India

PostPosted: Sat Jun 06, 2020 4:31 pm
Reply with quote

Willy Jensen wrote:
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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top