Physical Databases and Program Views

Introduction of Physical Databases and Program Views

A physical database is defined to IMS in one DBD, which is described later in this section. A physical database is limited to 15 hierarchical levels and 255 segment types (up to 254 dependent segments organized over 14 levels, plus the root segment). There is no limit to the number of segment occurrences, however. How to Use the IMS DATA Step Interface, illustrates the physical database AcctDBD.
A program view of a database consists of the hierarchically structured segments used in a program or application. A particular program view can be composed of all segments in a database or a subset of the segments, depending on the program's requirements. Program views are defined to IMS in program communication blocks (PCBs), which are contained in program specification blocks (PSBs).
The following figure illustrates a program view that consists of some segments from the AcctDBD database. This program view might be used by a program that prints monthly checking account statements. However, a SAS/ACCESS view descriptor can access data in only one path in the database. Therefore, in one invocation, the view descriptor can retrieve data in either the CHCKDEBT segment or the CHCKCRDT segment. (footnote 1)
Sample Program View
Sample Program View
In order for the SAS/ACCESS interface to access an IMS database, certain information about the database must be defined. These definitions are contained in DBDs and PSBs.

What You Need to Know to Create Descriptors

Typically, DBDs and PSBs are generated by the database administration staff, not by application programmers or users. Users do not need to know how to create DBDs, PSBs, or PCBs in order to use the SAS/ACCESS interface to IMS. If you create access descriptors and view descriptors, you need to know the following information:
  • the name of the database that you want to use (DBD name).
  • the ddnames and names of database data sets (and for HIDAM, the index data sets).
  • the name of the PSB that contains the PCBs to be used for your database.
  • which fields are sequence or search fields (as defined in the DBD).
  • standard segment descriptions, such as field name, field length, and data type. You might need a copybook, segment layout, or some other detailed description of the database if this information is not in the DBD.
  • what type of access is permitted (as defined in the PCBs in the PSB).
  • the sensitive segments (as defined in the PCBs in the PSB) and their names and lengths. Asensitive segment is a segment in the database that can be accessed only by using a PCB that permits Read or Update access.
  • the order of the PCBs in the PSB, and which PCBs your program needs to access.
  • the order in which fields are defined in the segment.
You can get all of this information from your installation's database administrator (DBA).
The descriptions of DBDs and PSBs that follow do not need to be understood in detail. They are included here for readers who want this additional information.

Database Description

The database description (DBD) is usually created by the DBA at an installation. The DBD specifies characteristics of a database, including the following:
  • the name of the DBD, which is also used as a shorthand name for the IMS database (1–8 characters).
  • the type and access method for the database (DEDB, MSDB, HDAM, HIDAM, HSAM, HISAM, GSAM, SHISAM, or SHSAM). These database types are defined in the next section.
  • the randomizing method to assign an address to each record's key (HDAM only).
  • the ddname for the database.
  • the device type.
  • the block size.
  • the name, parent, and length of each segment type in the database. The parent information enables IMS to determine the segment's position in the hierarchy.
  • the name, length, starting position, and type of data for each sequence and search field in each segment. (In the following example, the code that specifies these characteristics is highlighted.)
Note: It is not necessary to specify every field in a segment in the DBD. Only those fields to be used as sequence and search fields are specified in the DBD.

DBD for the WIRETRAN Segment

The following is the DBD for the WIRETRAN segment of the WireTrn database.
DBD   NAME=WIRETRN,ACCESS=(HDAM,OSAM),          X
        RMNAME=(DFSHDC40,3,71)
  DATASET DD1=WIREDD,DEVICE=3380, BLOCK=2400
  SEGM  NAME=WIRETRAN,PARENT=0,BYTES=100
  FIELD NAME=(SSNACCT,SEQ,M),BYTES=23,START=1,  X   
  TYPE=C
  FIELD NAME=ACCTTYPE,BYTES=1,START=24,TYPE=C
  FIELD NAME=WIREDATE,BYTES=8,START=25,TYPE=C
  FIELD NAME=WIRETIME,BYTES=8,START=33,TYPE=C
  FIELD NAME=WIREAMMT,BYTES=5,START=41,TYPE=X
  FIELD NAME=WIREDESC,BYTES=40,START=46,TYPE=C
  DBDGEN

