I am trying to write a code, which can be used to open/view any member from production libraries. The member entered could reside in PDS for COBOL or JCL or PROC Controlcards Copybooks etc.
Assuming the code am trying to write is named zoom
The user will enter TSO ZOOM MEMNAME
This should search the MEMNAME in all production libraries and when it finds a member, it opens the Member from that PDS
I tried writing in both CLIST and REXX, and codes are as below
CLIST
Code:
PROC 1 MEM
CONTROL NOLIST NOSYMLIST NOCONLIST
NGLOBAL NUMBER
SET USRID = &STR(&SYSUID)
IF &LENGTH(&STR(&MEM)) >8 THEN DO
WRITE MEMBER NAME SHOULD NOT EXCEED 8 CHARS
EXIT
END
SYSCALL SHOW 'PROCLIB(&MEM.)'
SYSCALL SHOW 'PRODJCL(&MEM.)'
SYSCALL SHOW 'CTLCARDS(&MEM.)'
SYSCALL SHOW 'COBOL(&MEM.)'
SYSCALL SHOW 'MFS(&MEM.)'
SYSCALL SHOW 'CPY(&MEM.)'
WRITE MEMBER &MEM NOT FOUND
EXIT
SHOW: PROC 1 DSN
IF &SYSDSN(&DSN) = OK THEN DO
ISPEXEC VIEW DATASET(&DSN)
EXIT
END
END
This code is working fine, except for one issue that a member-name could be same for a JCL and a PROC, in that case, it opens the library listed first
which is PROCLIB. So, if a user wants to see a JCL, which has the same member-name as PROC, the above logic would not work.
To cater this, I did a code in REXX where user has to enter the member-name, code snippet below:
REXX
Code:
/* REXX */
ADDRESS ISREDIT
'MACRO (MEM)'
SAY ENTER MEM
PULL MEM
I = INDEX(MEM,BMP)
IF INDEX(MEM,BMP) = 6
THEN DO
SAY ENTER J TO VIEW JCL OR P TO VIEW PROC
PULL OPTION
IF OPTION = J THEN DO
ADDRESS ISPEXEC "VIEW DATASET('PRODJCL("MEM")')"
END
ELSE DO
ADDRESS ISPEXEC "VIEW DATASET('PROCLIB("MEM")')"
END
END
This code is working fine too, but here the user has to enter the command
TSO ZOOM
and then has to enter the member-name, somewhat like below
Code:
TSO ZOOM
Code:
ENTER MEM
Is there a way that the user can enter command in one line like
TSO ZOOM MEMNAME
and the MEMNAME gets stored in a variable which can be used
for below code check; below code check is needed as all JCLs or PROCs will have last 3 letters as BMP
Code:
I = INDEX(MEM,BMP)
IF INDEX(MEM,BMP) = 6
The idea is to enter one line command as TSO ZOOM MEMNAME and
to avoid the logic of SAY MEMNAME and PULL MEMNAME
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
To start with, I would not write in clist, EVER. It has not been the recommend language since 1985.
Next, sergeken is correct, use the ARG command.
Next, rather than use INDEX, use POS. It is more modern and preferred.
Be aware, the syntax is the reverse.
In fact, the RIGHT command would be best I think.
Just in case the member name length is not = 8.
This exec itself is not an edit macro, so leave off those commands.
Your alignment is really off. You can't tell which end lines up with which do.
I was intrigued by this so I wrote my own version of this.
There are two programs involved. The ZOOM exec, and the TOTLINES edit macro to determine if the member exists.
See the code here: First ZOOM
Code:
/* REXX EXEC TO ZOOM INTO A PDS MEMBER */
ARG MEM
/* CHECK IF IN COBOL */
/* IF SO VIEW THIS DATASET THEN EXIT REXX EXEC */
"ISPEXEC VIEW DATASET('COBLIB("MEM")') MACRO(TOTLINES)"
"ISPEXEC VGET (TOTLINE) SHARED"
COBOLCNT = TOTLINE
IF COBOLCNT > 0 THEN DO
"ISPEXEC VIEW DATASET('COBLIB("MEM")')"
SIGNAL EXIT99
END
/* JCL AND PROC NAMES MUST END WITH BMP */
IF RIGHT(MEM,3) /= 'BMP' THEN DO
SAY 'JCL AND PROC NAMES MUST END WITH BMP'
SIGNAL EXIT99
END
/* CHECK IF IN PRODJCL */
"ISPEXEC VIEW DATASET('PRODJCL("MEM")') MACRO(TOTLINES)"
"ISPEXEC VGET (TOTLINE) SHARED"
JCLCNT = TOTLINE
/* CHECK IF IN PROCLIB */
"ISPEXEC VIEW DATASET('PROCLIB("MEM")') MACRO(TOTLINES)"
"ISPEXEC VGET (TOTLINE) SHARED"
PROCCNT = TOTLINE
/* BASED ON COUNTS VIEW CORRECT DATASET */
SELECT
WHEN JCLCNT > 0 & PROCCNT > 0 THEN DO
SAY 'ENTER J TO VIEW JCL OR P TO VIEW PROC'
PULL OPTION
IF OPTION = J THEN
"ISPEXEC VIEW DATASET('PRODJCL("MEM")')"
ELSE
"ISPEXEC VIEW DATASET('PROCLIB("MEM")')"
END
WHEN JCLCNT > 0 THEN
"ISPEXEC VIEW DATASET('PRODJCL("MEM")')"
WHEN PROCCNT > 0 THEN
"ISPEXEC VIEW DATASET('PROCLIB("MEM")')"
OTHERWISE SAY 'MEMBER' MEM 'NOT FOUND IN ANY PRODUCTION PDS'
END
EXIT99: EXIT
Now TOTLINES edit macro:
Code:
/* REXX EXEC EDIT MACRO TO FIND THE TOTAL NUMBER OF LINES */
/* IN A DATASET. VALUE IS PLACED IN SHARED POOL */
You still don't use SITE command tables introduced more than a decade ago? Sheesh...
With VBACKEND:
Code:
/* REXX backend for the various Vx routines */
/*** trace ?r ***************************************************** \| *
* (C) Copyright Robert AH Prins, 2009-2015 *
************************************************************************
* ------------------------------------------------------------------ *
* | Date | By | Remarks | *
* |------------+------+----------------------------------------------| *
* | | | | *
* |------------+------+----------------------------------------------| *
* | 2015-09-13 | RAHP | Update comment | *
* |------------+------+----------------------------------------------| *
* | 2011-05-06 | RAHP | Cater for members moved to RAHP.CNTL | *
* |------------+------+----------------------------------------------| *
* | 2011-02-06 | RAHP | Handle '*' as membername | *
* |------------+------+----------------------------------------------| *
* | 2009-06-03 | RAHP | Explicitely lowercase the type | *
* |------------+------+----------------------------------------------| *
* | 2009-05-26 | RAHP | Initial version | *
* |------------+------+----------------------------------------------| *
************************************************************************
* VBACKEND is the backend for the following command table entries: *
* *
* - VRx - View/edit/browse REXX source from anywhere *
* - VPx - View/edit/browse PLI source from anywhere *
* - VTx - View/edit/browse TEXT members from anywhere *
* - VCx - View/edit/browse CNTL members from anywhere *
* - VJx - View/edit/browse PROC members from anywhere *
************************************************************************
* 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/> *
************************************************************************
* For more z/OS tools and contact details go to: *
* *
* <https://prino.neocities.org/zOS/zOS%20Tools.html> *
***********************************************************************/
parse source source
parse value source with . . moi .
"ispexec control errors return"
parse value space(arg(1)) with type ',' mode ',' parm ' ' .
type = translate(type,,
'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
drop dsn
if parm = '*' then
parm = ''
if mode = 'browse' then
macro = ''
else
macro = 'macro(ecntl)' /* Replace by personal favorite, or '' */
/***********************************************************************
* GETVAR is a routine to retrieve a library, I wrote it to make all of *
* my code (other than GETVAR) virtually site-independent. *
***********************************************************************/
"ispexec lminit dataid(dsn) dataset('"getvar(type'RAHP')"') enq(shr)"
"ispexec" mode "dataid("dsn") member("parm")" macro
"ispexec lmfree dataid("dsn")"
exit
Want to browse JCL? VCB myjcl
Want to edit PL/I? VPE mypli
Want to view text? VT mytext
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
In this instance, I object to the use of 'ZOOM' as a command name, where it is different than the expected usage of 'zoom'.
I think what you normally want ZOOM to do:
- PF key that invokes ZOOM function
- user puts cursor on object name to be ZOOMed and presses ZOOM pfkey
- ZOOM command extracts the object name based on the cursor position and opens the file with VIEW service.