space
Previous Page | Next Page

IMS Essentials

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). (See the next several sections for more information about DBDs, PCBs, and 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 will be creating access descriptors and view descriptors, you need to know the following information:

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:

[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.)

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.  [cautionend]


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 will 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 Version 7 and later of SAS:

Data Entry Database (DEDB)

is a direct-access database that consists of one or more areas, with each area containing both root segments and dependent segments. The database is accessed using VSAM improved control interval processing (ICIP). This database type can only be used 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 only be used 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 that 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.  [cautionend]


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 RecommendedDBFORMAT= 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.d
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:

The number of characters or digits is specified either by the number of A s, X s, or 9 s 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) (fract)
COMP-3 9(int)V9(fract) PDw.d CEIL((int+fract+1)/2) (fract)
COMP 9(int)V9(fract) IBw.d *
* If 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 1  NAME=ACCTDBD, 2  ACCESS=(HDAM,OSAM),        X
     3  RMNAME=(DFSHDC40,3,71)
DATASET 4  DD1=ACCTDD, 5  DEVICE=3380,             X
6  BLOCK=2400 
7  SEGM  NAME=CUSTOMER,PARENT=0,BYTES=225
8  FIELD 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
  7  SEGM  NAME=CHCKACCT,BYTES=40,PARENT=CUSTOMER
  8  FIELD 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
  7  SEGM  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
  7  SEGM  NAME=CHCKCRDT,BYTES=80,                 X
        PARENT=((CHCKACCT,DBLE)),RULES=(,LAST)
  8  FIELD 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
  7  SEGM  NAME=SAVEACCT,BYTES=40,PARENT=CUSTOMER
  8  FIELD 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
  7  SEGM  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
  7  SEGM  NAME=SAVECRDT,BYTES=80,                 X
        PARENT=((SAVEACCT,DBLE)),RULES=(,LAST)
  8  FIELD 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


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:


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. [arrow]

space
Previous Page | Next Page | Top of Page