IMS Database Types

During installation, the database administrator (DBA) chooses the type of database to use for the IMS databases. The DBA decides which type of database to use based on how most of the programs that use an IMS database access the data in the database. The following is a list of database types that the DBA can use to define an IMS database that is supported by the SAS/ACCESS interface to IMS in SAS 7 and later:
Data Entry Database (DEDB)
is a direct-access database that consists of one or more areas. Each area contains both root segments and dependent segments. The database is accessed using VSAM improved control interval processing (ICIP). This database type can be used only with the SAS/ACCESS DATA step interface.
Main Storage Database (MSDB)
is a root-segment database, residing in main storage, which can be accessed to a field level. This database type can be used only with the SAS/ACCESS DATA step interface.
Hierarchical Direct Access Method (HDAM)
is one of the DL/I language's two direct-access methods. A direct-access method enables DL/I to locate any database record, regardless of the record sequence in the database, by using a randomizing routine or an index. HDAM provides direct access to data through a randomizing routine. Sequentially accessing an HDAM database, DL/I retrieves data in the order in which the data is physically stored in the database.
Hierarchical Indexed Direct Access Method (HIDAM)
is one of DL/I language's two direct-access methods. HIDAM provides direct access to data through an index.
Hierarchical Sequential Access Method (HSAM)
is one of DL/I language's sequential-access methods. In a sequential-access database, segments are stored in a hierarchical sequence, one segment after another. HSAM provides sequential access to root segments and dependent segments. You can access data in HSAM databases, but you cannot update any of the data.
Hierarchical Indexed Sequential Access Method (HISAM)
processes data sequentially, but has an index that enables you to directly access records in the database.
Generalized Sequential Access Method (GSAM)
enables IMS/ESA batch application programs to access a sequential z/OS data set record that is defined as a database record. This database record is handled as one unit, with no segments, fields, or hierarchical structure. Any records to be added are inserted at the end of the database. GSAM does not enable you to update or delete records in the database.
Simple Hierarchical Sequential Access Method (SHSAM)
is an HSAM database that contains only one segment type, a root segment. Only two types of calls are valid with SHSAM databases: Get calls to read a database and Insert calls to load a database. You must reload a database in order to update it.
Simple Hierarchical Indexed Sequential Access Method (SHISAM)
is a HISAM database with only one segment type, a root segment.

IMS Data Types

When specifying the characteristics of the physical database in the DBD, the DBA identifies for each segment in the database the fields that IMS can use to search or sequence a segment. The DBA can define each individual field, define the entire segment as one field and assign a generic data type, or define some fields individually and other fields as a group. The DBA can define fields in an IMS database segment using the following data types:
Data Type Codes and Corresponding Data Types
Data Type Code
Data Type
X
hexadecimal
P
packed decimal
C
alphanumeric character
F
binary fullword
H
binary halfword
Z
zoned decimal
E
short floating point
D
long floating point
L
extended floating point
Note: All COBOL and PL/I data types are supported as hexadecimal data types.

IMS Data Types in SAS/ACCESS Descriptors

