MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DSN1COPY and get Dataset Name behind any tablespace

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 319
Topics: 51
Location: Germany

PostPosted: Wed Nov 12, 2025 12:40 pm    Post subject: DSN1COPY and get Dataset Name behind any tablespace Reply with quote

I like to use the DSN1COPY tooling in the context to copy DB2 tables (content) from one subsystem to any other subsystem.

IBM describes this here:

https://www.ibm.com/docs/en/db2-for-zos/12.0.0?topic=dsn1copy-copying-tables-from-one-subsystem-another

How can I find the zOS filesystem name which is behind any given tablespace / table? This information requires DSN1COPY utility.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12399
Topics: 75
Location: San Jose

PostPosted: Wed Nov 12, 2025 6:08 pm    Post subject: Re: DSN1COPY and get Dataset Name behind any tablespace Reply with quote

bauer wrote:

How can I find the zOS filesystem name which is behind any given tablespace / table? This information requires DSN1COPY utility.


Bauer,

Here is the link to the explanation to data set naming conventions

https://www.ibm.com/docs/en/db2-for-zos/12.0.0?topic=groups-data-set-naming-conventions

Now that we know the convention, it should be easy to get the list from the db2 catalog tables.

Here is an untested SQL (I just modified an existing sql that I had) which may* give you the information you are looking for.

PS: I defaulted to D (for VSAM data components) for the 2nd qualifier. You can also have C (for VSAM clusters)

Code:

SELECT SUBSTR(VCATNAME,1,LENGTH(VCATNAME))     ||                 
       CHAR('.')                               ||                 
       CHAR('DSNDBD')                          ||                 
       CHAR('.')                               ||                 
       SUBSTR(DBNAME,1,LENGTH(DBNAME))         ||                 
       CHAR('.')                               ||                 
       SUBSTR(TSNAME,1,LENGTH(TSNAME))         ||                 
       CHAR('.')                               ||                 
       IPREFIX                                 ||                 
       CHAR('0001.')                           ||                 
      (CASE WHEN PARTITION >= 0000 AND PARTITION < 1000 THEN 'A' 
            WHEN PARTITION >= 1000 AND PARTITION < 2000 THEN 'B' 
            WHEN PARTITION >= 2000 AND PARTITION < 3000 THEN 'C' 
            WHEN PARTITION >= 3000 AND PARTITION < 4000 THEN 'D' 
            WHEN PARTITION >= 4000 AND PARTITION < 4097 THEN 'E' 
       END) ||                                                   
      (CASE WHEN PARTITION =  0000                               
            THEN '001'                                           
            WHEN PARTITION >  0000 AND PARTITION < 1000           
            THEN SUBSTR(DIGITS(PARTITION),3,3)                   
            WHEN PARTITION >= 1000                               
            THEN SUBSTR(DIGITS(PARTITION),2,4)                   
       END)                                                       
  FROM SYSIBM.SYSTABLEPART A                                     
 WHERE A.VCATNAME   > ' '                                         
   AND A.VCATNAME  <> '00000001'                                 
 UNION ALL                                                       
SELECT SUBSTR(B.VCATNAME,1,LENGTH(VCATNAME))   ||               
       CHAR('.')                               ||               
       CHAR('DSNDBD')                          ||               
       CHAR('.')                               ||               
       SUBSTR(DBNAME,1,LENGTH(DBNAME))         ||               
       CHAR('.')                               ||               
       SUBSTR(INDEXSPACE,1,LENGTH(INDEXSPACE)) ||               
       CHAR('.')                               ||               
       IPREFIX                                 ||               
       CHAR('0001.')                           ||               
      (CASE WHEN PARTITION >= 0000 AND PARTITION < 1000 THEN 'A'
            WHEN PARTITION >= 1000 AND PARTITION < 2000 THEN 'B'
            WHEN PARTITION >= 2000 AND PARTITION < 3000 THEN 'C'
            WHEN PARTITION >= 3000 AND PARTITION < 4000 THEN 'D'
            WHEN PARTITION >= 4000 AND PARTITION < 4097 THEN 'E'
       END)                    ||                               
      (CASE WHEN PARTITION =  0000                             
            THEN '001'                                         
            WHEN PARTITION >  0000 AND PARTITION < 1000         
            THEN SUBSTR(DIGITS(PARTITION),3,3)                 
            WHEN PARTITION >= 1000                             
            THEN SUBSTR(DIGITS(PARTITION),2,4)                 
       END)                                                     
  FROM SYSIBM.SYSINDEXPART B                                   
      ,SYSIBM.SYSINDEXES   C                                   
 WHERE B.IXCREATOR  = C.CREATOR                                 
   AND B.IXNAME     = C.NAME                                   
   AND B.VCATNAME   > ' '                                       
   AND B.VCATNAME  <> '00000001'                               
;                                           

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 319
Topics: 51
Location: Germany

PostPosted: Thu Nov 13, 2025 10:00 am    Post subject: Reply with quote

Ok, this helps. Thank you.

So, no path anywhere in the DB2 catalog. Building the path from the single qualifiers is necessary.

Have a nice day - thank you again Very Happy
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12399
Topics: 75
Location: San Jose

PostPosted: Thu Nov 13, 2025 12:35 pm    Post subject: Reply with quote

bauer wrote:
Building the path from the single qualifiers is necessary.


bauer,

I am not sure I understand what you meant by Single Qualifiers? Do you mean you just want based on a table name you provide as an input?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group