Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Check if DSN already allocated to specific DDNAME

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Grant Ward Able

New User


Joined: 22 Jul 2008
Posts: 8
Location: London

PostPosted: Wed Jun 03, 2009 3:22 pm    Post subject: Check if DSN already allocated to specific DDNAME
Reply with quote

Does anyone know how (using REXX) I can check if a DSN is already allocated to a specific DDNAME?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 03, 2009 3:28 pm    Post subject:
Reply with quote

This will work if the DD name does not have concatenated inputs as this will return only the first dataset allocated to the DDname.

Code:

X   = LISTDSI("DDname  FILE")     
DUMPDSN = SYSDSNAME               
Back to top
View user's profile Send private message
Grant Ward Able

New User


Joined: 22 Jul 2008
Posts: 8
Location: London

PostPosted: Wed Jun 03, 2009 3:39 pm    Post subject:
Reply with quote

Thanks - I really should have been more specific. This code is similar to what I have already. My problem really is that SYSDSNAME only gives me the first DSN in the concatenation. Is there a way to know if there are more? If so, how do I get those DSNs?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 03, 2009 3:48 pm    Post subject:
Reply with quote

Try this
Code:

/* REXX *** OBTAIN INFORMATION OF DSN & VOLSERS FOR A GIVEN DD NAME
        >>> BASED ON CODE ORIGINALLY POSTED BY DOUG NADEL            */

SIGNAL ON SYNTAX NAME ERR

NUMERIC   DIGITS 31

ARG DDNM .   /* DDNAME TO BE INTERROGATED FROM EXEC STATEMENT        */

DDDSN   = GETDSN1(DDNM) /* CALL DDNAME INTEROGATION CODE             */
SAY " "
DO A = 1 TO WORDS(DDDSN) /* DISPLAY THE RESULTS                      */
  DDDTRAN = TRANSLATE(WORD(DDDSN,A),' ',',')
  LENDSN  = LENGTH(WORD(DDDTRAN,1))
  VOLSERS = STRIP(SUBSTR(DDDTRAN,LENDSN+2))
  SAY "DDNAME  = "STRIP(DDNM)", DSN "RIGHT(A,3)" = "WORD(DDDTRAN,1)
  SAY "VOLSERS = "VOLSERS
END
SAY " "

EXIT

/* PROCEDURE GETDSN1 - FIND DATASETS/VOLUMES ALLOCATED TO DDNAME     */
GETDSN1: PROCEDURE
ARG DDNAM .
DSNAM2 = ''
DDNAME=STRIP(LEFT(DDNAM,8))            /* MUST BE 8 LONG, PAD BLANKS */
TIOTPTR=24+PTR(12+PTR(PTR(PTR(16))))   /* GET DDNAME ARRAY           */
TIOELNGH=C2D(STG(TIOTPTR,1))           /* LENGTH OF 1ST ENTRY        */
KONKAT=0                               /* SET INDICATOR TO DEFAULT   */
FOUND=0                                /* SET INDICATOR TO DEFAULT   */
PARSE VALUE '' WITH RETVALUE           /* SET RETURN VALUES NULL     */
DO UNTIL TIOELNGH=0                    /* SCAN UNTIL DD FOUND        */
  TIOEDDNM=STRIP(STG(TIOTPTR+4,8))     /* GET DDNAME FROM TIOT       */
  IF FOUND THEN DO
     IF TIOEDDNM = '' THEN  CALL GETDSNDETAIL
     ELSE LEAVE
     END
  ELSE IF TIOEDDNM=DDNAME THEN DO
     FOUND=1
     CALL GETDSNDETAIL
     END
  TIOTPTR=TIOTPTR+TIOELNGH             /* GET NEXT ENTRY             */
  TIOELNGH=C2D(STG(TIOTPTR,1))         /* GET ENTRY LENGTH           */
  END