To create access and view descriptors to be used by the SAS/ACCESS interface to IMS, you need to know how the DBA has defined the database fields. You also need to know how the fields are initialized and the order of all the fields in each segment to be accessed. You can get this information from a layout of the database or a COBOL copybook.
The following table shows the DBFORMAT= value that you specify in an access descriptor for some common COBOL and PL/I data types. This table also shows the SAS variable formats that the SAS/ACCESS interface generates from the IMS DBFORMAT= value.
Recommended DBFORMAT= Values to Use for Common COBOL and PL/I Data Types
IMS Type
COBOL
PL/I
Description
Standard Length in Bytes
Recommended DBFORMAT=
SAS Format Generated
C
PIC A
Pic 'A'
Alphabetic
<=200
>200
$w.
$200.
$w.
$200.
C
PIC X
Char or Pic 'X'
Alphanumeric
<=200
>200
$w.
$200.
$w.
$200.
Z
PIC 9
Pic '9'
Numeric Edited
w.
Z
PIC S9
Pic '99T'
Zoned-Decimal
ZDw.d
w.d
H
PIC 9(4) COMP
Fixed Bin (15)
Fixed-Point Binary
2
IB2.
7.0
F
PIC 9(8) COMP
Fixed Bin (31)
Fixed-Point Binary
4
IB4.
10.0
E
COMP-1
Float Bin (21)
Floating-Point
4
Rb4.
E13.0
D
COMP-2
Float Bin(53)
Floating-Point
8
RB8.
E22.0
P
COMP-3
Fixed Decimal
Packed-Decimal
<=16
PDw.d
w.d
When you create an access descriptor, you use the ITEM= statement to describe the IMS DBD. When you need to specify a SAS informat that corresponds to a COBOL data description, refer to PICTURE and USAGE. If the USAGE is COMP-1 or COMP-2, there is no PICTURE. If no USAGE is specified, it defaults to DISPLAY.
Use the following information to make the conversions:
  • pictures that include either A or X represent character values.
  • pictures that include numbers use 9 to represent digits. They might use an S to mean signed and a V to show the location of an implied decimal point.
The number of characters or digits is specified either by the number of As, Xs, or 9s in the picture or by the number in parentheses immediately after the A, X, or 9. For example, AAAA is the same as A(4).
The following table shows other conversions.
COBOL Conversions
USAGE
PICTURE
SAS Informat
Width
Decimal
COMP-1
None
RB4.
COMP-2
None
RB8.
DISPLAY
9(int)V9(fract)
ZDw.d
(int + fract)1
(fract)
COMP-3
9(int)V9(fract)
PDw.d
CEIL((int+fract+1)/2)1
(fract)
COMP
9(int)V9(fract)
IBw.d
*
1If the (int + fract) is 1-4, the width is 2 and decimal is a fraction. If the (int + fract) is 5-9, the width is 4 and decimal is a fraction. If the (int + fract) is 10-18, the width is 8 and decimal is a fraction.
Use SAS formats to print the fractional part read with the IBw.d and RBw.d SAS informats.

DBD for the ACCTDBD Database

The following is the DBD for the AcctDBD database.
DBD 1NAME=ACCTDBD, 2ACCESS=(HDAM,OSAM),        X
     3RMNAME=(DFSHDC40,3,71)
DATASET 4DD1=ACCTDD, 5DEVICE=3380,             X
6BLOCK=2400 
7SEGM  NAME=CUSTOMER,PARENT=0,BYTES=225
8FIELD NAME=(SSNUMBER,SEQ,U),BYTES=11,START=1,  X
   TYPE=C
   FIELD NAME=CUSTNAME,BYTES=40,START=12,TYPE=C
   FIELD NAME=CUSTADD1,BYTES=30,START=52,TYPE=C
   FIELD NAME=CUSTADD2,BYTES=30,START=82,TYPE=C
   FIELD NAME=CUSTCITY,BYTES=28,START=112,TYPE=C
   FIELD NAME=CUSTSTAT,BYTES=2,START=140,TYPE=C
   FIELD NAME=CUSTLAND,BYTES=20,START=142,TYPE=C
   FIELD NAME=CUSTZIP,BYTES=10,START=162,TYPE=C
   FIELD NAME=CUSTHPHN,BYTES=12,START=172,TYPE=C
   FIELD NAME=CUSTOPHN,BYTES=12,START=184,TYPE=C
  
7SEGM  NAME=CHCKACCT,BYTES=40,PARENT=CUSTOMER
8FIELD NAME=(ACNUMBER,SEQ,U),BYTES=12,START=1, X
   TYPE=X
   FIELD NAME=STMTAMT,BYTES=5,START=13,TYPE=P
   FIELD NAME=STMTDATE,BYTES=6,START=18,TYPE=X
   FIELD NAME=STMTBAL,BYTES=5,START=26,TYPE=P
  
