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

Browsing member from any PDS


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

New User


Joined: 12 Sep 2013
Posts: 22
Location: India

PostPosted: Wed Mar 08, 2017 1:17 am
Reply with quote

Hi All,

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

Sorry if the post is too lengthy.

Thanks in advance.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Mar 08, 2017 2:04 am
Reply with quote

shiitiizz wrote:
The idea is to enter one line command as TSO ZOOM MEMNAME and
to avoid the logic of SAY MEMNAME and PULL MEMNAME


Instead of
PULL MEM
use (in REXX)
ARG MEM

RTFM
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Mar 08, 2017 3:10 am
Reply with quote

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 */

"ISREDIT MACRO"
"ISREDIT (TOTLINE) = LINENUM .ZL"
"ISPEXEC VPUT (TOTLINE) SHARED"
"ISREDIT END"

EXIT
Back to top
View user's profile Send private message
shiitiizz

New User


Joined: 12 Sep 2013
Posts: 22
Location: India

PostPosted: Wed Mar 08, 2017 4:28 pm
Reply with quote

Many Thanks sergeyken and daveporcelan icon_smile.gif
The proposed solution worked exactly as expected !
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Wed Mar 08, 2017 9:37 pm
Reply with quote

From my personal ISPF command table:
Code:
VR  0 SELECT CMD(%VBACKEND exec,view,&ZPARM) NEWAPPL(ISR) SCRNAME(VREXX)
VRE 0 SELECT CMD(%VBACKEND exec,edit,&ZPARM) NEWAPPL(ISR) SCRNAME(EREXX)
VRB 0 SELECT CMD(%VBACKEND exec,browse,&ZPARM) NEWAPPL(ISR) SCRNAME(BREXX)
VP  0 SELECT CMD(%VBACKEND pli,view,&ZPARM) NEWAPPL(ISR) SCRNAME(VPLI)
VPE 0 SELECT CMD(%VBACKEND pli,edit,&ZPARM) NEWAPPL(ISR) SCRNAME(EPLI)
VPB 0 SELECT CMD(%VBACKEND pli,browse,&ZPARM) NEWAPPL(ISR) SCRNAME(BPLI)
VT  0 SELECT CMD(%VBACKEND text,view,&ZPARM) NEWAPPL(ISR) SCRNAME(VTEXT)
VTE 0 SELECT CMD(%VBACKEND text,edit,&ZPARM) NEWAPPL(ISR) SCRNAME(ETEXT)
VTB 0 SELECT CMD(%VBACKEND text,browse,&ZPARM) NEWAPPL(ISR) SCRNAME(BTEXT)
VC  0 SELECT CMD(%VBACKEND cntl,view,&ZPARM) NEWAPPL(ISR) SCRNAME(VCNTL)
VCE 0 SELECT CMD(%VBACKEND cntl,edit,&ZPARM) NEWAPPL(ISR) SCRNAME(ECNTL)
VCB 0 SELECT CMD(%VBACKEND cntl,browse,&ZPARM) NEWAPPL(ISR) SCRNAME(BCNTL)
VJ  0 SELECT CMD(%VBACKEND proc,view,&ZPARM) NEWAPPL(ISR) SCRNAME(VPROC)
VJE 0 SELECT CMD(%VBACKEND proc,edit,&ZPARM) NEWAPPL(ISR) SCRNAME(EPROC)
VJB 0 SELECT CMD(%VBACKEND proc,browse,&ZPARM) NEWAPPL(ISR) SCRNAME(BPROC)

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

Easy, clean and infinitely extensible.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu Mar 09, 2017 11:02 pm
Reply with quote

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

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Mar 09, 2017 11:14 pm
Reply with quote

I only used ZOOM as the name of the Rexx because that is what the OP mentioned in their post.
Back to top
View user's profile Send private message
shiitiizz

New User


Joined: 12 Sep 2013
Posts: 22
Location: India

PostPosted: Fri Mar 10, 2017 12:22 pm
Reply with quote

Pedro, I am yet to implement the changes. I will take your advise and would change the macro name to something else.
Thanks
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 How to copy the -1 version of a membe... TSO/ISPF 4
No new posts Searching for a member but don't know... TSO/ISPF 6
No new posts Looking For a PDS Member Without Open... PL/I & Assembler 10
No new posts Library member auto insert option TSO/ISPF 3
No new posts DataSet member creation failed with B... Java & MQSeries 15
Search our Forums:

Back to Top