RETURN DSNAM2                          /* RETURN RESULT TO MAIN MOD  */
GETDSNDETAIL:
   KONKAT=KONKAT+1
   TIOELNGH=C2D(STG(TIOTPTR,1))        /* LENGTH OF NEXT ENTRY       */
   TIOEJFCB=STG(TIOTPTR+12,3)
   TIOELINK=STG(TIOTPTR+3,1)
   PARSE VALUE '' WITH LABEL VOLUMES DEVTYP DSNAME MEMBER VOLLIST
   SELECT
      WHEN BITAND(TIOELINK,'20'X)='20'X THEN DEVTYP='*TERMINAL'
      WHEN BITAND(TIOELINK,'02'X)='02'X THEN DEVTYP='*SYSOUT'
      OTHERWISE DO
         JFCB=SWAREQ(TIOEJFCB)           /*CONVERT SVA TO 31-BIT ADDR*/
         DSNAME=STRIP(STG(JFCB,44))      /*DSNAME JFCBDSNM           */
         MEMBER=STRIP(STG(JFCB+44,8))    /* MEMBER OR RELATIVE GDGNUM*/
         LABEL=STRIP(C2D(STG(JFCB+68,2)))
         IF BITAND(STG(JFCB+159,1),'04'X)='04'X THEN DO
            DEVTYP='*VIO'
            LABEL=0
            VOLUMES=''
            END
         ELSE DO
            VOLLIST=STRIP(STG(JFCB+118,30))
            TIOEJFCBX=STG(JFCB+149,3)
              /* JOB FILE CONTROL BLOCK EXTENSION */
            IF TIOEJFCBX<>'000000'X THEN DO
               JFCB=SWAREQ(TIOEJFCBX) /*CONVERT SVA TO 31-BIT ADDR*/
               DEVTYP=C2X(STG(JFCB+140,4))
               VOLLIST=VOLLIST||STRIP(STG(JFCB+4,90))
               PTRX=PTR(JFCB+172,4)
               DO WHILE PTRX<>0          /* GET NEXT EXTENSION */
                  VOLLIST=VOLLIST||STRIP(STG(PTRX+4,90))
                  PTRX=PTR(PTRX+172,4)
                  END
               END
            VOLLEN=LENGTH(VOLLIST)
            VOLUMES=SUBSTR(VOLLIST,1,6)
            DO I=7 TO VOLLEN BY 6
               VOLUMES=VOLUMES||","||SUBSTR(VOLLIST,I,6)
               END
            END
         END
   PARSE VALUE RETVALUE || ,
     DSNAME','STRIP(MEMBER)','VOLUMES','LABEL','DEVTYP';' ,
     WITH RETVALUE
     DDNAME = LEFT(DDNAME,8)
     DSNAME = LEFT(DSNAME,44)
     DEVTYP = LEFT(DEVTYP,8)
     LABEL  = RIGHT(LABEL,3)
     IF MEMBER = ' ' THEN
       DSNAM2 = DSNAM2 ||" "||STRIP(DSNAME)
     ELSE
       DSNAM2 = DSNAM2 ||" "||STRIP(DSNAME)||STRIP("("MEMBER")")
 END
DSNAM2 = DSNAM2||","||VOLUMES
RETURN DSNAM2
/*-------------------------------------------------------------------*/
PTR:  RETURN C2D(STORAGE(D2X(ARG(1)),4))         /* RETURN A POINTER */
/*-------------------------------------------------------------------*/
STG:  RETURN STORAGE(D2X(ARG(1)),ARG(2))         /* RETURN STORAGE   */
/*-------------------------------------------------------------------*/
SWAREQ:  PROCEDURE                /* COURTESY OF GILBERT SAINT-FLOUR */
IF RIGHT(C2X(ARG(1)),1) <> 'F' THEN    /* SWA=BELOW ?                */
  RETURN C2D(ARG(1))+16                /* YES, RETURN SVA+16         */