7SEGM  NAME=CHCKDEBT,BYTES=80,                 X
        PARENT=((CHCKACCT,DBLE)),RULES=(,LAST)
8 FIELD NAME=DEBTAMT,BYTES=5,START=1,TYPE=P
   FIELD NAME=DEBTDATE,BYTES=6,START=6,TYPE=X
   FIELD NAME=DEBTBLNK,BYTES=2,START=12,TYPE=X
   FIELD NAME=DEBTTIME,BYTES=8,START=14,TYPE=C
   FIELD NAME=DEBTDESC,BYTES=59,START=22,TYPE=C
  
7SEGM  NAME=CHCKCRDT,BYTES=80,                 X
        PARENT=((CHCKACCT,DBLE)),RULES=(,LAST)
8FIELD NAME=CRDTAMT,BYTES=5,START=1,TYPE=P
   FIELD NAME=CRDTDATE,BYTES=6,START=6,TYPE=X
   FIELD NAME=CRDTBLNK,BYTES=2,START=12,TYPE=X
   FIELD NAME=CRDTTIME,BYTES=8,START=14,TYPE=C
   FIELD NAME=CRDTDESC,BYTES=59,START=22,TYPE=C
  
7SEGM  NAME=SAVEACCT,BYTES=40,PARENT=CUSTOMER
8FIELD NAME=(ACNUMBER,SEQ,U),BYTES=12,START=1, X
   TYPE=X
   FIELD NAME=STMTAMT,BYTES=5,START=13,TYPE=P
   FIELD NAME=STMTDATE,BYTES=6,START=18,TYPE=X
   FIELD NAME=STMTBAL,BYTES=5,START=26,TYPE=P
  
7SEGM  NAME=SAVEDEBT,BYTES=80,                 X
        PARENT=((SAVEACCT,DBLE)),RULES=(,LAST)
8 FIELD NAME=DEBTAMT,BYTES=5,START=1,TYPE=P
   FIELD NAME=DEBTDATE,BYTES=6,START=6,TYPE=X
   FIELD NAME=DEBTBLNK,BYTES=2,START=12,TYPE=X
   FIELD NAME=DEBTTIME,BYTES=8,START=14,TYPE=C
   FIELD NAME=DEBTDESC,BYTES=59,START=22,TYPE=C
  
7SEGM  NAME=SAVECRDT,BYTES=80,                 X
        PARENT=((SAVEACCT,DBLE)),RULES=(,LAST)
  8FIELD NAME=CRDTAMT,BYTES=5,START=1,TYPE=P
   FIELD NAME=CRDTDATE,BYTES=6,START=6,TYPE=X
   FIELD NAME=CRDTBLNK,BYTES=2,START=12,TYPE=X
   FIELD NAME=CRDTTIME,BYTES=8,START=14,TYPE=C
   FIELD NAME=CRDTDESC,BYTES=59,START=22,TYPE=C
  DBDGEN
1 The name of the DBD, which is also used as a shorthand name for the IMS database (1–8 characters).
2 The type and access method for the database (DEDB, MSDB, HDAM, HIDAM, HSAM, HISAM, GSAM, SHISAM, or SHSAM). These database types are defined in the next section.
3 The randomizing method to assign an address to each record's key (HDAM only).
4 The ddname for the database.
5 The device type.
6 The block size.
7 The name, parent, and length of each segment type in the database. The parent information enables IMS to determine the segment's position in the hierarchy.
8 The name, length, starting position, and type of data for each sequence and search field in each segment. (In the following example, the code that specifies these characteristics is highlighted.)

Program Specification Block

