How to Create a new IMS Database

 

As part of my work, however unfortunate it many seem for an application developer, I was asked  to create a brand new IMS Database. For my boss who comes from an open system  background, creating a DB is always just a Command or Click away and my best efforts to explain the complexity of creating a new database in IMS fell on deaf ears.

I googled all I could, but I did not stumble upon a single article which explains the process entirely. There are many which explains what a DBD or PSB is , and for the very same reason I am not going into details of those here . I will try to focus on the “how to” rather than the “what is”, so for what is worth , here goes..

 

Step 1 – DBDGEN

The DBD or the Database Descriptor defines the creates the physical structure of your IMS Database .We use assembler language macros statements to define the physical structure for an IMS Database . There are many articles explaining the meaning and options available in DBDGEN macro, so I am assuming that you have already read it or is familiar with it.

Let’s say we plan to create a simple IMS – DB with 2 levels and 3 segments as show below

Screen Shot 2015-12-12 at 11.35.08 AM

Create a PDS with recording format FB, LRECL 80 to store all your DDBDEN code

Create a member with same name as the name of the Database you plan to create

Code in your DBD gen assembler macro commands in the PDS member, make a note of the below points while you do

  • The Name of the Database Given by NAME= ‘   ‘ must be same as the PDS member name
  • All assembler macro statements begin at column 10
  • For continuations to next line use a ‘X’ at column 72
  • The DD name of the data base you are creating in given in DD1=Name, and the same DD name must be used wherever this IMS data base is referred in JCL

                 

               DBD   NAME=INVTDB,ACCESS=(HDAM,VSAM),                         X

                          RMNAME=(DFSHDC40,3,90,300)                              

DSG1     DATASET DD1=LIBDB,DEVICE=3390,SIZE=2048                      

               SEGM NAME=LIBSEG,PARENT=0,BYTES=10                          

               FIELD NAME=(LIBCD,SEQ,U),BYTES=5,START=1,TYPE=C              

               SEGM NAME=BOOKSEG,PARENT=LIBSEG,BYTES=10                        

               FIELD NAME=(BOOKID,SEQ,U),BYTES=5,START=1,TYPE=C              

               SEGM NAME=MAGSEG,PARENT=LIBSEG,BYTES=10                        

               FIELD NAME=(MAGID,SEQ,U),BYTES=5,START=1,TYPE=C              

               DBDGEN  

               FINISH  

               END                  

I am not going into details of what each keyword and option means, you can google it or use the link

 

Step 2 – Creating a Physical VSAM file for the Database

Create a VSAM ESDS file to hold the physical data using IDCAMS

 

//IDCAMS   EXEC PGM=IDCAMS                          

//SYSPRINT DD SYSOUT=*                            

//SYSIN   DD *                                    

DELETE ‘XXXXX.IMS.LIBDB’                      