SVA = C2D(ARG(1))                      /* CONVERT TO DECIMAL         */
TCB = PTR(540)                         /* TCB PSATOLD                */
JSCB = PTR(TCB+180)                    /* JSCB TCBJSCB               */
QMPL = PTR(JSCB+244)                   /* QMPL JSCBQMPI              */
QMAT = PTR(QMPL+24)                    /* QMAT QMADD                 */
DO WHILE SVA>65536
  QMAT = PTR(QMAT+12)                  /* NEXT QMAT QMAT+12          */
  SVA=SVA-65536                        /* 010006F -> 000006F         */
  END
RETURN PTR(QMAT+SVA+1)+16

/** ERROR ROUTINE - SHOW LINE AND EXECUTE WITH TRACE I               */
ERR:
  SIGNAL OFF SYNTAX
  DROPBUF
  SAY "ERROR ROUTINE OUTPUT STARTING"
  SAY "ERROR ROUTINE OUTPUT STARTING"
  SAY "   "
  SAY RIGHT(SIGL,6) ">>>" SOURCELINE(SIGL)
  SAY "   "
  TRACE I
  INTERPRET SOURCELINE(SIGL)
Back to top
View user's profile Send private message
Grant Ward Able

New User


Joined: 22 Jul 2008
Posts: 8
Location: London

PostPosted: Wed Jun 03, 2009 4:07 pm    Post subject:
Reply with quote

Wow - a lot more than I expected! Again, thanks.....
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Wed Jun 03, 2009 9:55 pm    Post subject: Reply to: Check if DSN already allocated to specific DDNAME
Reply with quote

Here is another method, using BPXWDYN:
Code:
/* rexx */                                             
Parse UPPER arg search4dd                               
last1 = 0                                               
dsnlist = ''                                           
Do i = 1 by 1 Until (last1 /= 0)                       
   Call bpxwdyn 'info inrelno('i') inrtddn(found_dd)', 
                'inrtlst(last1)'                       
   If found_dd = search4dd Then Leave                   
End                                                     
Do i = i by 1 While last1=0                             
   Call bpxwdyn 'info inrelno('i') inrtddn(found_dd)', 
                'inrtdsn(found_dsn)',                   
                'inrtlst(last1) msg(wtp)'               
   If found_dd /= '' & found_dd /= search4dd Then Leave
   If dsnlist  /= '' Then                               
     dsnlist = dsnlist || ","                           
   dsnlist = dsnlist || found_dsn                       
End                                                     
Say 'DSN list=' dsnlist                                 
Return                                                 


BDXWDYN is your friend. Unfortunately, it is documented in some unix manual (though, still z/OS). Even though it was introduced there, it does not have to be called from a unix environment.
Back to top
View user's profile Send private message
Grant Ward Able

New User


Joined: 22 Jul 2008
Posts: 8
Location: London

PostPosted: Thu Jun 04, 2009 4:31 pm    Post subject:
Reply with quote

Great stuff Pedro!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Thu Jun 04, 2009 8:00 pm    Post subject:
Reply with quote

You can also use:
Code:
X = OutTrap('Alloc.') 
Address TSO "LISTALC STATUS"
X = OutTrap('OFF')
then you have to analyse the contents of the stem.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Wed Jun 10, 2009 6:12 pm    Post subject:
Reply with quote

Just for general reference, here is one possible code for the LISTALC method:
Code:
   X = OUTTRAP('Alc.')                   
   "LISTALC STATUS"                     
   X = OUTTRAP('OFF')                   
                                         
   ActDDN = ''
   Do Ix = 2 To Alc.0
      Parse Var Alc.Ix DSN DDN .
      If DDN <> '' Then Do
         DISP = ''
      End; Else Do
         Ix = Ix + 1
         Parse Var Alc.Ix 3 DDN 12 DISP .
         If DDN = '' Then
            DDN = ActDDN
         Else
            ActDDN = DDN
      End
      Say Left(DDN,8) Left(DSN,40) DISP
   End

Instead of the "Say" line, you can check for a specific DDN or DSN, or you can store the values in a new stem var, or whatever.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Release quantity that was allocated v... Auryn JCL & VSAM 5 Thu May 18, 2017 6:02 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Route a product's job to specific lpar vasanthz All Other Mainframe Topics 9 Thu Mar 02, 2017 2:22 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us