A program specification block (PSB) is generally created by the DBA at an installation. A PSB consists of one or more program views of one or more databases. A SAS task using the SAS/ACCESS interface to access an IMS database must reference one and only one PSB. Information specified in the PSB includes the following items:
  • at least one program view for each database that is accessed by the SAS/ACCESS interface in the executing task. A program view is defined in a PCB. In fact, you can use the terms program view and PCB interchangeably. Each PCB provides these specifications:
    • the database to be accessed.
    • the processing options (read-only or various updating options).
    • the maximum length of the concatenated key fields (sequence fields) in any path.
    • the database segments that can be accessed. These segments are called sensitive segments. The name, parent segment, and access mode for each sensitive segment are given.
  • the programming language the PSB supports. The SAS/ACCESS interface to IMS uses a PSB regardless of the specified programming language. This flexibility means that no additional PSBs are required for the SAS/ACCESS interface.
  • the name of the PSB.
Note: In IMS Version 12, the IMS PSB control block (created via the PSBGEN utility) added new vectors. See http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.ims12.doc.rpg/ims_coex_sys_psblibrary.htm. When running IMS Version 12, but using PSBs that were created from earlier versions of IMS (Version 11 or prior), all versions of SAS continue to work. If a PSB is generated using the IMS Version 12 PSBGEN utility, and the SAS program needs to use one of the moved vector addresses, you must run the second maintenance release of SAS 9.4 or later. The second maintenance release of SAS 9.4 or later is still able to use PSBs generated with prior IMS Version 12 PSBs. A bit in the PSB control block identifies which version is present.

Example of a PSB

Here is a sample of a PSB called ACCTSAM, which contains some database PCBs for the AcctDBD database and one PCB for the WireTrn database:
  PCB   TYPE=DB,DBDNAME=ACCTDBD,PROCOPT=G,       X
        KEYLEN=11
  SENSEG NAME=CUSTOMER,PARENT=0,PROCOPT=G
  PCB   TYPE=DB,DBDNAME=ACCTDBD,PROCOPT=G,       X
        KEYLEN=23
  SENSEG NAME=CUSTOMER,PARENT=0,PROCOPT=GP
  SENSEG NAME=CHCKACCT,PARENT=CUSTOMER,PROCOPT=G
  SENSEG NAME=SAVEACCT,PARENT=CUSTOMER,PROCOPT=G
  PCB   TYPE=DB,DBDNAME=ACCTDBD,PROCOPT=A,       X
        KEYLEN=23
  SENSEG NAME=CUSTOMER,PARENT=0,PROCOPT=AP
  SENSEG NAME=CHCKACCT,PARENT=CUSTOMER,PROCOPT=AP
  SENSEG NAME=CHCKDEBT,PARENT=CHCKACCT,PROCOPT=A
  SENSEG NAME=CHCKCRDT,PARENT=CHCKACCT,PROCOPT=A
  SENSEG NAME=SAVEACCT,PARENT=CUSTOMER,PROCOPT=AP
  SENSEG NAME=SAVEDEBT,PARENT=SAVEACCT,PROCOPT=A
  SENSEG NAME=SAVECRDT,PARENT=SAVEACCT,PROCOPT=A
  PCB   TYPE=DB,DBDNAME=WIRETRN,PROCOPT=A,       X
        KEYLEN=23
  SENSEG NAME=WIRETRAN,PARENT=0,PROCOPT=A
  PSBGEN LANG=ASSEM,IOASIZE=500,PSBNAME=ACCTSAM, X
   CMPAT=YES
  END

Security Options

IMS provides security for databases through data sensitivity, a way of controlling which data the SAS/ACCESS interface to IMS can access. The SAS/ACCESS interface is used to access only data to which it is sensitive. There are three levels of data sensitivity:
segment sensitivity
enables the IMS interface to access only certain segments in a particular hierarchy.
field-level sensitivity
enables the IMS interface to access only certain fields in a particular segment.
key sensitivity
enables the IMS interface to access only segments below a particular segment in a hierarchy. It does not enable the IMS interface to access that particular segment, and returns only the segment's key to the interface.
The DBA can specify data sensitivity for an IMS database in each database PCB in the PSB.
FOOTNOTE 1:With the SAS/ACCESS DATA step interface, the view shown can be processed in a single DATA step execution. See Overview of the IMS DATA Step Interface for more information.[return]