DEFINE CLUSTER( NAME(‘XXXXX.IMS.LIBDB’) –      

         STORAGECLASS(TCHSC) –                      

         RECOVERY –                                

         NOERASE –                                  

         SHAREOPTIONS(1 3) –                        

         VOLUME(TCHN04   ) –                      

         NONINDEXED –  ) –                                     

         DATA(NAME(‘XXXXX.IMS.LIBDB.DATA’) –    

          CYLINDERS(4 4) –                      

          BUFFERSPACE(4096) –                  

          CONTROLINTERVALSIZE(2048) –          

         FREESPACE(0 0) –

          RECORDSIZE(2041 2041) –        

          NONSPANNED –    )                  

  /*                                    

 

Step 3 – Execute the DBDGEN  

Create the DBDLIB Library as a PDS with the below Characteristics

  • Organization . . . : PO  
  • Record format . . . : U  
  • Record length . . . : 0  
  • Block size . . . . : 32760
  • Data set name type: PDS                    

A new member containing the DBDLIB for the DBDGEN code will be added to this PDS.Use the below JCL to execute the DBDGEN and create the corresponding DBDLIB, modify the JCL wherever required.

 

//DBDGNJCL JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=X,                      

//         REGION=5M,NOTIFY=&SYSUID                                    

//**************************** INPUT AREA******************************************

// SET MEMBER=’LIBDB’                           Name of the new DBD to be created

// SET SOURCE=’XXXX.DBDGEN.SRC’   Source Library containing DBDGEN code

// SET LOADLIB=’XXXX.TEST.DBDLIB’     DBDLIB PDS Library Name created above 

//**************COMPILE THE DBD GEN******************************************

//COMPILE EXEC PGM=ASMA90,REGION=4M,                

//         PARM=(OBJECT,NODECK,NODBCS,                

//         ‘SIZE(MAX,ABOVE)’)                        

//SYSLIB   DD DSN=IMS910.SDFSMAC,DISP=SHR   IMS Macro Library name

//SYSLIN   DD DSN=&&LOADSET,UNIT=SYSDA,DISP=(,PASS),  

//         SPACE=(80,(100,100),RLSE),                

//         DCB=(BLKSIZE=80,RECFM=F,LRECL=80)          

//SYSPRINT DD SYSOUT=*                                

//SYSUT1   DD UNIT=SYSDA,DISP=(,DELETE),              

//         SPACE=(CYL,(10,5))                        

//SYSIN   DD DISP=SHR,                              

//         DSN=&SOURCE(&MEMBER)        Contains the DBDGEN code

//***************** LINK EDIT DBDGEN ****************************************

//LINKEDIT EXEC PGM=IEWL,PARM=’XREF,LIST’,          

//         COND=(0,LT,COMPILE),REGION=4M            

//SYSLIN   DD DSN=&&LOADSET,DISP=(OLD,DELETE)        

//SYSPRINT DD SYSOUT=*                              

//SYSLMOD DD DISP=SHR,                              

//         DSN=&LOADLIB(&MEMBER)    New DBDLIB member will be added here 

//SYSUT1   DD UNIT=(SYSDA,SEP=(SYSLMOD,SYSLIN)),    

//         SPACE=(1024,(100,10),RLSE),DISP=(,DELETE)

//* ********************* END of JCL **********************************                              

 

Step 4 – Initializing your Database

This is a step which nobody writes about, but mandatory for your IMS DB to function correctly. All IMS shops will have either IBM file manager for IMS or CA file master plus or an equivalent . This example I am using IMS file manager to load an initial dummy record to the IMS DB before it can be used in a program

This can be done using the interactive panel in IBM File Manager (Initialize option under utilities) or you can submit a JCL to do the same. I prefer the JCL (see below)

 

//FILEMAN EXEC PGM=FMN1IMSB                    

//STEPLIB DD DSN=FMN.SFMNMOD1,DISP=SHR        

//SYSPRINT DD SYSOUT=*,RECFM=FBA,LRECL=133      

//FMNTSPRT DD SYSOUT=*                          

//FMN1JIN DD DSN=FMN.SFMNSLIB,DISP=SHR        

//SYSTERM DD SYSOUT=*                          

//FMIMSIN DD *                                

$$FILEM DIB DIBTYPE=INSERT,                    

$$FILEM     DBDDSN=XXXX.TEST.DBDLIB,     DBDLIB Library name     

$$FILEM     DBDMEM=LIBDB,                           DBDLIB member name                        

$$FILEM     RESLIB1=IMS910.SDFSRESL,            

$$FILEM     MACLIB=IMS910.SDFSMAC,              

$$FILEM     DFSVSAMP=IMS910.PROCLIB,            

$$FILEM     VSMPMEM=DFSVSMDC                    

/*                                              

//IEFRDER DD DUMMY                              

//* —————————————————————  

//* — IMS DLI DATASETS REQUIRED FOR THE LOAD                   —  

//* —————————————————————  

//LIBDB DD DSN=XXXXX.IMS.LIBDB,DISP=SHR   ESDS VSAM File Name 

//ENDRC     ENDIF      

 

Step 5 – PSBGEN     

You IMS Database is pretty much ready now, but you would still need to create a PSB to execute a program accessing the DB, so like how we did for DBDGEN create a PDS member (LRECL 80) and code your PSBGEN macro commands

 

PRINT NOGEN                                        

PCB TYPE=DB,DBDNAME=LIBDB,KEYLEN=99,PROCOPT=A      

SENSEG NAME=LIBSEG,PARENT=0                        

SENSEG NAME=BOOKSEG,PARENT=LIBSEG

SENSEG NAME=MAGSEG,PARENT=LIBSEG

PSBGEN PSBNAME=LIBPSB,LANG=COBOL                  

END  

 

Step 6 – Execute the PSBGEN

Create the PSBLIB Library PDS with the below Characteristics

  • Organization . . . : PO  
  • Record format . . . : U  
  • Record length . . . : 0  
  • Block size . . . . : 32760
  • Data set name type: PDS                    

A new member containing the PSBLIB for the PSBGEN code will be added to this PDS.Use the below JCL to execute the PSBGEN and create the corresponding PSBLIB, the JCL is pretty standard, you need to make your specific modification here

 

//PSBGNJCL JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=X,                      

//         REGION=5M,NOTIFY=&SYSUID       

//**************************** INPUT AREA ***************************************************                // SET MEMBER=’LIBPPSB’                      PSBLIB member to be created    

// SET SOURCE=’XXXX.IMS.PSBGEN’    PSBGEN Source Library    

// SET LOADLIB=’XXXX.IMS.PSBLIB’       PSBLIB Load Library  

//**************COMPILE THE PSB GEN******************************************

//COMPILE EXEC PGM=ASMA90,REGION=4M,                  

//         PARM=(OBJECT,NODECK,NODBCS,                  

//         ‘SIZE(MAX,ABOVE)’)                          

//SYSLIB   DD DSN=IMS910.SDFSMAC,DISP=SHR     IMS Macro library              

//SYSLIN   DD DSN=&&LOADSET,UNIT=SYSDA,DISP=(,PASS),    

//         SPACE=(80,(100,100),RLSE),                  

//         DCB=(BLKSIZE=80,RECFM=F,LRECL=80)            

//SYSPRINT DD SYSOUT=*                                  

//SYSUT1   DD UNIT=SYSDA,DISP=(,DELETE),                

//         SPACE=(CYL,(10,5))                          

//SYSIN   DD DISP=SHR,                                

//         DSN=&SOURCE(&MEMBER)    Location of the PSB GEN code      

//***************** LINK EDIT PSBGEN ****************************************                  

//LINKEDIT EXEC PGM=IEWL,PARM=’XREF,LIST’,                            

//         COND=(0,LT,COMPILE),REGION=4M                              

//SYSLIN   DD DSN=&&LOADSET,DISP=(OLD,DELETE)                          

//SYSPRINT DD SYSOUT=*                                                

//SYSLMOD DD DISP=SHR,                                                

//         DSN=&LOADLIB(&MEMBER)  New member added here                                        

//SYSUT1   DD UNIT=(SYSDA,SEP=(SYSLMOD,SYSLIN)),                      

//         SPACE=(1024,(100,10),RLSE),DISP=(,DELETE)                  

//* ********************* END of JCL **********************************

 

Once you have your PSB and DBD read you are all set you compile and run you program using your new IMS database! . Please email us if you need any further clarifications , hope this was of help.

 

Mainframe Wiki © 2015 Frontier Theme