IMS Handout

Embed Size (px)

Citation preview

  • 8/3/2019 IMS Handout

    1/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only.

    TABLE OF CONTENTS

    1. WHAT IS IMS? ................................................................................................................................... 1

    1.1. HIERARCHICAL DATA BASE.............................................................................................................. 1

    2. GENERAL CONCEPTS IN IMS ...................................................................................................... 2

    3. ARCHITECTURE OF IMS ............................................................................................................... 6

    4. WHAT IS A DBD? .............................................................................................................................. 7

    5. WHAT IS A PSB? ............................................................................................................................... 8

    6. WHAT IS AN ACB? ......................................................................................................................... 10

    7. WHAT IS DL/I? ................................................................................................................................ 10

    8. IMS PROCESSING .......................................................................................................................... 11

    9. DL/I DATABASE ORGANIZATION ............................................................................................. 14

    10. ENTRY AND GOBACK STATEMENT ........................................................................................ 21

    11. IMS PROCESSING .......................................................................................................................... 23

    12. WHAT IS A SSA? ............................................................................................................................. 23

    13. DL/I CALLS ...................................................................................................................................... 24

    14. UNSUCCESSFUL CALLS ............................................................................................................... 32

    15. COMMAND CODES ........................................................................................................................ 33

    16. DL/I STATUS CODES ..................................................................................................................... 34

    17. DL/I ACCESS METHODS .............................................................................................................. 37

    17.1. HSAM ....................................................................................................................................... 37

    17.1.1. Defining HSAM ..................................................................................................................... 37

    17.1.2. Stored Segment Occurrence .......... .......... ........... .......... ........... .......... ........... .......... ........... .... 38

    17.2. HISAM ...................................................................................................................................... 38

    17.2.1. Data storage using KSDS-ESDS: .......... ........... .......... .......... ........... .......... ........... .......... ... 38

    17.2.2. Stored Segment Occurrence .......... .......... ........... .......... ........... .......... ........... .......... ........... .... 39

    17.2.3. Stored Segment Occurrence .......... .......... ........... .......... ........... .......... ........... .......... ........... .... 41

    17.3. HDAM ....................................................................................................................................... 44

    17.3.1. Data Storage using ESDS/OSAM .......... .......... ........... .......... .......... ........... .......... ........... ...... 4417.3.2. Defining HDAM .................................................................................................................... 46

    17.3.3. Stored Segment Occurrence .......... .......... ........... .......... ........... .......... ........... .......... ........... .... 46

    17.4. HIDAM ..................................................................................................................................... 47

    17.4.1. Defining HIDAM .................................................................................................................. 47

    18. SECONDARY INDEXING .............................................................................................................. 48

    18.1. SEGMENTS IN SECONDARY INDEXING ......................................................................................... 48

    18.2. SECONDARY DATA STRUCTURE ................................................................................................. 49

    18.3. POINTERS IN SECONDARY INDEXING.......................................................................................... 50

  • 8/3/2019 IMS Handout

    2/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only.

    19. MULTIPLE DATASET GROUP .................................................................................................... 52

    20. WHAT IS A LOGICAL RELATIONSHIP? .................................................................................. 53

    20.1. TYPES OF LOGICAL RELATIONSHIPS........................................................................................... 54

    20.2. DEFINITIONS............................................................................................................................... 57

    20.3. RULES IN LOGICAL RELATIONS................................................................................................... 6521. DATA COMMUNICATION AND MESSAGE FORMAT SERVICE ........................................ 65

    21.1. WHAT IS A LOGICAL TERMINAL? ................................................................................................ 66

    21.2. MESSAGE PROCESSING IN IMS ................................................................................................... 66

    PROCESSING A JOB IN IMSDB/DCENVIRONMENT .................................................................................. 67

    21.4. INPUT MESSAGE AREA ............................................................................................................... 70

    21.5. OUTPUT MESSAGE AREA ........................................................................................................... 71

    21.6. MESSAGE FORMAT SERVICE AND ITS CONTROL BLOCKS............................................................ 72

    CODING OF MFS STATEMENTS ................................................................................................................... 1

    21.8. CODING OF DEVICE FORMAT STATEMENTS ................................................................................. 74

    21.9. CODING MESSAGE DESCRIPTOR CONTROL STATEMENTS........................................................... 79

    21.10. DYNAMIC CHANGING OF ATTRIBUTES AND CURSOR POSITION CONTROL .................................. 81

  • 8/3/2019 IMS Handout

    3/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 1 of 84

    1. What is IMS? IMS is an acronym that stands forInformation Management System. A software product for creating and managing the physical storage andretrieval of data that is organized using hierarchical data structure.1.1.Hierarchical Data Base A hierarchical data base consists of collection of elements called as

    segments.

    Segments are connected to each other through links. It is similar to an upside down tree structure. The top of hierarchy forms the root. A segment may relate downwards to one or more sub-ordinate segments

    called as child segments. A segment may relate to only one segment above it called as parent

    segment.

    Fig.1.0.

    Hierarchical Structure

    COURSE

    (Root)

    CLASS

    (Parent/Child)

    INSTRUCTOR

    (Child)

    STUDENT

    (Child)

  • 8/3/2019 IMS Handout

    4/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 2 of 84

    2. General Concepts in IMSSegment:

    Each grouping of data. Basic element of the data structure. Consists of one or more related fields. Can be compared with file record. Unit of I/O. It is an entity and cannot be broken. Can contain Key Field or Sequence Field:

    A field within a segment used for searching, indexing and sequencing purposes. Only

    one key per segment is allowed and should be the first field in the segment. It may ormay not be unique.

    Search Field:A field within a segment that is a non-key field but can be used for search operations.

    Data Field:A field within a segment that contains data related to the segment.

    Data in this field cannot be used for search operations

    In Fig. 1.0.COURSE, CLASS, INSTRUCTOR, STUDENTare segments.

    Segment Type: Layout of segment within hierarchical structure. Can be compared with record description. Maximum 255 per data base record.Segment Occurrence: Consists of a set of field occurrences within a segment. Can be compared with a record occurrence in a flat file system. Can have key field called as sequence field. A particular segment type can have any number of segment occurrences. Fig 2.0. shows the segment occurrences.

  • 8/3/2019 IMS Handout

    5/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 3 of 84

    Segment Occurrence

    Twin Segments

    Fig. 2.0.

    Root Segment:

    Highest level segment in data base structure. Only one root per data base record. A root may have any number of child segments. Root segment is at level 01.Refer Fig.2.1.Dependent Segments:

    All segments under a particular segment are dependent segments. Any segment other than root segment is called as dependent segment.Parent Segment:

    A dependent segment which has one or more dependent segments is called as a parentsegment.Refer Fig.2.1.

    Child Segment:

    A segment that is directly dependent on some other segment is called child segment. A child segment cannot have more than one parent.Refer Fig.2.1.Only Parent Segment: A segment which does not have any parent. The root is the parent-only segment.Refer Fig.2.1.Only Child Segment: A dependent which does not have any dependents.Refer Fig.2.1.

    INSTRUCTOR2INSTRUCTOR1

    COURSE2

    COURSE1

    CLASS1

    STUDENT2

    STUDENT1

  • 8/3/2019 IMS Handout

    6/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 4 of 84

    Parent/Child Segment: A dependent, which has dependents, can be a parent/child segment.

    Refer Fig. 2.1.

    Twin Segment:

    Multiple occurrences of a particular child segment under a common parent segment.Refer to fig. 2.0.

    Sibling:

    Child segment types under one parent segment type.Refer Fig 2.1.Path:

    Series of continuous segment occurrences starting from root to any dependent segment. The path starting from the root and ending at the last level is called complete path.Level:

    This indicates the depth of tree from root. The roots being at level one. There can bemaximum 15 levels.Refer Fig. 2.1.

    Segment Type Code (STC):

    Each Segment is assigned a value ranging from 1 to 255 according to hierarchicsequence. This value is called STC.

    Root always starts with STC = 01. These values are used by the operating system access methods for the retrieval of data.

    Refer Fig. 2.1.

    STC = 01

    Root /Only Parent

    STC = 02 STC = 03

    Parent/Child

    Sibling

    STC = 04 STC = 05

    Only Child & SiblingsFig. 2.1.

    INSTR (Level-03)

    COURSE Level-01

    CLASS (Level-02)

    STUDENT (Level-03)

    PRE-REQ (Level-02)

  • 8/3/2019 IMS Handout

    7/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 5 of 84

    Data Base Record: Each occurrence of root segment with all its sub-ordinate segments makes a single data

    base record.Refer Fig. 2.2.

    Twin SegmentsFig. 2.2.

    Data Base Record

    Concatenated Key:

    Sequence field of each segment within hierarchical path beginning with root segmentsequence field.

    Is positioned from left to right.Refer Fig. 2.3.Concatenated Key

    Fig. 2.3.

    Concatenated Key

    INSTRUCTOR2INSTRUCTOR1

    COURSE1

    CLASS1

    STUDENT2

    STUDENT1

    COURSE1 CRS1

    CLASS1 CRS1CLS1PREQ1RS1PRE1

    STUDENT1 CRS1CLS1STU1

  • 8/3/2019 IMS Handout

    8/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 6 of 84

    3. Architecture of IMS

    PSB

    Logical Database

    Physical Database

    Fig 3.0.

    Architecture of IMS

    Fig.3.0. shows the architecture of IMS. The host language Data language/I (DL/I) acts as an

    interface between the application program and the operating system.

    The Program Communication Block (PCB) describes a logical view of the database as seen bythe application program. An application program can have more than one view. These views are

    clubbed together to form a Program Specification Block (PSB).

    The physical data structure is called as Data Base Descriptor (DBD).

    The operating system access methods used for IMS are: Virtual Storage Access Method (VSAM)

    Host Language

    +

    DL/I

    PC

    B

    PC

    B

    ...

    D

    B

    D

    D

    B

    D

    D

    B

    D

    ........

  • 8/3/2019 IMS Handout

    9/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 7 of 84

    Indexed Sequential Access Method (ISAM) Overflow Sequential Access Method (OSAM)

    4. What is a DBD? Means Data Base Description. Used to describe the complete structure of database (physical database). The DBA initiates a process called DBDGEN (Data base generator) to describe physical

    structure of database.

    A DBD contains:

    Segment Types. Parent Child relations. Field in each segment. Search fields (optional).Defining a DBD:

    Source form of DBD written in assembler macro is input to DBDGEN program. Assembly Macros are expanded with the help of Macro Library. Load Module is stored in DBD library and retrieved when required by IMS. Refer

    Fig.4.0.

    Fig.4.0.

    DBDGEN Definition.

    DBDGEN

    Programs

    Assembler

    Macro

    Macro

    Library

    DBD

    Library

  • 8/3/2019 IMS Handout

    10/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 8 of 84

    Essentials for defining the structure:

    Data base name. Dataset name and location. Segment name, parent and size. Field names, size, start position and type.DBDGEN Statements:

    DBD NAME=TRGDBD

    DATASET DD1=IN,DEVICE=3380

    SEGM NAME=COURSE,PARENT=0,BYTES=256FIELD NAME=(COURSE#,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=TITLE,BYTES=33,START=4,TYPE=C

    ...............

    DBDGENFINISH

    END.

    5. What is a PSB? Means Program Specification Block. This control block specifies the information regarding different views i.e. the databases(one or more) a program can access, the data elements the program can see in those

    databases, and the processing the program can do.

    There is only one PSB in a given application program.What is a PCB? Means Program Communication Block. An application program may have more than one view (logical data structure). Each view is defined in a PCB. Set of all PCBs is included in the PSB. The PCB defines which of the segments in the database the program can access.

    PCB also defines how the application program is allowed to process the segments(update, retrieve only, load only etc.).

    PCB has two types of sensitivity : Segment level sensitivity

    If an entire segment is included in the view it is said to have segment level sensitivity.

    Field level sensitivityIf the data view includes only certain fields within a segment it is said to have field

    level sensitivity.

  • 8/3/2019 IMS Handout

    11/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 9 of 84

    A PCB contains: DBD Name. Concatenated Key length. Processing Options (PROCOPT). Sensitive Segments. Sensitive fields.Defining a PSB:

    Source form of PSB written in assembler macro is input to PSBGEN program. Assembly Macros are expanded with the help of Macro Library. Load Module is stored in PSB library and retrieved when required by IMS. Refer

    Fig.5.0.

    Fig. 5.0.

    PSBGEN Definition.

    PSBGEN Statements:

    PCB TYPE=DB,DBDNAME=TRGPDBD,KEYLEN=15,PROCOPT=A

    SENSEG NAME=STREAM

    SENFLD NAME=STRNO.

    PSBGEN

    Programs

    Assembler

    Macro

    Macro

    Library

    PSB

    Library

  • 8/3/2019 IMS Handout

    12/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 10 of 84

    .

    PSBGEN NAME=INLOAD,LANG=COBOL

    END

    PCB : Program Communication Block

    PROCOPT : Program processing options.

    SENSEG : Sensitive Segment.

    SENFLD : Sensitive field

    6. What is an ACB? Means Application Control block. Used to pre-build the database with DBDs and PSBs. Used for faster access.

    7.What is DL/I? Stands for Data Language /I. It is the data manipulation language (DML) for IMS. Serves as an interface between the data base and application program i.e. It transfers information to and from database. Allows application program to manipulate database.

    Set of IMS modules that exist external to the application program. Subroutine called by application program that is host language (COBOL).DL/I Functions:

    Calls Description

    GU (Get- Unique) To obtain a unique occurrence of a

    segment within a database.

    GN ( Get-Next) To obtain the next occurrence of a segment

    within a database.

    GNP (Get-Next-Within-Parent) Retrieves child segments under a parent

    REPL To replace an occurrence of a segment indatabase.

    DLET To delete an occurrence of segment in

    database.

    ISRT To insert an occurrence of segment in

    database.

  • 8/3/2019 IMS Handout

    13/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 11 of 84

    8. IMS Processing

    Fig.8.0.

    Types of IMS Processing

    IMS processing is of the following types: (Refer Fig.8.0.)

    Batch Processing Online Message processing Batch Message processingIMS Batch Processing:

    BATCH

    Processing

    ON-LINE

    MESSAGE

    Processing

    BATCH/MESSAGE

    Processing

    IMS

    Controller

    Application

    Program

    DL/I

    JCL

    DATA SET

    DBD

    Lib

    PSBLib

  • 8/3/2019 IMS Handout

    14/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 1.0 For Internal Use Only Page 12 of 84

    Fig.8.1.

    IMS Batch Processing

  • 8/3/2019 IMS Handout

    15/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 13 of 84

    Data base access is offline. No data communication services or terminals are used. Input is pre-planned. Can access DL/I database as well as OS/VS data sets. Application Program is scheduled by JCL.Refer fig.8.1.

    IMS Online Message Processing:

    Fig.8.2.

    IMS On-line Message Processing

    Called as Message Processing Program (MPP). Data Base Access is online. Can Access Message Queue and cannot access OS/VS data sets. Data communication services or terminals are used. Used for interactive processing. Transactions are entered at the terminal, which are stored in message queues. To process the transaction application program is invoked. Output can be seen at the terminal screen. Data Communication Calls are made in order to send and receive data on to the

    screens and Database calls are made to retrieve and store data on to database. Refer

    fig.8.2.

    Communication

    Controller

    Queue Manager

    DL/I

    MVS Address

    Space (VTAM)

    Message

    Queues DBDLib

    PSB

    Lib

    DATA BASE

    T

    ERM

    IN

    AL

  • 8/3/2019 IMS Handout

    16/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 14 of 84

    IMS Batch Message Processing Combination of Batch and Online Processing. BMP programs are scheduled by JCL. Can access online databases in Batch mode. Can access both OS/VS datasets and DL/I database Can access Message Queues. To invoke Application program through JCLs the transaction-Id is passed as a

    PARM parameter.

    9. DL/I Database organization

    Fig.9.0.

    Access Methods

    Access Methods (Refer Fig.9.0.)

    HSAM -> Hierarchical Sequential Access MethodHISAM-> Hierarchical Indexed Sequential Access Method

    HDAM -> Hierarchical Direct Access Method

    HIDAM-> Hierarchical Indexed Direct Access Method

    DL/I

    DATA BASE ORGANISATION

    Hierarchical

    Sequential

    Hierarchical

    Direct

    HDAM HIDAMHSAM HISAM

  • 8/3/2019 IMS Handout

    17/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 15 of 84

    DL/I Databases are internally stored on Operating System data sets.DL/I uses Access Methods like:

    Fig.9.1.DL/I data base access methods

    Sequential access method (SAM). Indexed Sequential Access method (ISAM). Overflow sequential Access Method (OSAM). Virtual Storage Access Method (VSAM).

    Understanding a DBD

    DBD statement Data set Statement Segment Statement Field StatementConsider the following Database Structure.

    Fig. 9.2.

    HSAM HISAM HDAM HIDAM

    SAM

    ISAM/

    OSAM

    or

    VSAM

    OSAM

    or

    VSAM

    ISAM/

    OSAM

    or

    VSAM

    SUPPSEG

    ITEMSEG

    LOCSEG

  • 8/3/2019 IMS Handout

    18/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 16 of 84

    The DBD is as follows:

    PRINT NOGEN

    DBD NAME= INPDBD,ACCESS=(HISAM,VSAM)

    DATASET DD1=PRIMEDS, OVFLW= OVFLWDS,DEVICE=3380,RECORD=(128,128)

    SEGM NAME=SUPPSEG,PARENT=0,BYTES=95

    FIELD NAME=(SNO,SEQ,U),BYTES=3,START=1,TYPE= C

    FIELD NAME=SNAME,BYTES=30,START=4,TYPE=CFIELD NAME=SADDR,BYTES=30,START=34,TYPE=C

    FIELD NAME=SCITY,BYTES=20,START=64,TYPE=C

    FIELD NAME=SSTATE,BYTES=2,START=84,TYPE=C

    SEGM NAME=PARTSEG,PARENT=SUPPSEG,BYTES=45FIELD NAME=(PNO,SEQ,U),BYTES=5,START=1,TYPE= C

    FIELD NAME=PNAME,BYTES=30,START=6,TYPE=C

    FIELD NAME=COLOR,BYTES=6,START=36,TYPE=CFIELD NAME=WEIGHT,BYTES=4,START=42,TYPE=P

    SEGM NAME=LOCSEG,PARENT=PARTSEG,BYTES=37

    FIELD NAME=(LOCCOD,SEQ,U),BYTES=3,START=1,TYPE= C

    FIELD NAME=LDES,BYTES=30,START=4,TYPE=CFIELD NAME=QTY,BYTES=4,START=34,TYPE=C

    DBDGEN

    FINISHEND

    DBD Statement

    Defines the database. It includes: Name of the database INPDBD.

    (All names are limited to 1-8 characters).

    DL/I access method HISAM. Underlying OS Access Method VSAM.

    It should be the first statement in database definition.Format:

    DBD NAME=dbdname,

    ACCESS=(HSAM)

    (HISAM [ ,ISAM )VSAM ]

    (HDAM [ ,OSAM )

    VSAM]

    (HIDAM [ ,OSAM )VSAM]

    (INDEX [ ,ISAM ) for index in HIDAM

    VSAM]

  • 8/3/2019 IMS Handout

    19/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 17 of 84

    DATASET Statement

    Defines the Operating System Data set(s) used to store the database.Eg: HISAM requires 2 data sets

    PRIMEDS, primary data set (VSAM KSDS) OVRFLWDS , Overflow data set (VSAM ESDS)

    RECORD=(128,128) specifies the logical record length of primary and overflow dataset respectively.

    Data Definition names DD1 and DD2 are required to identify the data sets atexecution time.

    DEVICE=3380, specifies the unitFormat:

    DATASET DD1=ddname1,DEVICE=device

    ,DD2=ddname2,OVFLW=ddname3, RECORD=(lrec1,lrec2)

    Example of DATASET statement:For HSAM

    DATASET DD1= ddname1

    ,DD2=ddname2

    ,DEVICE=device, RECORD=(lrec1,lrec2)

    For HISAMDATASET DD1=ddname1

    ,DEVICE=device

    ,OVLFLW=ddname3

    , RECORD=(lrec1,lrec2)

    For HDAM

    DATASET DD1=ddname1,DEVICE=device

    For HIDAMDATASET DD1=ddname1

    ,DEVICE=device

  • 8/3/2019 IMS Handout

    20/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 18 of 84

    SEGM statement:

    SEGM statement defines the segment type and inter segment relationship. Sequence of SEGM statement reflects the hierarchical structure of the database. The

    order will be taken from

    Top to Bottom Left to Right

    Format:

    SEGM NAME=segname1,PARENT=( [ ,0 or Segname2])

    BYTES=max bytes

    PARENT=0 indicates that the segment is root segment.

    PARENT=segname2 indicates that the current segment (segname1) isa child of segname2.

    FIELD statement: Defines the format of field within the segment. It specifies:

    Name Length Type Starting position of field

    Specification of sequence field is optional. Default for SEQ is U (unique) unless M (multiple) is specified. Sequence field should be defined as the first field in the segment.

    Format:

    FIELD NAME=(fldname[,SEQ][,U/M]),

    BYTES=bytes,START=start position,

    TYPE=[C/X/P]

  • 8/3/2019 IMS Handout

    21/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 19 of 84

    Understanding PCB:

    PCB statement SENSEG Statement

    Referring tofig.9.2. the PCB for the DBD is

    PRINT NOGEN

    PCB TYPE=DB,DBDNAME=INPDBD,KEYLENGTH=11,

    PROCOPT=LSSENSEG NAME=SUPPSEG

    SENSEG NAME=PARTSEG,PARENT=SUPPSEG

    SENSEG NAME=LOCSEG,PARENT=PARTSEG

    PSBGEN PSBNAME=INLOAD,LANG=COBOLEND

    PCB Statement:

    Defines the DBD name, the key length and the processing options. TYPE=DB specifies that the PCB is for database and not for data communication

    (TYPE=TP). DBDNAME=INPDBD specifies the underlying physical database to which the PCB

    corresponds to.

    KEYLENGTH=11 specifies the length of the longest concatenated key. PROCOPT parameter specifies the type of operations user will be permitted to

    perform on the segment.

    The different PROCOPTs are:

    G Get operation IInsert RReplace DDelete AAll (GIRD) L or LSInitial Load KKey sensitivity OOnly P For path calls

    Note: PROCOPT can have four options at the most.

    SENSEG Statement It defines the segment to be included in the PCB.PSBGEN Statement Assigns a name to the PSB. LANG parameter specifies the host language, which is going to use the PSB.

  • 8/3/2019 IMS Handout

    22/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 20 of 84

    Definition of PCBMASK:

    Fig.9.3.

    PCB Mask

    For each PCB in the PSB an area with certain predefined fields is declared in thelinkage section of the COBOL program. This area is called as PCBMASK.

    Format:

    01 PCB-MASK-1.05 PCB-DBD-NAME PIC X(8).

    05 PCB-SEG-LEVEL PIC XX.

    05 PCB-STATUS-CODE PIC XX.05 PCB-PROC-OPTION PIC X(4).

    05 FILLER PIC S9(5) COMP.

    05 PCB-SEG-NAME PIC X(8).05 PCB-KEY-LENGTH PIC S9(5) COMP.

    05 05 PCB-NUM-SEN-SEG PIC S9(5). COMP.

    05 PCB-KEY-FB-AREA PIC X(11).

    PCB-DBD-NAME: Contains the name of the DBD being processed.

    PCB-SEG-LEVEL:

    Contains the level of segment just processed.

    DL/IAPPLICATION

    PROGRAM

    ENTRY DLITCBL USING PCB-name1 [PCB-name2 .....]

    PCBs should be defined in the linkage section of

    COBOL ro ram

    Specifies address of each

    PCB in PSB.

  • 8/3/2019 IMS Handout

    23/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 21 of 84

    PCB-STATUS-CODE: Tells whether DL/I call was successful or failed. If it is blank the call was successful.PCB-PROC-OPTION:

    Contains the processing options defined at the time of creation of PCB.PCB-SEG-NAME:

    Contains the name of the segment that has been just processed.PCB-KEY-LENGTH:

    Contains the length of the concatenated key until the last successful call.PCB-NUM-SEN-SEG: Gives the number of sensitive segments defined in the PCB macro.

    PCB-KEY-FB-AREA:

    Contains the fully concatenated key .Note:All the data items defined in the PCBMASK are of a fixed length except for the

    PCB-KEY-FB-AREA. Its length will correspond to the length of longest possible

    concatenated key.

    10. Entry and Goback Statement

    Fig.10.0.

    Entry and Go Back Statement

    DL/IAPPLICATION

    PROGRAM

    ENTRY CBLTDLI

    GO BACK

  • 8/3/2019 IMS Handout

    24/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 22 of 84

    Entry Statement (Refer fig.10.0.) Used to initiate communication between DL/I and Application Program and facilitate

    use of IMS Resources.

    Should be the first statement in Procedure Division.Format:

    ENTRY DLITCBL USING pcb-name1

    [pcb-name2]

    GOBACK Statement (Refer fig.10.0.) Used to terminate the Application Program and transfer control to IMS. Should be the last statement coded in Procedure Division.

    Format:

    GOBACK.

    Note: STOPRUN should not be coded.

    DL/I Call Statement

    This statement is used to transfer control from the application program to the DL/Iinterface.

    Coded in the Procedure Division.Format:

    CALL CBLTDLI USING dli-function

    pcb-mask

    segment-io-area

    [ssas ]

    dl/i function is used to specify the operation to be performed on the database. This

    function has to be specified in the working-storage section.

    Eg: GU (Get Unique)

    Note: COBOL does not support Literal on CALL Statement

    segment-io-area is the name of the working-storage section field into which DL/I will

    return the retrieved data and from which DL/I will get the data for write, update

    operations.

  • 8/3/2019 IMS Handout

    25/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 23 of 84

    ssa is the segment search argument. It is used to specify the search criteria. This is a

    variable in the working-storage section used to hold either the sequence field or the

    search field but not the data field.

    11. IMS ProcessingThere are two types of IMS processing:

    Sequential Processing. Random Processing.

    Sequential Processing:

    Data is read in a hierarchic sequence. To get the nth segment all the n-1 segments have to be read. The GN and GNP DL/I functions are used to retrieve data.Random Processing:

    Access to database records is random. Only one read call (GU/GN) gets the required record.

    12. What is a SSA? Stands for Segment Search Argument. It is an area in the WORKING-STORAGE SECTION used to identify the

    segment that the program wants to access.

    It can be used to: Identify any occurrence of a segment type. Identify a specific occurrence of a segment type.

    It always follows the I/O area parameter. There can be 1-15 SSAs in a DL/I call. The SSAs must appear in hierarchical order of segment types.

    SSA Contains:

    The segment name.

    The segment name and sequence field. The segment name and search field.Types of SSAs Unqualified searches for a specific segment type only. Qualified searches for a specific segment occurrence of a specific segment type.

  • 8/3/2019 IMS Handout

    26/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 24 of 84

    Unqualified SSA Specifies the segment name only. Call made using unqualified SSA will access the database to retrieve the segment from

    the current position.

    Format:

    01 UNQUALIFIED-SSA.05 U-SSA-SEGMENT-NAME PIC X(8).

    05 FILLER PIC X VALUE .

    Note: Segment name is padded with spaces whenever it is less than 8 characters.

    The blank in the 9th

    position distinguishes an unqualified SSA from a Qualified

    SSA.

    Qualified SSA It supplies the DL/I call with either a sequence field value or search field value in

    addition to the segment name.

    Format:01 QUALIFIED-SSA.

    05 Q-SSA-SEGMENT-NAME PIC X(8) VALUE SUPPSEG .05 FILLER PIC X VALUE (.

    05 KEY-NAME PIC X(8) VALUE SNO .05 OPERATOR PIC XX VALUE =.

    05 KEY-VALUE PIC X(3) VALUE 111.

    05 FILLER PIC X VALUE ).

    Note: Segment name is padded with spaces whenever it is less than 8 characters.

    value of sequence/search field depends on actual size of the field (variable).

    13. DL/I Calls Retrieve from database GU (Get Unique) GN (Get Next) GNP (Get Next Within Parent) Hold Calls GHU (Get hold Unique) GHN(Get hold next) GHNP(Get hold next within parent)

  • 8/3/2019 IMS Handout

    27/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 25 of 84

    Insert Call ISRT(Insert into Database )

    Update Call REPL(Replace a record in database) DLET(Delete a record form database)

    Fig.13.0.

    Data base structure

    GU (Get Unique):

    Used to retrieve a unique segment. Used in case of random processing. Is independent of the position established by the previous calls. Retrieves the first occurrence of the segment satisfying the condition even if issued

    in a loop. Used to establish position in the database.

    The types of GU calls are: GU without SSA:

    Retrieves the first occurrence of the root segment. Used to reset the position in database.

    Format:

    CALL CBLTDLI USING DLI-GUPCB-MASK

    IO-AREA.

    Eg: Infig.13.0. GU call retrieves first occurrence of COURSE.

    COURSE

    CLASS

    STUDENT

  • 8/3/2019 IMS Handout

    28/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 26 of 84

    GU with unqualified SSA: Retrieves the first segment occurrence in the database that meets the criteria. The segment retrieved will be the one specified at the lowest level SSA.

    Format:

    CALL CBLTDLI USING DLI-GU

    PCB-MASKIO-AREA

    USSA.

    Eg: Consider USSA is COURSE CLASS

    In fig.13.0. issuing this call will retrieve the first occurrence of CLASS under the firstoccurrence of COURSE.

    GU with qualified SSA: Retrieves the first segment occurrence in the database that meets the criteria. The segment retrieved will be the one specified at the lowest level SSA. A complete set of SSAs to retrieve a segment includes uniquely identified SSAs

    one for each segment.

    Processing is based on unique fields and unique values.Format:

    CALL CBLTDLI USING DLI-GUPCB-MASK

    IO-AREA

    QSSA.

    Eg: Consider that QSSA is COURSE (CRSNO = IMS)

    CLASS (EDCTR = ED01)STUDENT (STUNO = 001).

    In fig. 13.0. issuing the call with above SSA will retrieve the student details whose

    number is 001 under CLASS ED01 attending COURSE IMS.

  • 8/3/2019 IMS Handout

    29/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 27 of 84

    GN (Get Next):

    Retrieves the next segment meeting the criteria from the currently establishedposition.

    Used in case of sequential processing. Is dependent of the position established by the previous calls. GN without SSA if issued in a loop retrieves the entire database.

    Types of GN calls are:

    GN without SSA: Retrieves the next occurrence of the segment that meets the criteria from the

    current position.

    When issued in a loop retrieves the entire database.Format:

    CALL CBLTDLI USING DLI-GNPCB-MASKIO-AREA.

    Eg: Infig.13.0. GN call retrieves next occurrence of COURSE from the current position.

    GN with unqualified SSA: Retrieves the next segment occurrence in the database that meets the criteria from

    the current position.

    The segment retrieved will be the one specified at the lowest level SSA.Format:CALL CBLTDLI USING DLI-GN

    PCB-MASKIO-AREA

    USSA.

    Eg: Consider USSA is COURSE CLASS

    Infig.13.0.. issuing this call will retrieve the next occurrence of CLASS under the

    COURSE where the current position is established.

    GN with qualified SSA:

  • 8/3/2019 IMS Handout

    30/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 28 of 84

    Retrieves the next segment occurrence in the database that meets the criteria fromthe current position.

    The segment retrieved will be the one specified at the lowest level SSA. A complete set of SSAs to retrieve a segment includes uniquely identified SSAs

    one for each segment.

    Processing is based on unique fields and unique values. This is same as GU issued with a fully qualified SSA. Used when sequence field is not unique i.e. used to retrieve duplicate segment

    occurrences.

    Format:

    CALL CBLTDLI USING DLI-GN

    PCB-MASK

    IO-AREAQSSA.

    Eg: Consider the QSSA as COURSE (CRSNO = IMS)CLASS (EDCTR = ED01)

    STUDENT (STUNO = 001)

    Infig13.0. issuing the call with above SSA will retrieve the student details whose numberis 001 under CLASS ED01 attending COURSE IMS.

    GNP (Get-Next-Within-Parent): Used to sequentially access dependent segments of an established parent segment. Parentage has to be established before using GNP. Parentage can be established by issuing a GU or a GN call. After establishment of parentage the GNP call can be issued to retrieve all dependent

    segments.

    It searches only segment occurrence within a common parent. Establishing new parentage by issuing GU or GN can change parentage. Delete and Replace calls do not affect parentage. Insertion at higher level or same level as parentage will destroy the parentage. GNP with qualified SSA in a loop retrieves all the duplicates just like a GN with a

    fully qualified SSA.

    Format:

    CALL CBLTDLI USING DLI-GNP

    PCB-MASKIO-AREA

    [USSA/QSSA]

    Eg: Infig.13.0. if the parentage is established at CLASS where CLASS=ED001 and aunqualified GNP call is issued ,then all the students under ED001 are retrieved.

  • 8/3/2019 IMS Handout

    31/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 29 of 84

    Hold Calls:

    GHU, GHN and GHNP functions like GU, GN and GNP respectively. Thesecalls are issued to hold the segments retrieve by the call. These calls are used

    prior to DLET or REPL call.

    RULEOption for ISRT, REPL and DEL

    Format: RULE = positionPosition can take the values:

    FIRST:

    For insert the segment occurrence must be inserted at the first. For delete the first segment occurrence must be deleted. For replace the first segment occurrence must be replaced.HERE:

    For insert the segment occurrence must be inserted just after the currentposition.

    For delete the segment occurrence at the current position. must be deleted. For replace the segment occurrence at the current position. is to be be

    replaced.

    LAST:

    For insert the segment occurrence must be inserted at the last. For delete the last segment occurrence must be deleted.

    For replace the last segment occurrence must be replaced.

    Note: LAST is the default rule. LAST overrides FIRST and HERE.FIRST overrides HERE.

    LAST cannot be overridden.

    ISRT (Insert): Used to Add a data to an existing database. To load a new database.

    The data to be inserted is moved to the IO-AREA.

    An unqualified SSA is given to the segment to be inserted.

    Inserting data to a existing Segment:

    A fully qualified SSA has to be given in order to establish the position where in thesegment to be inserted and an unqualified SSA for the segment being inserted.

  • 8/3/2019 IMS Handout

    32/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 30 of 84

    Format:

    CALL CBLTDLI USING DLI-ISRTPCB-MASK

    IO-AREA

    QSSA1USSA1.

    Eg: Infig.13.0. if data is to be inserted in STUDENT for an already existing COURSE

    and CLASS the SSAs will beQSSA1 is COURSE (CRSNO = IMS) CLASS (EDCTR = ED001)

    USSA1 is STUDENT

    With the above SSAs when an insert call is issued the data present in IO_AREA will beinserted as a new student for IMS course for ED001 class.

    Initial loading of database:

    In this case only unqualified SSA is specified and the data to be inserted is placed

    in the IO-AREA.

    Format:

    CALL CBLTDLI USING DLI-ISRT

    PCBMASKIO-AREA

    USSA.

    Eg: USSA is COURSE.

    In fig.13.0. if ISRT call is issued with the above SSA a new database record for

    COURSE is inserted.

    REPL (Replace a segment occurrence):

    Used to replace an existing segment occurrence. Before REPL is issued, a GHU, GHN or GHNP must be issued in order to hold the

    segment occurrence to be replaced.

    No SSA must be given along with a REPL call (except path call). The length of segment cannot be changed and the value of sequence field cannot be

    changed.

    When path call is issued along with GHU and a particular segment data is not to bechanged then command code N must be issued along with the SSA for that

    particular segment. The new data must be moved to IO-AREA before replace call is issued.

  • 8/3/2019 IMS Handout

    33/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 31 of 84

    Format:

    CALL CBLTDLI USING DLI-REPL

    PCB-MASK

    IO-AREA .

    Eg: CALL CBLTDLI DLI-GHU

    PCB-MASKIO-AREA

    USSA.

    Here USSA is COURSE.

    CALL CBLTDLI DLI-REPL

    PCB-MASKIO-AREA.

    After this call is issued the first course data will be replaced

    with the new data that is in the IO-AREA. (Refer fig.13.0.)

    DLET (Delete a segment occurrence): Used to delete an existing segment occurrence. Before DLET is issued, a GHU, GHN or GHNP must be issued in order to hold the

    segment occurrence to be deleted.

    No SSA must be given along with a DLET call (except path call). In case if the previous call was a path call, an unqualified SSA for the segment to be

    deleted can be given along with DLET call.

    When a segment occurrence is deleted then all the subordinate occurrences of thatsegment will also be deleted.

    Format:

    CALL CBLTDLI USING DLI-DLET

    PCB-MASK

    IO-AREA

    [USSA].

    Eg: CALL CBLTDLI USING DLI-GHU

    PCB-MASK

    IO-AREAUSSA.

  • 8/3/2019 IMS Handout

    34/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 32 of 84

    Here USSA is COURSE.

    CALL CBLTDLI USING DLI-DLET

    PCB-MASK

    IO-AREA.

    After this call is issued the first course and its correspondingdependents data will be deleted (Refer fig.13.0.)

    14.Unsuccessful CallsWhat happens when a call fails?

    Fig. 14.0.

    Refer fig. 14.0.

    Consider the call

    GU A(AKEY=A1)

    B(BKEY=B1)

    C(CKEY=C3)

    GN

    What is the Output?

    Ans: D1

    A1

    B3B2

    B1

    F1C2

    E1

    D1C1

  • 8/3/2019 IMS Handout

    35/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 33 of 84

    As seen infig14.0. the COURSE occurrence with key C3 is not available. So the GU call

    fails. The Key feedback area contains values up to the step till where the call is

    successful. Hence when the call GN fails the data stored in Key feedback area isA1B1C1C2. So the current position established is at segment occurrence C2. Now the

    next call given is GN. So the next segment occurrence following it is D1. Hence the

    output is D1.

    Note:

    In case of GU and GN the current position is established just after the segmentretrieved, in case of successful calls.

    In case of unsuccessful GU and GN the current position is established just after thesegment examined to satisfy the criteria.

    In case of successful ISRT call the current position is just after the segment inserted. In case of successful DLET call the position is established at the point where the

    segment is deleted.

    In case of successful REPL call the previously established position is maintained.15.Command Codes

    Specified along with the SSA. This is used to

    Enhance functionality of SSA. Reduce the number of SSAs required. Reduces the number of calls required.Command codes can be used in

    Qualified Calls Unqualified CallsFormat:

    For unqualified SSA

    WORKING-STORAGE SECTION.

    01 UNQUALIFIED-SSA.

    05 U-SSA-SEG-NAME PIC X(8).

    05 FILLER PIC X VALUE *.

    05 U-SSA-COMD-CODE PIC X.

    05 FILLER PIC X VALUE .

    For qualified SSA

    WORKING-STORAGE SECTION.

    01 QUALIFIED-SSA.

  • 8/3/2019 IMS Handout

    36/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 34 of 84

    05 SSA-SEG-NAME PIC X(8).

    05 FILLER PIC X VALUE *.

    05 SSA-COMD-CODE PIC X.

    05 FILLER PIC X VALUE (.

    05 SRCH-FLD-NAME PIC X(8) VALUE

    COURSE .05 FILLER PIC X(2) VALUE = .05 SRCH-VALUE PIC X(8).

    05 FILLER PIC X VALUE ).

    Command

    Code

    Meaning

    C Use concatenated key for segment

    D Path Call

    F Retrieve the first occurrence of the segment under its

    parentL Retrieve the last occurrence of the segment under its

    parent

    N No replace for the segment for a path replace call

    P Establish parentage at this level (above the lowest level

    segment returned by the call)

    Q Enqueue the segment

    U Hold position for subsequent retrieval on this segment

    V Hold position for subsequent retrieval on this segmentand those above it

    - The null command code has the same effect as nocommand code at all.

    Note: F command code can be used with GN and GNP calls.

    Using it with GU call is meaningless since GU always retrieves the first segmentoccurrence meeting the criteria

    L command code can be used with GU, GN and GNP calls.

    PROCOPT= P should be defined in PCB before using D command

    Code.

    16. DL/I Status CodesThese are the status codes returned as a result of the call issued against standard

    DL/I databases.

  • 8/3/2019 IMS Handout

    37/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 35 of 84

    Status

    Code

    DL/I Call Description

    AB All Call did not specify a segment IO area

    AC All get calls &

    ISRT

    Call included an SSA with an hierarchical error

    AD All Function code field specified for the call contains anincorrect value.

    AH ISRT Call requires at least one SSA

    AI All Error occurred when trying to open database data set.

    AJ All Invalid SSA

    AK All get calls &

    ISRT

    Field you name on qualified SSA is incorrect.

    AM All Processing options for call given not specified in PCB

    AO All Call caused a physical I/O error

    AT DLET,ISRT,REPL

    The I/O Area the call specified is to large

    AU All SSA specified in call exceeded maximum lengthallowed in PSB

    DA DLET, REPL Sequence field has been changed

    DJ DLET, REPL Call wasnt immediately preceded by a successful gethold call

    DX DLET The call violated a delete rule for segment

    GA Unqualified

    GN & GNP

    A higher level segment was retrieved during

    sequential retrieval (expected condition)

    GB GN End of data base during sequential retrieval

    GD ISRT Position lost before the call could be completed.GE All get calls

    and ISRT

    A segment occurrence meeting the specified condition

    wasnt found

    GK Unqualified

    GN & GNP

    A segment of different type but at same hierarchical

    level was retrieved (expected condition)

    GP GNP Proper parentage isnt in effect

    II ISRT Segment already exists in database

    IX ISRT The call violated an insert rule for the segment

    LB ISRT Segment already exists in database

    LC ISRT Input data is not in hierarchical sequence

    LD ISRT One or more segment segments in path to the segment

    being loadedLE ISRT The sequence of segment types at the same level isnt

    same as that specified in DBD

    Status

    Code

    DL/I Call Description

    NO DLET,REPL,I

    SRT

    Call caused a physical I/O error on secondary index

  • 8/3/2019 IMS Handout

    38/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 36 of 84

    RX ISRT Call violated a replace rule for a segment

    V1 DLET,

    REPL,ISRT

    Variable length segment longer than maximum

    segment size specified

    bb(spaces) All The call was executed normally

    A3 ISRT Program tried to send a message to a modifiable PCB

    but no destination associated with it.

    A5 ISRT Program specified a MOD name for a segment other

    than the first in output message

    QC Message GU No input message are present for the program

    QD Message GN No segments are present for the current input message

    QE Message GN The Program issued a GN call before message GU call

    QF Message GU,

    ISRT

    The message segment is 5 chars long or less

    QH Message ISRT The destination of output message is undefined

    RX Database ISRT The call violated a replace rule for a segment

    XA Message ISRT The program has already responded to the originating

    terminal, but it is trying to pass the SPA to another

    program

    XB Message ISRT The Program has already passed the SPA to another

    program but trying to send output message to theoriginating terminal

    XC Message ISRT The Program sent a message whose ZZ field has value

    other than binary zeros

    XF Message ISRT The logical terminal involved in a conversation is not

    defined properly to IMS

    X1 Message

    GU,ISRT

    An IO error occurred while IMS was Accessing the

    SPAX2 Message ISRT The first output message of a conversational program

    was not the SPA

    X3 & X7 Message ISRT SPA is invalid because the first six bytes were altered

    by the program

    X4 Message ISRT The program tried to perform a message switch to a

    non conversational program

    X5 Message ISRT The program tried to perform a message switch by

    passing SPA to it more then once

    X6 Message ISRT Th program tried to perform a message switch to a

    transaction that is not defined.

    X8 Message ISRT A system or I-O errorX9 Message ISRT The SPA the program tried to insert is larger then the

    value specified in PSB

  • 8/3/2019 IMS Handout

    39/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 37 of 84

    17.DL/I Access MethodsThe different Access methods are:

    HSAM -> Hierarchical Sequential Access Method HISAM-> Hierarchical Indexed Sequential Access Method HDAM -> Hierarchical Direct Access Method HIDAM-> Hierarchical Indexed Direct Access Method17.1. HSAM

    Is stored on a tape or DASD as a sequential data set.Here the segments of a database record are related by physical adjacency.Used for sequential processing only i.e. entire database is searched sequentially

    for a segment.

    GN, GU,GNP calls can be processed. No capability for REPL and DLET calls.Any modification on existing database is done by creating a new version

    of database.Sequence Key need not be defined for the dependents, when defined for

    the root the database records should be stored in ascending value of key.

    17.1.1. Defining HSAM10 1617 72

    DBD NAME=SAMHSAM,ACCESS=HSAM

    DATASET DD1=SAMHSAM1,DD2=SAMHSAMO,DEVICE=3380, X

    RECORD=(512,512)

    ACCESS=HSAM specifies that DL/I access method HSAM should be used

    DD1=SAMHSAMI,DD2=SAMHSAMO

    SAMHSAMI is used for input operations (GN, GU,GNP)

    SAMHSAMO is used to contain new version of database after replace or delete

    RECORD=(512,512) is the record length of SAMHSAMI, SAMHSAMO

    respectively

    HSAM does not have capability of Multiple data set groups* logical relations* Secondary Indexing*Note: * will be discussed later.

  • 8/3/2019 IMS Handout

    40/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 38 of 84

    17.1.2. Stored Segment Occurrence

    Fig.17.0.

    Segment Type Code (STC): This is the first byte in the segment. The valueranging from 1-255.

    Delete Byte: It is of one byte. When set used to indicate that the segmentoccurrence is marked for deletion. Not used in case of HSAM.

    Segment Data: The actual data of the segment.17.2. HISAM

    Requires two data sets Primary Overflow

    Gives indexed access to root segment data stored in primary data set. Gives sequential access to the dependents. (may be stored in

    Primary/Overflow dataset).

    Capability for REPL and DLET calls. Used primarily for sequential processing.HISAM using Key Sequential Data Set (KSDS) as Primary Data set and

    Entry Sequential Data Set (ESDS) as overflow data set

    17.2.1. Data storage using KSDS-ESDS:

    S

    T

    C

    D

    B SEGMENT DATA

    INDEX

    SET

    SEQUENCE

    SET

    CONTROL

    AREA

    CONTROLINTERVAL

    (CI)

    Dependent

    data

    KSDS Dataset Fig. 17.1.

    Note: - - - - -> indicates NDP

    00

    ESDS Dataset

  • 8/3/2019 IMS Handout

    41/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 39 of 84

    As shown in thefig.17.1. KSDS is divided into Index component and Data

    component The index component contains the index set and sequence set. The data is stored in control Area. Control Area is divided in to number of Control Intervals (CI). Number of entries in sequence set will be equal to number of CI in a control

    area.

    Number of sequence sets will be equal to the number of control areas. The entries in index set correspond to the number of sequence set. An entry in sequence set corresponds to the highest value of the root segment

    entered in CI.

    Each database record starts at the beginning of logical record in primarydataset.

    The Root along with some of the dependents is stored in KSDS and theremaining dependents are stored in ESDS.

    The pointer from a root in KSDS to corresponding dependents in ESDS , thelink between two records in ESDS is called as next dependent pointer(NDP).

    NDP occupies four bytes and contains the Relative Byte Address (RBA) ofnext dependent segment in ESDS.

    NDP will have value zeros if it is in the last segment occurrence of a particulardatabase record.

    Insertion, Replace and Deletion can be performed for segments in bothdatasets.

    In case of deletion of a segment occurrence in KSDS the deletion is physicallydone and the space becomes reusable.

    Deletion in case of ESDS dataset is done by setting the delete byte in thatsegment occurrence. Physical deletion does not take place. Hence the space isnot reusable.

    17.2.2. Stored Segment Occurrence

    Fig.17.2.

    In fig. 17.2. NDP stands for next dependent pointer that occupies four bytes andcontains the Relative Byte Address (RBA) of the record containing next

    dependent segment.

    S

    T

    C

    D N

    B D

    PSEGMENT DATA

  • 8/3/2019 IMS Handout

    42/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 40 of 84

    Insertion

    Each time a root Segment is entered a new KSDS record is created. Root Segment is placed at the front of the record. As many subordinate segments as will fit in the record are placed after the root. If the KSDS is filled before all the dependent segments are loaded A new ESDS record is created. Next dependent segment is placed at the front of the record. RBA of the ESDS is placed in the next dependent pointer position of the root.

    If ESDS record is filled before all dependent segments have been loaded A new ESDS record is created. RBA of the new ESDS record is placed in the NDP position of the previous

    ESDS record.

    HISAM using Indexed Sequential Data Set (ISDS) as Primary Dataset and

    Operating System Access Method (OSAM) as overflow dataset.

    Data storage in ISAM-OSAM

    HISAM

    ISAM/OSAM

    ISAM

    dataset

    OSAM

    dataset+

    Fig.17.3.

  • 8/3/2019 IMS Handout

    43/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 41 of 84

    Here no control Intervals/ control areas are there. Here ISAM is divided intological records.

    The Index contains entry for each logical record in ISDS.

    17.2.3. Stored Segment Occurrence

    Fig.17.4.

    In fig 17.4. NDP stands for next dependent pointer, which occupies four bytes

    and contains the Relative Byte Address (RBA) of next dependent segment. Here

    the NDP exists at the end of all stored segments in the record. Here address is of 3bytes.

    ROP stands for Root Overflow Pointer. It is used to contain the pointer to a rootin OSAM dataset, inserted after initial load.

    Data storage in ISAM / OSAM

    Fig. 17.5

    Segment Prefix Root Segment Data Next

    Overflow Dependent

    Pointer Pointer

    CRS1 CRS3 CRS4

    CRS1

    ROP CRS3

    CRS4

    Dependent Data

    Dependent Data

    CRS2

    .

    .

    New Root Inserted OSAMISAM

  • 8/3/2019 IMS Handout

    44/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 42 of 84

    While loading the database initially, each root segment is stored in an ISAMrecord.

    As many subordinate segments as will fit in the record are placed after the root. The root along with some of the dependents is stored in ISAM dataset and the

    subsequent segments are stored are stored in OSAM dataset.

    RBA of OSAM record is placed in dependent pointer of ISAM record. For all Subsequent segments a new OSAM record is created and next dependent

    pointer of previous record is set accordingly.

    If the insertion of a root segment occurrence is done after the initial loadingthen

    Case (i)The root segment is being inserted in between two previouslyentered root segment occurrences.

    Here the root segment along with its dependents gets inserted in OSAM dataset. The ROP is adjusted accordingly so that proper link is maintained.

    Eg: In Fig.17.5. Two COURSES with sequence key CR1 and CR3 have

    been initially inserted and now we want to insert course with sequence keyCR2.A new record is created in OSAM and COURSE with sequence key CR2 is

    stored in it along with its dependents.

    Now the ROP of COURSE with sequence key CR3 points to COURSE withsequence key CR2.

    Note: Here index once created during initial loading is not updated. The

    links are maintained through ROP.

    Case(ii) The root segment occurrence is to be inserted at the end of thedatabase( i.e. after the previously entered record)

    Here a new record is created in ISAM and the data is filled accordingly as

    when initially loaded.

    Eg: Infig. 17.5. COURSES with sequence key CR1,CR2 and CR3 have beeninitially inserted and now we want to insert course with sequence key CR4.

    A new record is created in ISAM. The root along with some dependents

    depending on the size of record are filled in that record and the subsequent

    segments are inserted in OSAM. The index is updated accordingly.

    Deletion in case of ISAM-OSAM Deletion of a segment is accomplished by setting the flag in Delete byte. Here space after deletion is not reusable.(both for the data stored in ISAM as well as

    OSAM).

  • 8/3/2019 IMS Handout

    45/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 43 of 84

    HISAM has capability of Multiple dataset groups* logical relations* Secondary Indexing*

    Note: * will be discussed later.

    Defining a HISAM

    DBD NAME=SAHISAM,ACCESS=(HISAM,VSAM)

    DATASET DD1=HISAMPR,OVFLW=HISAMOV

    DEVICE=3380,RECORD=(128,128)

    ACCESS=(HISAM,VSAM) specifies DL/I access method HISAM should be used. VSAM is used

    as underlying access method.

    DD1=HISAMPR, ,OVFLW=HISAMOV

    HISAMPR is the primary dataset(KSDS)

    HISAMOV is the overflow dataset(ESDS)

    RECORD=(128,128) is the length of HISAMPR, ,HISAMOV respectively.

    Hierarchical Direct (HD) databases Use Hierarchical Direct Access Method. Here the relationships among segments do not rely on their physical positions. Instead

    segments are related to one another by pointer values stored in them. The pointer values are four-byte relative addresses (RBAs). Here each direct pointer which is

    stored in the segments prefix points directly to another segment occurrence, whether that

    segment is at the beginning of a record or not. After a segment has been inserted into a HD database, its position is fixed; i.e. it isnt moved

    when some other segments are added as in HISAM database.

    When a segment is deleted from a HD data base the space is immediately available to storeanother segment.

    Child & Twin Pointers

    There are four kinds of child/Twin Pointers.

  • 8/3/2019 IMS Handout

    46/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 44 of 84

    Physical Child First (PCF) Pointer This pointer is a part of the prefix of parent segmentand its value contains the RBA of the first child occurrence of the related child segment

    subordinate to the parent segment. If a parent segment has more than one directly dependentsegment types, there is one PCF pointer for each.

    Physical Child Last (PCL) Pointer This points to the last occurrence of the specifiedsegment type subordinate to a given parent segment occurrence .

    Physical Twin Forward (PTF) Pointer This pointer chains to the next twin segmentoccurrence.

    Physical Twin Backward (PTB) Pointer This pointer chains to the previous twinsegment occurrence. This pointer is optional.

    17.3. HDAM Provides Direct (randomized) access to the root. Provides Direct (pointer) access to the dependents. Used for primarily direct processing. Implemented using either ESDS or OSAM.

    Data Storage using ESDS/OSAM

    Logical Record

    Root Addressable Area

    Overflow Area

    ESAM/ OSAM

    Fig. 17.6.

  • 8/3/2019 IMS Handout

    47/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 45 of 84

    ESDS/ OSAM dataset are divided into two areas:

    Root Addressable Area:Overflow Area. (Refer fig.17.6.)In each control interval in the root addressable area, DL/I creates one/more rootanchor points (RAPs). A RAP is a four-byte field that contains an RBA. RAP points

    to the occurrences of root segments . Maximum number of RAPs that can be defined

    in a CI is 255.

    When a root segment is inserted in HDAM database the HDAM randomizing

    module thats being used calculates two values:

    The CI that should contain the segment The RAP within the CI that should point to it. Then if adequate space is

    available in the CI, DL/I adds the segment to the control interval and stores its

    RBA in the RAP. And if enough space isnt available in the CI for the rootsegment, Dl/I stores it in a nearby CI that has enough free space.

    Randomizing Module: This is a program that uses a technique similar to hashing

    function and generates the random address used to store the records.

    The following parameters have to be given as the input for randomizing module.

    RMname = (Name, Anchor pt, rbn, Bytes)

    Name: is the name of the module we are using for random generation.

    Anchor pt: specifies the number of RAPs required.rbn: specifies number of RBNs to be used for root addressable area.

    Bytes: number of bytes of a database record to be stored along with root segment

    occurence.

    Root segments that randomize to the same RBN and RAP are called synonyms.They are chained through twin pointers.

  • 8/3/2019 IMS Handout

    48/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 46 of 84

    17.3.1. Defining HDAMDBD NAME=SAHDAM,ACCESS=(HDAM,VSAM),

    RMNAME=(DFSHDC10,,10)DATASET DD1=SAHDAM1,DEVICE=3380

    SEGM NAME=COURSE,POINTER=TWINBWDFIELD

    .

    .

    .

    .SEGM NAME=PREREQ,PARENT=((COURSE,DBLE)),

    POINTER=TWINBWD

    POINTER=TWIN means PTF should be generated

    =TWINBWD means PTF and PTB should be generated

    =NOTWIN means no twin allowed i.e. neither PTF nor PTBgenerated.

    PARENT=(0 or segment name, SNGL or DBLE)

    0 means the segment is root else if segment name givenmeans that segment is the parent of the segment being

    defined.

    SNGL means PCF should be generated

    DBLE means PCF and PCL should be generated.

    17.3.2. Stored Segment Occurrence

    Fig.17.7.

    STC DB PTF PTB PCF PCL .......................... Segment Data

  • 8/3/2019 IMS Handout

    49/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 47 of 84

    17.4. HIDAM Provides indexed access to the root segment. Provides pointer access to the subordinate segments i.e. direct access. It consists of two databases namely Main database. Index database.

    Each of the databases is defined through their own DBDGEN. Root segments & subordinate segments are stored in the OSAM or ESDS

    dataset.

    The segments in the main database are chained through Child pointers (PCF, PCL). Twin pointers (PTF, PTB).

    Access to the root segment is via index database. Subordinate segments are accessed via twin/child pointers. Index database is used to index the database records stored in the main

    database

    Index contains only one segment (root only). Index segment prefix contains the pointers to database records. Index database can use either ISAM or VSAM. Index database is HISAM database & HISAM rules apply to it.

    17.4.1. Defining HIDAMMain database

    DBD NAME=SAHDAM,ACCESS=(HIDAM,VSAM),RMNAME=(...)DATASET DD1=SAHIDAM,DEVICE=3380

    SEGM NAME=COURSE,POINTER=TWINBWDLCHILD NAME=(IDXSEG,IDXDBD),POINTER=INDEX

    FIELD NAME=(CRSNO,SEQ),BYTES=

    .

    .

    .

    .

    SEGM NAME=PREREQ,PARENT=((COURSE,DBLE)),POINTER=TWINBWD

  • 8/3/2019 IMS Handout

    50/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 48 of 84

    Index Database

    DBD NAME=IDXDBD,ACCESS=(INDEX,VSAM),DATASET DD1=IDXDS,DEVICE=3380

    SEGM NAME=IDXSEG, BYTES=..

    LCHILD NAME=(COURSE,EDUDBD),INDEX=CRSNOFIELD NAME=(CRSNO,SEQ),BYTES=DBDGEN

    FINISH

    END.

    18.Secondary Indexing

    Fig.18.0.

    IMS being a hierarchical database supports only one to many relationships.

    Eg: Infig. 18.0. a query like all the students in a particular class can be obtained but a

    query like Find details of a CLASS given the STUDENT details cannot be answered.

    In order to facilitate the access of a parent through its child secondary indexing is used.

    DL/I maintains an alternate sequence by storing pointers to segments of indexed database ina separate index database.

    18.1. Segments in secondary indexing

    COURSE

    CLASS

    INSTRUCTOR STUDENT

  • 8/3/2019 IMS Handout

    51/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 49 of 84

    Pointer Segment:Is present in the indexed database. It contains the key field (indexed field)

    and points to the segment that is to be retrieved.

    Source Segment:Contains field or fields that the pointer segment uses as key field. Each timea new entry is made in source segment the corresponding entry is duplicatedin index database. Should be at the same level or at lower level as target

    segment.

    In case if source and target segments are different, source segment should bedependent of target segment.

    Target Segment:Is the one which is retrieved .It is present in the main database. Pointersegment points to the target segment. Target segment can be at any of the 15

    levels. If target segment is not specified then the source itself becomes the

    target segment.

    Pointer segment contains two main elements:

    Prefix element:The prefix element of pointer segment contains a pointer to the target segment.

    Data element:The data element contains the key value on which index is built.

    18.2.Secondary Data StructureWhen a secondary index is created the hierarchical tree structure changes. The re-

    arranged tree structure is called as secondary data structure.

    Properties of secondary data structure

    The target segment becomes the root. Ancestors of target segment will become the dependents to the target

    segment, in the reverse order.

    Original dependants of target segment are moved to the right. Others segments are not included.

    The data structure shown in fig.8.0. becomes:

    CLASS

    COURSE STUDENT

  • 8/3/2019 IMS Handout

    52/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 50 of 84

    Fig.18.1.

    Secondary Data Structure

    Note: Infig.18.1. a secondary index from to INSTRUCTOR cannot be created

    as STUDENT is not a dependent of INSTRUCTOR.

    18.3.Pointers in secondary indexing Direct Pointer: Here the relative byte address (RBA) of target segment is

    stored in prefix of the pointer segment. This can be used only in HD databasesand cannot be used in HISAM, as in HISAM the records are continuously

    moving, which results in constant changing RBA.

    Pointer segment for Direct Pointer:

    Fig. 18.2.

    Symbolic Pointer: Here the sequence key field of the source segment isduplicated in data portion i.e. the key field is physically stored. This is

    generally used in case of HISAM database.

    Pointer segment for Symbolic Pointer:

    Fig.18.3.

    DBDGEN requirements for secondary indexing: (Refer fig.18.0.)

    Main DBD

    PRINT NOGENDBD NAME=EDUDBD,ACCESS=HDAM

    DATASET DD1=COURSE,DEVICE=3380

    SEGM NAME=COURSE,PARENT=0,BYTES=10FIELD NAME=(CRSNO,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=CRSNAME,BYTES=4,START=7,TYPE=C

    SEGM NAME=CLASS,PARENT=COURSE,BYTES=10FIELD NAME=(CLSNO,SEQ,U),BYTES=3,START=1,TYPE=C

    S D P P RBA of target segment Segment data.

    T B T TC F B

    S D P P Key field of the Target Segment data.

    T B T T segment

    C F B

  • 8/3/2019 IMS Handout

    53/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 51 of 84

    LCHILD NAME=(IDXSEG,IDXDBD),POINTER=INDX

    XDFLD NAME=XSTUNO,SRCH=STUNO,SEGMENT=STUDENT

    FIELD NAME=CLSNAME,BYTES=4,START=7,TYPE=CSEGM NAME=STUDENT,PARENT=CLASS,BYTES=10

    FIELD NAME=(STUNO,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=STUNAME,BYTES=4,START=7,TYPE=CSEGM NAME=INSTRT,PARENT=CLASS,BYTES=10FIELD NAME=(INSNO,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=INSNAME,BYTES=4,START=7,TYPE=C

    DBDGENFINISH

    END

    Index DBD

    PRINT NOGEN

    DBD NAME=INDEXDBD,ACCESS=INDEXDATASET DD1=IDX1,DEVICE=3380

    SEGM NAME=IDXSEG,PARENT=0,BYTES=3

    LCHILD NAME=(IDXSEG,IDXDBD),POINTER=INDX

    FIELD NAME=(STUNO,SEQ,U),BYTES=3,START=1,TYPE=CDBDGEN

    FINISH

    END

    PSBGEN requirements for secondary indexing:

    PCB for normal view

    PCB TYPE=DB,DBDNAME=EDUDBD,KEYLEN=9,PROCOPT=A

    SENSEG NAME=COURSE, PARENT=0SENSEG NAME=CLASS, PARENT=COURSE

    SENSEG NAME=STUDENT, PARENT=CLASS

    SENSEG NAME=INSTRT, PARENT=CLASS

    PCB for secondary index view

    PCB TYPE=DB,DBDNAME=EDUDBD,KEYLEN=9,PROCOPT=A

    PROCSEQ=IDXDBDSENSEG NAME=CLASS, PARENT=0

    SENSEG NAME=COURSE, PARENT=CLASS

    SENSEG NAME=STUDENT, PARENT=CLASS

    PSBGEN NAME=EDUPSB,LANG=COBOL

    END

  • 8/3/2019 IMS Handout

    54/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 52 of 84

    Some of the terms related to secondary indexing:

    LCHILD: This macro relates a target segment to its associated secondaryindex database.

    Eg: In the Main DBD the macro LCHILD relates CLASS segment to thepointer segment IDXSEG in the secondary index database IDXDBD.LCHILD macro declared in the index segment of index DBD relates pointer

    segment to the target segment.

    XDFLD: This macro supplies a field name that is used to access the databasevia the secondary key.

    SRCH: This specifies the fields from the source segment that are used tobuild Indexed field. The maximum number of fields that can be given in

    SRCH is 5. In case when indexed field is not unique (i.e. there are duplicate

    values in indexed field) the search field may be made unique by addinganother field in search criteria. Even if 5 fields together do not make the

    search unique then SUBSEQ (subsequent) fields can be added. Subsequent

    fields are not given during actual search.

    Search keys can be made unique using system defined fields. In HD databases,

    code the field name starting with /SX. The name of the field can go upto 8

    characters including /SX. When this kind of field is coded IMS generates aunique 4 byte RBA of source segment and puts it in the subsequent field of

    the pointer segment. For the system field no start must be coded as /SX field

    does not occupy any storage.

    PROCSEQ: For secondary index PCB view PROCSEQ parameter isspecified on the PCB macro. In absence of this parameter the processing is

    done in usual hierarchic sequence.

    The value of PROCSEQ is the DBD name of the secondary index database. This

    indicates the new processing sequence and the processing is done based on thesecondary index view. If the same program needs to access more than one

    secondary indexed database, the multiple PCBs are coded with different

    PROCSEQ values.

    Multiple Dataset Group

    The hierarchical tree structure can be stored in more than one dataset group. There willbe one primary dataset group and there can be multiple (maximum 9) secondary dataset

    groups. The root essentially being stored in the primary dataset group.

  • 8/3/2019 IMS Handout

    55/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 53 of 84

    Used to increase the efficiency of search and retrieval of data.

    It can be used for HISAM and HD databases.

    In case of HISAM split can occur only at the second level i.e. at immediate child of root.In case of HD databases split can occur at any level below root provided the parent and

    child segments at split point are connected through child pointers and twin segments in

    child are connected through twin pointers .

    What is a logical relationship?

    A logical relationship is the link between two segments that are otherwise unrelated. These

    two segments may reside in separate physical databases. Logical relations are establishedfor:

    Accessing a segment in another database: During data conflicts between segments, thesegment causing conflict can be kept in a separate database and a logical relation ship can bestablished.

    Fig.20.0.

    Note: indicates logical relationship.

    Eg: Infig.20.0. CUSTOMER segment cannot be put under any segment becausethis leads to many to many relationships. In order to avoid this conflict

    CUSTOMER is put in a separate database and a logical relationship between

    CUSTOMER and STUDENT is established. The basis for logical relation ship is

    called logical child segment. The logical child has two parents: one physical

    parent and one logical parent.

    In fig.20.0. STUDENT is the logical child, CLASS is the physical parent andCUSTOMER is the logical parent.

    Inverting parent child relationship: In an hierarchical tree, to provide access fromchild to parent without disturbing the existing parent child relationship this technique

    COURSE

    CLASS

    CUSTOMER

    STUDENTINSTRUCTOR

    CUSTOMER

  • 8/3/2019 IMS Handout

    56/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 54 of 84

    is used. In this case the parent must be the original segment and the logical child

    may be dummy segment.

    Fig.20.1.

    Note: indicates logical relationship

    In fig.20.0. if a report has to be generated instructor wise i.e. classes handled bythe instructor it is not possible directly. Considerfig.20.1. using this the same report

    can be generated very easily.

    Types of Logical Relationships

    Unidirectional logical relationship: The relationship is from logical child to logical parent. Logical parents data

    can be accessed from logical child but vice versa is not allowed.

    One logical child can have one logical parent and one physical parent, for allthe occurrences of that child segment type.

    Logical relation is established using logical parent pointer (LP).

    Logical parent pointer is of two types:

    COURSE

    CLASS

    (Parent)

    STUDENTINSTRUCTOR

    (Dummy)

    CLASS

    (Dummy)

    INSTRUCTOR

    (Parent)

  • 8/3/2019 IMS Handout

    57/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 55 of 84

    1) Symbolic Pointer: In this the logical parent concatenated key (LPCK)is physically stored as the first field of logical child. This pointer isused when the parent resides in HISAM database.

    Fig 20.2.

    2) Direct Pointer: In this, the relative byte address of logical parent isstored in logical child in its pointer area. This is used when parentresides in HD databases.

    Fig 20.3.

    DBDGEN requirements for unidirectional logical relationship in HDAM

    database: (Refer fig.20.0.)

    DBD for customer data base

    PRINT NOGENDBD NAME=CUSTDBD,ACCESS=(HDAM,VSAM), RMNAME=(..)

    DATASET DD1=CUST,DEVICE=3380

    SEGM NAME=CUSTOMER, BYTES=11, PARENT=0,POINTER=TWINBWDFIELD NAME=(CUSTNO,SEQ,M),BYTES=3,START=1,TYPE=C

    LCHILD NAME=(STUDENT,EDUDBD)

    FIELD NAME=CUSTNAME,BYTES=7,START=4,TYPE=CDBDGEN

    S D P P Logical Parent Pointer Segment data.T B T T (LP)

    C F B LPCK of the logical parent

    S D P P Logical Parent Pointer Segment data.

    T B T T (LP)

    C F B RBA of the logical parent

  • 8/3/2019 IMS Handout

    58/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 56 of 84

    FINISH

    END

    DBD for COURSE database

    PRINT NOGEN

    DBD NAME=EDUDBD,ACCESS=(HDAM,VSAM), RMNAME= (. )

    DATASET DD1=COURSE,DEVICE=3380

    SEGM NAME=COURSE,PARENT=0,BYTES=10FIELD NAME=(CRSNO,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=CRSNAME,BYTES=7,START=4,TYPE=C

    SEGM NAME=CLASS,PARENT=COURSE,BYTES=10

    FIELD NAME=(CLSNO,SEQ,U),BYTES=3,START=1,TYPE=CFIELD NAME=CLSNAME,BYTES=7,START=4,TYPE=C

    SEGM NAME=STUDENT, BYTES=11,

    PARENT=((CLASS),(CUSTOMER,P,CUSTDBD)),POINTER=(LPARNT,TWINBWD),RULE=(LLL,LAST)

    FIELD NAME=(CUSTNO,SEQ,M),BYTES=6,START=1,TYPE=C

    FIELD NAME=STUNO,BYTES=3,START=4,TYPE=C

    FIELD NAME=STUNAME,BYTES=4,START=7,TYPE=CSEGM NAME=INSTRT,PARENT=CLASS,BYTES=10

    FIELD NAME=(INSNO,SEQ,U),BYTES=3,START=1,TYPE=C

    FIELD NAME=INSNAME,BYTES=7,START=4,TYPE=CDBDGEN

    FINISH

    END

    DBD indicating logical relation

    PRINT NOGEN

    DBD NAME=LOGDBD,ACCESS=LOGICAL

    DATASET LOGICAL

    SEGM NAME=COURSE,PARENT=0,SOURCE=(COURSE,D,EDUDBD)SEGM NAME=CLASS,PARENT=COURSE,SOURCE=(CLASS,D,EDUDBD)

    SEGM NAME=STUCUST,PARENT=CLASS,

    SOURCE=((STUDENT,D,EDUDBD),(CUSTOMER,D,CUSTDBD))SEGM NAME=INSTRT,PARENT=CLASS, SOURCE=(INSTRT,D,EDUDBD)

    DBDGEN

    FINISHEND

  • 8/3/2019 IMS Handout

    59/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 57 of 84

    Note: In case of HIDAM the DBDs will remain same but only addition is a

    LCHILD statement after the segment definition and the sequence field definitionindicating the index and in index data base the corresponding LCHILD must be

    specified.

    PSBGEN requirements for logical relationship (Refer fig.20.0.)

    Normal View

    PRINT NOGEN

    PCB TYPE=DB,DBDNAME=EDUDBD,KEYLEN=9,PROCOPT=A

    SENSEG NAME=COURSE,PARENT=0SENSEG NAME=CLASS,PARENT=COURSE

    SENSEG NAME=STUDENT,PARENT=CLASS

    SENSEG NAME=INSTRT,PARENT=CLASS

    PCB TYPE=DB,DBDNAME=CUSTDBD,KEYLEN=3,PROCOPT=A

    SENSEG NAME=CUSTOMER,PARENT=0

    Logical View

    PCB TYPE=DB,DBDNAME=LOGDBD,KEYLEN=9,PROCOPT=ASENSEG NAME=COURSE,PARENT=0

    SENSEG NAME=CLASS,PARENT=COURSE

    SENSEG NAME=STUCUST,PARENT=CLASS

    SENSEG NAME=INSTRT,PARENT=CLASS

    PSBGEN PSBNAME=LOGPSB,LANG=COBOL

    END

    Definitions

    PARENT Operand specified for the logical child segment. Specifies whether direct pointer is used or symbolic pointer is used.

    Format: PARENT ((physical parent name), (logical parent name, P/V, dbd name oflogical parent)).

    PPhysical; V Virtual

    If the parameter is Pin the declaration along with the logical parent name it

    means that the logical parent concatenated key is stored as first field in the logical

  • 8/3/2019 IMS Handout

    60/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 58 of 84

    child i.e. symbolic pointer is used. If V is specified then logical parents key isused to generate the relative byte address of the logical parent and the key of

    logical parent is not stored i.e. direct pointer is used.

    Layout of Concatenated Segment:

    Fig.20.4.

    SOURCE Is used to represent a concatenated segment.Format: SOURCE=(segment name, D/K, dbd name) for normal segments.

    SOURCE=((logical child segment name, D/K, dbd name),(logical parent segment name, D/K, dbd name)

    For the concatenated segment.

    K Key value.

    D Data value.

    This value K or D is specified in order to control the data that is coming into the

    I-O area. If K is specified only key value of that segment is moved into I-O areaand if D is specified the entire data is moved into I-O area.

    DATASET LOGICAL indicates that the database exists virtually and is notphysically stored.

    Logical Twins: are the occurrences of a logical child segment type that are allsubordinates to a single occurrence of the logical parent segment type.

    Note: In case of uni-directional logical relationship access from logical parent tological child is not allowed. In order to facilitate access in either direction bi-

    directional logical relationship should be used.

    Bi-directional physically paired logical relationship: The relation ship is two ways: from logical child to logical parent and vice

    versa.

    Logical Child Logical Parent

    LPCK Intersection data LPK Logical Parent data

  • 8/3/2019 IMS Handout

    61/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 59 of 84

    In this case the logical child is duplicated in both the databases. When logical child is accessed from its physical parent the path is said to be

    a physical path.

    Fig.20.5.

    DBDGEN requirements for Bi-directional logical relationship(Refer fig.20.5.)

    DBD for AREA database

    PRINT NOGENDBD NAME=AREADBD,ACCESS=(HDAM,VSAM), RMNAME= (.)

    DATASET DD1=AREA1,OVFLW=AREA2,DEVICE=3380

    SEGM NAME=AREA, BYTES=10,POINTER=TWINBWDFIELD NAME=(AREANO,SEQ,U),BYTES=3,START=1,TYPE=C

    LCHILD NAME=(SIGHTB,BIRDDBD),PAIRED=SIGHTA

    FIELD NAME=AREANAME,BYTES=7,START=4,TYPE=CSEGM NAME=SIGHTA,PARENT=((AREA),(BIRD,P,BIRDDBD)),

    BYTES=35,POINTER=(TWINBWD,LPARNT,PAIRED)

    FIELD NAME=(BIRDNO,SEQ,M),BYTES=3,START=1,TYPE=C

    FIELD NAME=DATE,BYTES=8,START=4,TYPE=C

    FIELD NAME=REMARKS,BYTES=22,START=13,TYPE=CDBDGEN

    FINISHEND

    DBD for BIRD database

    AREA

    SIGHTA

    BIRD

    SIGHTB

    Physically paired

  • 8/3/2019 IMS Handout

    62/85

    TATA Information Management System

    INFOTECH LTD. Hand Out

    IIMSHD/VER 0.2 For Internal Use Only Page 60 of 84

    PRINT NOGEN

    DBD NAME=BIRDDBD,ACCESS=(HDAM,VSAM), RMNAME= (. )

    DATASET DD1=BIRD1,OVFLW=BIRD2,DEVICE=3380SEGM NAME=BIRD,PARENT=(0,DBLE),

    BYTES=10,POINTER=TWINBWD

    FIELD NAME=( BIRDNO,SEQ,U),BYTES=3,START=1,TYPE=CLCHILD NAME=(SIGHTA,AREADBD),PAIRED=SIGHTBFIELD NAME= BIRDNAME,BYTES=7,START=4,TYPE=C

    SEGM NAME=SIGHTB,PARENT=(( BIRD),(AREA,P,AREADBD)),

    BYTES=35,POINTER=(TWINBWD,LPARNT,PAIRED)FIELD NAME=(AREANO,SEQ,M),BYTES=3,START=1,TYPE=C

    FIELD NAME=DATE,BYTES=8,START=4,TYPE=C

    FIELD NAME=REMARKS,BYTES=22,START=13,TYPE=C

    DBDGENFINISH

    END

    DBD indicating logical relation of SIGHTA with BIRD

    PRINT NOGENDBD NAME=LOGDBD1,ACCESS=LOGICAL

    DATASET LOGICAL

    SEGM NAME=AREA,PARENT=0,SOURCE=(AREA,D,AREADBD)SEGM NAME=SIBIRD,PARENT=AREA,

    SOURCE=((SIGHTA,D,AREADBD),(BIRD,D,BIRDDBD))

    DBDGEN

    FINISHEND

    DBD indicating logical relation of SIGHTB with AREA

    PRINT NOGEN

    DBD NAME=LOGDBD2,ACCESS=LOGICALDATASET LOGICAL

    SEGM NAME=BIRD,PARENT=0,SOURCE=(BIRD,D,BIRDDBD)

    SEGM NAME=SIAREA,PARENT=BIRD,

    SOURCE=((SIGHTB,D,BIRDDBD),(AREA,D,AREADBD))

    DBDGENFINISH

    END

    Logical View1

    AREA

    SIGHTA BIRD

    SIBIRD

  • 8/3/2019 IMS Handout

    63/85

    TATA Information Management System