You are on page 1of 120

IDMS/R

Version 2.0
16-May-2002

1

IDMS/R
Table of Contents

1. Overview ....................................................................................................................................6
1.1. IDMS/R and DBMS ...........................................................................................................6
1.2. Database Approach ............................................................................................................6
1.2.1. Data Integrity ..............................................................................................................6
1.2.2. Application Development Productivity .....................................................................7
1.3. Different Database Architectures .....................................................................................7
1.3.1. Hierarchical .................................................................................................................7
1.3.2. Network ........................................................................................................................7
1.3.3. Relational .....................................................................................................................8
1.3.4. Difference Between RDBMS and Network, Relations, Chain Pointers .................9
1.4. IDMS/R: - Network and Relational Facilities, DBMS ..................................................10
2. Logical Database Structure ....................................................................................................12
2.1. Entity, Logical and Physical Structure...........................................................................12
2.2. Attributes, Relationships – Training Database ............................................................12
2.3. Entity-Relationship Diagrams .......................................................................................13
2.4. IDMS Database Records, Record Type, Record Occurrences ....................................14
2.5. One-To-Many and Many-To-Many Relationships .......................................................14
2.6. IDMS Set, Set Type, Set Occurrence, Bubble Diagram ...............................................15
2.7. Schema, Subschema .........................................................................................................19
3. IDMS/R Batch Program .........................................................................................................20
3.1. Operating Environment ..................................................................................................20
3.2. DML Statements: Executable and Compiler Directive ................................................20
3.3. Three Steps Compilation: DML Pre-processor, Compilation and Linking ...............20
3.4. Compiled Listing of Sample IDMS/R Program ............................................................22
3.5. Run-Unit ...........................................................................................................................28
3.6. Virtual Storage Layout ....................................................................................................29
3.7. DML Execution Steps ......................................................................................................30
4. Physical Database Structure ..................................................................................................32
4.1. Areas ..................................................................................................................................32
4.2. Pages ..................................................................................................................................32
4.3. DB-Key ..............................................................................................................................34
4.4. Multiple Areas ..................................................................................................................34
4.5. Files ....................................................................................................................................35
4.6. Record occurrence – Prefix, Data ...................................................................................35
5. Record .....................................................................................................................................37
5.1. Record Name ....................................................................................................................37
5.2. Record Identifier ..............................................................................................................37
5.3. Storage Mode ....................................................................................................................37
5.4. Record Length ..................................................................................................................38
5.5. Location Mode ..................................................................................................................38
5.6. Duplicates Option .............................................................................................................40
5.7. Area Name ........................................................................................................................41
5.8. Bachman Diagram For Record Type .............................................................................41
6. Set .............................................................................................................................................43

2

IDMS/R
6.1. Set Name ...........................................................................................................................43
6.2. Linkage Options ...............................................................................................................43
6.3. Order Options ..................................................................................................................46
6.4. Bachman Diagram For Set .............................................................................................50
7. Retrieval: Basic, By Sort-key, Indexed Set, Sweeping Areas ..............................................51
7.1. Basic Retrieval: CALC, Through Relationship ............................................................51
7.2. CALC Retrieval: Random access ...................................................................................51
7.3. Error Handling..................................................................................................................52
7.4. Access By Walking Sets i.e. Access Through Set Relationship ....................................53
7.5. Retrieval By Sort-Key Value ...........................................................................................58
7.6. Generic Key Retrieval .....................................................................................................59
7.7. Indexed Set .......................................................................................................................59
7.8. Retrieval Using Indexed Set ............................................................................................60
7.9. Bachman Diagram: Indexed Set .....................................................................................61
7.10. Retrieval By Sweeping Areas ........................................................................................62
8. Currency ..................................................................................................................................64
8.1. Currency Table ................................................................................................................64
8.2. Currency Loss ..................................................................................................................66
8.3. Storing and Retrieval By DB-Key Value .......................................................................68
8.4. Obtain Vs. Find and Get .................................................................................................69
8.5. IF <set-name> EMPTY / MEMBER: ...........................................................................71
9. Types of Set Relationships ......................................................................................................74
9.1. Hierarchies ........................................................................................................................74
9.2. Junction Record: Multiple Set Membership .................................................................76
9.3. Nested Structure – Bill Of Material ...............................................................................77
10. Set Membership Options ......................................................................................................84
10.1. Disconnect option ...........................................................................................................84
10.2. Connect option ...............................................................................................................85
10.3. Bachman Diagram and Examples ................................................................................86
11. DML Data Update Functions ...............................................................................................88
11.1. Ready ...............................................................................................................................88
11.2. Store ................................................................................................................................88
11.3. Modify .............................................................................................................................91
11.4. Erase ................................................................................................................................92
11.5. Connect ...........................................................................................................................94
11.6. Disconnect .......................................................................................................................94
12. Recovery and Restart ...........................................................................................................97
12.1. IDMS/R Operating Environments ...............................................................................97
12.2. Journal Files, Checkpoints ............................................................................................98
12.3. Recovery / Restart ..........................................................................................................98
12.4. Commit ............................................................................................................................99
12.5. Recovering From Failures ...........................................................................................100
12.6. Rollback ........................................................................................................................101
13. Locking .................................................................................................................................102
13.1. Area Locks ....................................................................................................................102
13.2. Area Usage Modes ........................................................................................................102

3

IDMS/R
13.3. Record Locks – Implicit, Explicit ...............................................................................104
14. Utilities .................................................................................................................................109
14.1. DMLO ...........................................................................................................................109
14.2. OLQ ..............................................................................................................................110
15. Appendix A: Employee Database ......................................................................................112
16. Appendix B: Compilation and Run JCL ..........................................................................114
17. Appendix C: IDMS/R ERROR-STATUS VALUES ........................................................117
18. Appendix D: References .....................................................................................................120

4

IDMS/R

Day-Wise Schedule

Day 1
Overview
Logical Database Structure
IDMS/R Batch Program

Day 2
Physical Database Structure
Record
Set

Day 3
Retrieval: Basic, By Sort-key, Indexed Set, Sweeping Areas

Day 4
Currency

Day 5
Types of Set Relationships

Day 6
Set Membership Options
DML Data Update Functions

Day 7
Recovery and Restart
Locking

Day 8
Utilities – DMLO, OLQ

5

IDMS/R

1. Overview

1.1. IDMS/R and DBMS
IDMS/R (Integrated Database Management System/Relational) is a software product
on IBM mainframe that offers capabilities for working with well-organized data.
IDMS/R is one of a number of software systems that can be classified as a DBMS
(Database Management System).

A DBMS is a software subsystem that manages a collection of interrelated data
elements, stored in a database, that can be accessed in a shared manner by a collection
of application programs.

Components of IDMS/R work around a central software subsystem called IDD
(Integrated Data Dictionary). In IDMS/R environment, all data elements used in
application system are defined in the data dictionary.

1.2. Database Approach
There are many advantages to maintaining all an organization data in a central pool or
reservoir, so that it can be shared by a number of application programs. We can place
the advantages of the database approach into two categories: Data integrity and
Application development productivity.

1.2.1. Data Integrity

Reducing / eliminating data redundancy: - There is no duplication of
information. Each piece of information is stored only once in the central pool and
application programs access it via the database management system. E.g.
information about employees is stored centrally in Employee table or structure.
Multiple copies of same data do not exist in different stages of updating.

Recovery and Restart: - A database management system provides powerful tools
for automatically recovering from system failures, restoring the database to its
original form, and restarting jobs that were affected by failures.

6

With a DBMS. and the order in which data is processed.3.1. and the DBMS performs all the necessary steps to locate the required data. since programs do not access data directly. Application Development Productivity Simplified Programming: .The application programs using conventional files are tied tightly to the formats of files they process. 1.1.2. all programs that access the record must also be modified. Network A network-structured database typically uses embedded pointers to create a mesh structure / configuration. 1. Different Database Architectures 1. If a record format changes. Supplier Order Line Item Fig. data records are typically connected with embedded pointers to form a tree structure / configuration.IDMS/R 1.3. IDMS/R is an example of network DBMS.3. Reduced Maintenance: .2. application programs make simple requests for data. Hierarchical In a hierarchically structured database. IMS is an example of hierarchical DBMS.2. changes can be made to the structure of the database without requiring that applications programs be modified. This results in application programs that are less complex than those that work with conventional files. With a DBMS. 7 . 1.In a program that uses conventional files. in which a dependent record type has one and only one parent. in which a dependent record type can have more than one parent. Data and programs are independent. much of the program logic must deal with the way in which files are read and written. These two things increase programmer productivity.

3. for retrieval) supported by the system.2. Dependent records Line-Item and Quotation have more than one parent. Relational In a relational DBMS.3.IDMS/R The term network in this context has nothing to do with a communications network! It refers rather to the kinds of data structures and operators (e.g. 1. Supplier Order Part Quotation Line-Item 8 . 1. data is represented in the form of tables in which all associations are expressed using values in the stored data and no embedded pointers are required to represent relationships between records. Supplier Part Order Line Item Quotation Fig.

4. SUBJECT Address Sub-Id Sub-Name First Last #0 S001 MVS *0 *6 #1 S002 JCL *1 *7 #2 S003 VSAM *2 *2 #3 S004 IDMS *3 *3 9 . In the Training department. many courses are conducted for different subjects. However. Chain Pointers The reason “relational systems” are called “relational” is that the term relation is basically just a mathematical term for a table. Difference Between RDBMS and Network. namely Subject and Course. Consider another example given below about chain pointers. Relational model supports one-to-many and many-to-many links. But. Thus.IDMS/R Fig. Chain pointers form a circular list. the data and the relationships among data are represented by a collection of tables. we can use a ring structure or chain pointers to represent all employees in the given department. There are two record types. Rather than using multiple pointers in Dept record. An Employee record occurrence can be associated with only one Dept record occurrence.3. a Dept record occurrence can be associated with many Employee record occurrences. Links are implemented in the Network model by adding pointer fields to records that are associated via a link. Network model supports only one-to-many links and it does not support many-to-many links. which are linked.3. suppose the Dept- Employee relationship is one-to-many from Dept to Employee. Relations. 1. 1. and relationships among data are represented by links. To illustrate the implementation of the Network model. we need only one pointer in the Employee record occurrence to represent the Dept-Employee relationship. In the relational model. The network model differs from the relational model in that data are represented by collection of records.

but the addition of relational capabilities through a software subsystem called the Automatic System Facility (ASF) has given it a dual nature. “Next” pointer of course C0701 points to next MVS course i. The programmer is forced to think in term of links. .IDMS/R COURSE Address Course-Id Course-Name Next Prior Owner *0 C0701 FIT-MVS *4 . Querying is simple in the relational model. Network structured databases can be used to handle high volume transaction processing applications which have demanding performance requirements. Relational databases can be used to accommodate user-generated applications. . and how to traverse them to get at needed information. while it is significantly more complicated in the network model. *4 #0 *7 C1002 FIT-JCL . C0901 and so on. #2 *3 C0804 FIT-IDMS . Data manipulation in the network model is hence said to be navigational.Network and Relational Facilities. #3 *4 C0901 EXP-MVS *6 *0 #0 *5 C0902 EXP-JCL *7 *1 #1 *6 C1001 FIT-MVS .“First” pointer points to first MVS course C0701. Combining both network and relational capabilities in one system provides the installation with a versatile tool for meeting both production requirements and the ease-of-use requirements of end users. DBMS IDMS/R was originally designed to be an implementation of the network database model.e. IDMS/R: . *5 #1 Consider subject MVS with Sub-Id S001: . It is clear from the preceding discussion that the Network model is closely tied to the implementation. #0 *1 C0702 FIT-JCL *5 . #1 *2 C0703 FIT-VSAM .4. 10 . 1.

The DDL is used by database designers to describe the logical and physical structure of the database to DBMS software and to application programs. ASF is menu oriented and relatively easy to use. This component is most commonly called the DBMS. In turn. all database access. IDMS/R support for a networked structured database is provided via two common languages that designers and programmers use to control access to the database: data description language (DDL) and data manipulation language (DML). The heart of any database product is the software component that manages access to the database. input/output operations. 11 . and space management are performed by the same system components. Application programs make requests for access to the database by executing DML statements. data entered through the relational facility can be used to update the production. This means that data stored in the form of network structures can be accessed by conventional application programs. IDMS/R uses a software subsystem called Automatic System Facility (ASF) to provide users with a relational view of the database. In either case. To this end. the data stored in an IDMS/R database is accessed only by the DBMS and never directly by an application program. but can also be accessed by the relational facilities for those applications that require a relational view of the network structured data. Application programs use DML to specify how the database is accessed. A major purpose of a DBMS is to isolate application programs from the details concerning how data elements are physically stored. the DBMS intercepts these requests and performs the required accesses to the database to satisfy these requests. network-structured database. IDMS/R consist of a set of software modules that manage the data elements that are stored in the database and maintains the relationships that exist between them.IDMS/R The relational and network capabilities of IDMS/R are supported by a single database management system product.

Information about faculties in Training department Subject: . At the highest level is the application environment. or ideas about which we are storing data. At any given point of time. multiple courses can be in progress. we can view the database on a number of different levels. Information about subjects taught Course: . • There are many participants for a course. Entity. Please consider the following scenario for the Training Department. On a lower level we are concerned with software. Attributes. 2. where we describe the physical structure of the database and the way in which logical records are implemented in computer storage. Entities consist of those objects. people. A faculty can teach multiple subjects.Information about participants in a course Performance: .1. A subject can be taught by multiple faculties. where we discuss the nature of the entities that we are representing in the database. Relationships – Training Database We will be using a hypothetical Training Department database that might be used to maintain information about courses conducted and faculties. where we describe the logical structure of the database that we are using to represent information about entities in the database.Information about performance of a participant 12 . Logical Database Structure 2. • There are 10 faculties in the department. to manage a central pool of data. On a still lower level is the hardware. Faculty: . assignments and test marks. The database will store information about the following entities. Information about courses of diff subjects Participant: . • The Training Dept conducts courses for various subjects. such as IDMS/R. Logical and Physical Structure When we are using a powerful DBMS.2. • Performance of a participant in a course is measured in terms of attendance.IDMS/R 2.

One faculty can teach many subjects. we can discuss the attributes that an entity has and the relationships that exist between the entities. Subject- Stream. Each course is conducted by one faculty. The Participant and Performance entities also form one-to-many relationship. etc. 2. The Course and Participant entities form another one-to-many relationship.IDMS/R In discussing entities. Faculty Subject Course Participant Performance Fig. Entity Attributes: An attribute is a particular piece of information that is associated with an entity. We use arrow symbols for connecting the boxes to represent relationships. E. Each participant attends one course. E. the Faculty and Course entities participate in one-to-many relationship. 2. An entity-relationship diagram for Training Department information is given below. The Faculty and Subject entities form a many-with-many relationship.g. Each entity is represented by a square-cornered box. possible attributes of the Subject entity are Subject-Id. Entity-Relationship Diagrams We can represent the relationships between the entities (discussed above) using an entity-relationship diagram.. Subject-Name. and each course has many participants. and a subject can be taught by many faculties. but each faculty conducts many courses. Entity Relationships: We can identify a number of relationships between the entities about which we are storing information.g.1.3. The “arrow head” points to the many 13 .

5. we begin by defining a separate database record for each entity.IDMS/R side of a relationship and the other end of the arrow indicates the “one” side of a relationship. IDMS/R does not support directly many- to-many relationships. We can think of a record type as a template. 2. One-To-Many and Many-To-Many Relationships IDMS/R supports one-to-many relationship. Subject-Name and Subject-Stream data elements as shown below. Subject Record Subject-Id Subject-Name Subject-Stream PIC X(04) PIC X(10) PIC X(06) (Subject record type) Record Types Vs. Record Type.There is a clear distinction between a record type and a record occurrence. Consider the Subject entity and its attributes. IDMS Database Records. It describes the format of all occurrences of a given record type that will be stored in the database. For each many-to-many relationship between two entities.4. We name each data element. Record Occurrences: . Subject Record Type Subject-Id Subject-Name Subject-Stream PIC X(04) PIC X(10) PIC X(06) Subject Record Occurrences S002 JCL IBM S003 VSAM IBM S004 IDMS IBM 2.In representing the Training Department database using a network-structured IDMS/R database. define its length and define the type of data that it will contain. Data elements are sometimes called data items or fields. we will almost always identify additional attributes that are not associated with either of 14 . We represent the Subject attributes using a Subject record and we represent each Subject attribute as a data element within the Subject record as shown below. Each occurrence of the Subject record type consists of a single set of values for the Subject-Id. Record Occurrences Database Records: .

Set Type. please refer to Employee Database in Appendix A. Set Occurrence. the record type on the “many” side is designated the member record type.g. there is an important distinction between a set type and a set occurrence. called junction record type. Course-Participant.2. Faculty-Course. but are associated with the intersection between the two entity types. E. 2.2. The record type on the “one” side of the relationship is designated the owner of the set.IDMS/R the two entities alone. A set occurrence. The junction record type is described in more details in Section 9. 2. on the 15 . A set consists of two or more record types that participate in one-to- many relationships with one another. Set Occurrence: As with record types and record occurrences. Faculty Subject Faculty-Course Subject-Course Course Course-Participant Participant Participant-Performance Performance Fig. Each set must be assigned a unique name. Also. which has one-to-many relationships with the two entity types. IDMS Set. The junction record resolves the many-to-many relationship and implements this many-to-many relationship indirectly. a set type can be thought of as a template that describes the general nature of the set. Set Type Vs. A set that consist of only two record types is generally given a name that is a concatenation of the names of Owner and Member record types separated by hyphen.6. The names of all the sets for Training Dept database are shown in the diagram below. Like a record type. Bubble Diagram A one-to-many relationship in an IDMS/R network database is implemented by defining a set. This intersection is represented by another record type.

IDMS/R other hand. Faculty Raju 16 . Notice that the set occurrence begins with an owner record occurrence. A set occurrence consists of one occurrence of the owner record type and any number of member record occurrences. 2. the Faculty record for Raju is the owner record of an empty set. It is called a bubble diagram. that occurrence points to the next member record occurrence. In the following figure. A specific occurrence of the set Faculty-Course is shown in a diagram given below. A set occurrence can also consists only of an owner record occurrence and no member record occurrences. There exists one occurrence of the Faculty-Course set for each occurrence of the set’s owner record type. in which case the set occurrence is said to be empty. Above figure shows an example of a set occurrence. Faculty Sudhir Course C0702 Course C0804 Course C0703 Fig. Records in each occurrence of the set are physically linked together by pointers. The owner record occurrence points to the first occurrence of the member record type. consists of a specific single occurrence of the owner record type and all occurrences of the member record type that are associated with it. A set consists of an owner record type and one or more member record types. The last member record occurrence then points back to its owner.3. and so on until the last member record occurrence is encountered. Accessing members by following the pointers from one record occurrence to the next is called walking the set.

IDMS/R Fig. 2.4. 2. 17 . MVS JCL CO701 C1001 CO702 C1002 CO901 CO902 JCL MVS CO702 C1002 C1001 CO701 CO902 Shilpa CO901 Kishore Fig. Following is another example of bubble diagram.5.

C009 --.P7 --.P10 --.IDMS/R Classroom Exercise Draw a bubble diagram for following Sub : JCL .P3 --.C005 C003.P5 --.C009 Fig. NIL --.C009 Participants : Participant P1.C006.P9.C001 . P2.6.C006.C006 P8.IDMS Faculties : SHEKHAR SHILPA Course C001.P4. C003 --. 18 .C005 .JCL C005. IDMS Faculty Subject Courses : C001 .C003 P6. 2.

Schema. Subschema: . Users in a particular department work only on record types. Users in Payroll Dept do not work on data of Inventory dept functions. but they work on some portion of the schema. data elements and set types. there would be a different subschema for Inventory Dept. there should be a subschema defined such that includes all the elements defined in the schema. We can represent a schema visually by using a Bachman diagram. most application programs do not require access to all record types and all set types that are defined in a schema. One or more subschemas are defined such that each subschema specify the particular record types. data elements and set types that a particular application program is authorized to access. 19 . An application program always accesses the database by referring to a subschema. In a big manufacturing company. Payroll Dept.IDMS/R 2. So even if a program requires access to all the record types. Subschemas also provide the ability to restrict access to only those record types. Sales Dept.7. set types that are required for their application or function.g. data elements and set types defined in the schema. Users in any particular department do not need access to the entire schema. etc. Subschemas provide a means of simplifying the view of the database for each application program. Refer to Section 5. data elements.The definition of all record types and all set types that make up an IDMS/R network database is called a schema.8 for more details of Bachman diagram. E. that each group of application programs needs access to.In real-world systems. Subschema Schema: .

Instead. 3. Some DML statements are carried out during the program’s execution. OPEN statements prepare files for processing and establish linkages between the application program and the operating system data management routines. IDMS/R Batch Program 3. The DML processor validates the DML statements and creates a translated version of the source program 20 . The reason for this is that the application program does not interface directly with the operating system data management routines that handle data transfer operations. DML Statements: Executable and Compiler Directive An IDMS/R program uses DML statements for database access. The program then makes requests for file accesses by issuing READ. Compiler-directive statements control compilation of a program.3. These statements result in calls to the operating system data management routines that handle the requests. the program is first read by a DML processor. there are no file description statements or OPEN or CLOSE statements for the database.IDMS/R 3.1. Operating Environment A conventional application program generally begins by issuing one or more OPEN statements.2. the application program issues DML statements that direct IDMS/R to access the database. An IDMS/R application program has DML statements embedded in the source code to request database access and other support functions. Three Steps Compilation: DML Pre-processor. The IDMS/R DML provides a number of statements that enable the programmer to access an IDMS/R database and to perform a number of support functions. E. Compilation and Linking Following diagram illustrates the steps required to prepare an application program for execution.g. WRITE statements. Before the source program is compiled. a compiler-directive statement is used to identify the subschema that the program should use. 3. In an IDMS/R application program. Some DML statements are compiler-directive statements.

In addition. The linkage editor also includes a copy of a routine called the IDMS Interface Module in the finished load module. After the translated source program has been compiled. 21 . The source program that the DML processor generates differs from the input IDMS/R source file in the following way: • Database record descriptions have been copied into the program from the data dictionary. the resulting object module is processed by the linkage editor to create an executable load module. Source DML Data Dictionary Statements Processor Error COBOL Listing Source DML Processor Errors COBOL Compiler Error Object Listing Module Compilation Errors Linkage Editor Error Load Listing Module Linking Errors Fig. 3. • DML requests that involve the transfer of control to IDMS/R have generated appropriate CALL statements. • IDMS/R DML statements have been changed to comments. Output from the DML processor is a new source program. Requests that the program makes for IDMS/R services result in calls to the IDMS Interface module. the DML processor can optionally generate a source statement listing containing error diagnostics. which serves as the input to the compiler.IDMS/R in which DML statements have been replaced by appropriate calls to IDMS/R.1.

SOURCE-COMPUTER. record descriptions. 01 WS-DEPT-ID PIC 9(04) VALUE 0. 03 DBKEY PIC S9(8) COMP SYNC. 03 ERROR-RECORD PIC X(16) 22 . IBM-3090. ENVIRONMENT DIVISION. 3. 03 RRECORD-NAME REDEFINES RECORD-NAME. Compiled Listing of Sample IDMS/R Program IDENTIFICATION DIVISION. *PROTOCOL. 05 SSC-DNA PIC X(8). 88 DB-REC-NOT-FOUND VALUE '0326'. 05 SSC-DBN PIC X(8). 05 SSC-NODN PIC X(8). The DML processor automatically includes record description entries defined by the subschema the program is using. PROGRAM-ID. The programmer can use COPY or INCLUDE statements to merge in predefined program modules. 03 ERROR-SET PIC X(16) VALUE SPACES. DATA DIVISION. OBJECT-COMPUTER.IDMS/R The DML processor must have access to the data dictionary as it processes the source program. In addition. 88 ANY-STATUS VALUE ' ' THRU '9999'. * IDMS-RECORDS MANUAL. WORKING-STORAGE SECTION. 88 DB-END-OF-SET VALUE '0307'. 03 PROGRAM-NAME PIC X(8) VALUE SPACES. E. *IDMS-CONTROL SECTION. 03 ERROR-STATUS PIC X(4) VALUE '1400'. CONFIGURATION SECTION. 03 AREA-NAME PIC X(16) VALUE SPACES.4. * COPY IDMS SUBSCHEMA-CONTROL. 88 ANY-ERROR-STATUS VALUE '0001' THRU '9999'. IBM-3090. * DB EMPSS01 WITHIN EMPSCHM VERSION 100. 05 SSC-DNO PIC X(8). 03 AREA-RNAME REDEFINES AREA-NAME. IDMSTEST. 88 DB-STATUS-OK VALUE '0000'. 03 RECORD-NAME PIC X(16) VALUE SPACES. *SCHEMA SECTION. the DML processor automatically updates the data dictionary. 01 SUBSCHEMA-CTRL. MODE IS BATCH. the DML processor stores into the data dictionary information about the types of DML statements that the program executes against database records.g.

05 DBSTATUS-CODE PIC X(5). 03 EMP-COVERAGE PIC X(16) VALUE 'EMP-COVERAGE '. 01 SUBSCHEMA-SSNAME PIC X(8) VALUE 'EMPSS01 '. 03 SR415 PIC X(16) VALUE 'EMPLOYEE '. 01 SUBSCHEMA-RECNAMES. 03 SR425 PIC X(16) VALUE 'EXPERTISE '. 01 SUBSCHEMA-SETNAMES. 03 ERROR-AREA PIC X(16) VALUE SPACES. 03 SR440 PIC X(16) VALUE 'JOB '. 03 SR455 PIC X(16) VALUE 'SKILL '. 05 FILLER PIC X(96). 05 DB-SUB-ADDR PIC X(4).IDMS/R VALUE SPACES. 03 SR405 PIC X(16) VALUE 'DENTAL-CLAIM '. 03 DIRECT-DBKEY PIC S9(8) COMP SYNC. 23 . 03 SR435 PIC X(16) VALUE 'INSURANCE-PLAN '. 03 FILLER PIC X. 03 DEPT-EMPLOYEE PIC X(16) VALUE 'DEPT-EMPLOYEE '. 03 DATABASE-STATUS. 03 SR430 PIC X(16) VALUE 'HOSPITAL-CLAIM '. 03 SR400 PIC X(16) VALUE 'COVERAGE '. 03 SR450 PIC X(16) VALUE 'OFFICE '. 03 DIRECT-DBK REDEFINES DIRECT-DBKEY PIC S9(8) COMP SYNC. 03 SR420 PIC X(16) VALUE 'EMPOSITION '. 05 DBSTATMENT-CODE PIC X(2). 03 IDBMSCOM-AREA PIC X(100) VALUE LOW-VALUE. 03 RECORD-OCCUR PIC S9(8) COMP SYNC. 03 COVERAGE-CLAIMS PIC X(16) VALUE 'COVERAGE-CLAIMS '. 03 RIDBMSCOM REDEFINES IDBMSCOM-AREA. 03 DML-SEQUENCE PIC S9(8) COMP SYNC. 03 SR460 PIC X(16) VALUE 'STRUCTURE '. 03 IDBMSCOM REDEFINES IDBMSCOM-AREA PIC X OCCURS 100. 03 SR445 PIC X(16) VALUE 'NON-HOSP-CLAIM '. 03 SR410 PIC X(16) VALUE 'DEPARTMENT '.

03 EMP-NAME-NDX PIC X(16) VALUE 'EMP-NAME-NDX '. 01 SUBSCHEMA-AREANAMES. 03 EMP-EMPOSITION PIC X(16) VALUE 'EMP-EMPOSITION '. 02 DEPT-NAME-0410 PIC X(45). 1000-INIT. 01 DEPARTMENT. 0000-EXIT. 03 OFFICE-EMPLOYEE PIC X(16) VALUE 'OFFICE-EMPLOYEE '. CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (59) SUBSCHEMA-CTRL SUBSCHEMA-SSNAME. 03 INS-DEMO-REGION PIC X(16) VALUE 'INS-DEMO-REGION '. 02 FILLER PIC XXX. PERFORM 2000-PROCESS THRU 2000-EXIT. STOP RUN. 03 MANAGES PIC X(16) VALUE 'MANAGES '. * COPY IDMS RECORD DEPARTMENT. PERFORM 8000-WRAP-OFF THRU 8000-EXIT. 02 DEPT-ID-0410 PIC 9(4). * BIND DEPARTMENT. PERFORM 1000-INIT THRU 1000-EXIT. 03 EMP-DEMO-REGION PIC X(16) VALUE 'EMP-DEMO-REGION '. 03 SKILL-NAME-NDX PIC X(16) VALUE 'SKILL-NAME-NDX '. PERFORM IDMS-STATUS. 03 SKILL-EXPERTISE PIC X(16) VALUE 'SKILL-EXPERTISE '. 03 ORG-DEMO-REGION PIC X(16) VALUE 'ORG-DEMO-REGION '. 03 REPORTS-TO PIC X(16) VALUE 'REPORTS-TO '. 03 JOB-EMPOSITION PIC X(16) VALUE 'JOB-EMPOSITION '. CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (48) SR410 DEPARTMENT. 24 . 03 CALC PIC X(16) VALUE 'CALC '. PROCEDURE DIVISION. 02 DEPT-HEAD-ID-0410 PIC 9(4). EXIT. 03 JOB-TITLE-NDX PIC X(16) VALUE 'JOB-TITLE-NDX '.IDMS/R 03 EMP-EXPERTISE PIC X(16) VALUE 'EMP-EXPERTISE '. 0000-MAIN. * BIND RUN-UNIT.

' ERROR-STATUS. DISPLAY 'ERROR RECORD -----. 2000-EXIT. IDMS-ABORT SECTION.' RECORD-NAME. ********************************************************* IDMS-STATUS-PARAGRAPH. DISPLAY 'ERROR AREA -------. IF DB-STATUS-OK GO TO ISABEX. * FINISH.' DML-SEQUENCE. * READY ORG-DEMO-REGION.' ERROR-AREA. DISPLAY 'LAST GOOD RECORD -. ********************************************************* IDMS-STATUS SECTION. PERFORM IDMS-STATUS. IF DB-STATUS-OK DISPLAY 'DEPARTMENT : ' DEPT-NAME-0410 ELSE IF DB-REC-NOT-FOUND DISPLAY 'INVALID DEPARTMENT CODE' ELSE PERFORM IDMS-STATUS. 8000-EXIT.' PROGRAM-NAME '. 8000-WRAP-OFF.IDMS/R PERFORM IDMS-STATUS. CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (2). DISPLAY 'PROGRAM NAME -----. CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (37) ORG-DEMO-REGION. 2000-PROCESS. ' ERROR-RECORD ' **** RECOVER IDMS ****' UPON CONSOLE. EXIT. DISPLAY 'ERROR STATUS -----. * ROLLBACK. * COPY IDMS IDMS-STATUS.' AREA-NAME. * OBTAIN CALC DEPARTMENT. ACCEPT WS-DEPT-ID. DISPLAY 'DML SEQUENCE -----. CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (32) SR410 IDBMSCOM (43).' ERROR-SET. DISPLAY 'LAST GOOD AREA ---.' ERROR-RECORD. DISPLAY '**************************' ' ABORTING . PERFORM IDMS-ABORT. EXIT. DISPLAY 'PROGRAM ABORTED'.' PROGRAM-NAME. MOVE WS-DEPT-ID TO DEPT-ID-0410. ' ERROR-STATUS '. DISPLAY 'ERROR SET --------. CALL 'IDMS' USING SUBSCHEMA-CTRL 25 . EXIT. 1000-EXIT.

Note: . The name of Program-id is generally the same name as the name of the load module that is referenced in the EXEC statement of the run JCL. Data Division 26 . The IDMS-RECORDS MANUAL clause specify records whose data descriptions (or record layout) will be copied from the data dictionary into the working-storage section by using the statement ‘COPY IDMS RECORD <rec-name> in the Data Division. then DEBUG indicates that the DML processor will supply additional code in the resulting source program that will be helpful in program debugging using the debugger. MODE IS BATCH IDMS-RECORDS MANUAL. the Environment division contains a new section called the IDMS-CONTROL section: IDMS-CONTROL SECTION. Environment Division This division contains the INPUT-OUPUT section. In this example.1. Eg. BATCH indicates that the program will run in the batch rather than the online mode. ISABEX.If we mention ‘MODE IS BATCH DEBUG’. PROTOCOL. IDENTIFICATION DIVISION. The PROTOCOL statement is a compiler-directive statement that specifies the manner in which the DML processor will generate CALL statements. IDMSTEST.IDMS/R IDBMSCOM (67). EXIT. which contains references to the files used by the program. CALL 'ABORT'. In addition to the normal INPUT-OUPUT section. Explanation of sample IDMS/R program: Identification Division The Identification Division of the IDMS/R program is similar to that of a conventional COBOL program. PROGRAM-ID. 3.

The ‘READY ORG-DEMO-REGION’ statement indicates that the program will retrieve data only and will not be allowed to execute database modification DML statements for the specified area. DATA DIVISION. Schema Section specifies the names of the subschema and the schema used in the program.IDMS/R This division begins with a new section called ‘Schema Section’ in addition to File section and Working-Storage section. The data descriptions that define the IDMS Communications Block (i. The ‘BIND DEPARTMENT’ statement establishes addressability for the WORKING-STORAGE area that will be used to contain Department record occurrences. The main difference between the PROCEDURE division of an IDMS/R application program and that of a conventional COBOL program is the inclusion of DML statements that request IDMS/R services. The ‘BIND RUN-UNIT’ statement establishes addressability for the IDMS Communications Block and causes IDMS/R to load the subschema identified in the SCHEMA section. the Procedure division defines the processing that the program performs. BIND statements are required for database access. Procedure Division As in a conventional application program. READY ORG-DEMO-REGION. PERFORM IDMS-STATUS. The remaining DATA division sections are similar to those of a conventional COBOL program. 27 . SCHEMA SECTION. The READY statement performs an equivalent function as an OPEN statement for a conventional file. DB EMPSS01 WITHIN EMPSCHM VERSION 100.e. Status Checking: The statement immediately following the READY statement performs a paragraph named IDMS-STATUS. Subschema- Control) and the Department record have been inserted by the DML processor.

The program performs the IDMS-STATUS paragraph after each DML statement is executed to determine if the requested operation executed successfully. If the Department record is found. For the READY statement. 28 . The program then issues a DML statement to read the appropriate Department database record: OBTAIN CALC DEPARTMENT. Database access: .The program accepts the value of Dept-Id and moves that value to Dept-Id field of Department record layout in working storage. The FINISH statement releases the database areas from the program's control. a value of “0326” is returned. a status code that describes the results of the requested operation. the program ends by executing a STOP RUN statement. An end-of-set condition is indicated by “0307”. it returns an error-status code zero. The IDMS-STATUS paragraph performs error-status code checking and abnormally terminates the program if a nonzero error-status code is found. in the ERROR-STATUS field of the IDMS Communications Block. When a retrieval fails because a record is not found. 3.IDMS/R The IDMS-STATUS routine is brought into the program as a result of a COPY IDMS statement that is coded toward the end of the source listing: COPY IDMS IDMS-STATUS. and indicates a successful DML operation. If IDMS/R cannot locate a Department record having the requested dept-id. it returns a nonzero error-status code. Finally. Also the program may begin and end more than one run unit in the same program execution. If IDMS/R completes a requested DML operation successfully.5. IDMS/R returns. These represent the status code values most often returned by IDMS/R. Finish statement: . Run-Unit A run unit is the portion of the program’s processing during which it has access to one or more database areas and can request IDMS/R services. the program displays an error message. A status code value of "0000"is labeled DB-STATUS-OK. The data elements that define the layout of the Communications Block specify a number of status code values.The program ends the run unit by executing a FINISH statement. If IDMS/R detects an error condition. the program displays department-name. anything other than a zero status code is unacceptable. The program may perform some processing before it begins an IDMS/R run unit and it may perform processing after the run unit is completed.

IDMS/R A run unit is a unit of work within IDMS/R. an address space in an MVS system. IDMS/R stores into the IDMS communication block information about the results of each request for an IDMS/R service.6. IDMS/R is generally contained in its own area of virtual storage. before reissuing the BIND RUN-UNIT and READY statements. Virtual Storage Layout Following diagram shows the layout of virtual storage when an IDMS/R program executes. Note: . A run unit begins with the BIND RUN-UNIT statement and ends with the FINISH statement. Each run unit represents a concurrently executing task that is interacting with an IDMS/R database. In addition to other storage areas used by the program. 3. Subschema tables are loaded when an application program requests database access. The area of virtual storage occupied by the IDMS/R application program contains variable storage. Variable storage contains the data areas to be modified by the program during execution. Operating System Variable IDMS Communication Storage Block IDMS/R Executable Code Interface Module Subschema IDMS/R IDMS/R Application Program Tables Systems DBMS Buffers 29 Operating System . The IDMS/R area also contains the subschema tables for the IDMS/R application programs currently in execution.If your program consists of more than one run unit. The IDMS/R area of virtual storage contains the IDMS/R database management system and the system buffers.e. i. variable storage contains a control block called the IDMS communication block. A program can consist of any number of run units that are executed serially. The system buffers are the storage locations that IDMS/R uses in transferring database pages to and from direct access storage. the IDMS/R interface module and an executable code. but typically contains only one. you must reinitialize the ERROR STATUS field in the IDMS Communication Block to the value 1400. The BIND RUN-UNIT and FINISH statements are analogous to the processing time between OPEN and CLOSE file statements.

DML Execution Steps Following are the steps that are involved in the execution of a typical DML statement. Update currencies: . and area names. record type. 30 . set. E. which performs the requested service. and an image of the requested subschema record is built in variable storage.7. If the desired record is not already in a buffer. and access restrictions. the required record may already be in a system buffer due to a previous retrieval.The IDMS/R interface module transfers control to IDMS/R DBMS. ii. the DBMS reads the tables to determine record. as required. Call the IDMS/R Interface Module: .2. and area definitions. i. in this case for a retrieval. Transfer control to IDMS/R: .The DBMS updates run-unit. iii. the DBMS uses operating system data management facilities to read the required database page from direct access storage. set. It is not always necessary for the DBMS to read the database to satisfy a retrieval request.IDMS/R Address Space IDMS/R Address Space Fig. This information includes the type of database service desired and record. Retrieve database record and build subschema record: . Since access to the database is controlled by the subschema tables.g.The CALL statement generated by DML processor passes control to IDMS/R Interface Module and provides it with information that will be needed to perform the requested database access. currencies. set type and area currencies. (Virtual Storage Layout) 3.The required database record is retrieved. This is done by moving the database key and other control data from the system buffers to the subschema tables. if required. iv. 3.

IDMS/R v. 31 .The application program should contain code to check the results of each requested service. This information describes the results of the requested DML function. Test status information: . vii. vi. Return to the program: . The ERROR-STATUS field of IDMS Communication Block contains the status of DML statement just executed.After updating the Communication block. control is passed first from the DBMS to the IDMS/R Interface Module and then to the application program at the statement following the DML statement just executed. Store status information: .The DBMS moves status information to appropriate locations within the IDMS Communication Block.

Pages An area can be further subdivided into pages. we discuss how an IDMS/R network-structured database is physically implemented. Header of a page: 16 Bytes 32 . A page is the unit of data that is moved between the database and the system buffers that are used by IDMS/R to hold the retrieved records. Areas An IDMS/R database is divided into one or more areas.2. 4. 4. A database page contains record occurrences and control information. but all occurrences of a particular record type must be located in the same area. An area is defined as the major named subdivision of addressable storage in the database.IDMS/R 4. Header Record Occurrences Record Occurrences Free Space Line Index 3 Line Index 4 Line Index 5 Line Index 6 Line Index 2 Line Index 1 Footer Fig. Physical Database Structure Here. which constitute the smallest logical units of database storage.1. Areas contain occurrences of the records that make up networked-structured databases. 4.1. The diagram given below shows the structure of a page from a database area. Each area can contain occurrences of one or more record types.

The indexes move from the end of the page backward into the page body as more records are placed on the page. i. the displacement of the beginning of the record from the start of the page. broken into four 2-bytes fields: the record identifier. IDMS/R actually checks both values each time a page is read. This feature. The header of a page is 16 bytes long. reduces unusable space to a minimum. This is added protection against undetected database damage. The line index itself is 8 bytes in length. The data stored in the page body is always concentrated at the front of the page body. the prior pointer (4 bytes). consisting of the page number (4 bytes). SA (Space Available Count) is the number of bytes of free space on the page. the record length and the length of the record prefix (the pointers). The page footer consists of 16 bytes. The line index group contains one or more line index pointers. Note that the page number occurs as the first and last four bytes of each page. broken into a line index for the header (8 bytes). The IDMS/R database page is broken into four distinct sections. the line space count (2 bytes). the space available count (2 bytes) and a 2-byte unused space. Initial value of this field is (PAGESIZE – 32) bytes. that continuously optimizes the available space on the page. iv. ii. the page update count (2 bytes) and the page number (4 bytes). iii. an unequal value causes immediately alarm within DBMS. The page body that contains all of the object data records being stored on the page.IDMS/R Page Number Next pointer Prior Pointer SA Unused 4 Bytes 4 Bytes 4 Bytes 2 Bytes 2 Bytes Footer of a page: 16 Bytes Line Index 0 Line Space Count Page Update Count Page Number 8 Bytes 2 Bytes 2 Bytes 4 Bytes Line Index format: 8 Bytes Record-Id Displacement Record Length Prefix Length 2 Bytes 2 Bytes 2 Bytes 2 Bytes Each page can be considered as a mini-database since each normally stores several records and contains its own control information. one for each record stored on the page. 33 . the next pointer (4 bytes).

IDMS/R

Each page has a unique page number. Within a page, each record occurrence has
unique line number.

Pages in an area must be sequentially numbered. Gaps in the page numbers can occur
between areas. Areas cannot overlap i.e. a page number can belong to one area only.

Valid page numbers:
AREA 1 Pages 1 – 500
AREA 2 Pages 601 – 1000
Invalid page numbers:
AREA 1 Pages 1 – 500
AREA 2 Pages 401 – 700

4.3. DB-Key
Each record occurrence is assigned a unique numeric identifier, called its database
key (db-key). Format of db-key is shown below.

A record occurrence’s db-key consists of a 32-bit field that typically contains a 23-bit
page number and an 8-bit line number. The page number identifies the page in which
the record occurrence is stored and the line number identifies the location of the
record occurrence within that page.
IDMS/R uses database keys to keep track of where in the database record occurrences
are physically stored.

Sign Bit (Not used)

Database Page Number Line Number
0 1 23 24 31

4.4. Multiple Areas
A database could be divided into multiple areas for many reasons.

• Processing efficiency. Programs can open areas individually. If we group
record-types into areas appropriately, programs can open only the areas that
contain the record types they need. E.g. programs of Payroll function do not need
any record types pertaining to Inventory / Stock data of Parts. So, record-types
associated with Payroll data would be in one area. Record-types associated with
Inventory data can be in another area.

34

IDMS/R
• Security. If we need to restrict access to certain record types, we can place
them together in an area that is protected using IDMS/R security facilities. E.g.
access to Payroll-Area is restricted.

• Search efficiency. Efficiency of sequential scan through the database
improves if the record type is assigned to a separate area.

• Concurrent updating. A program can request exclusive use of an area and
prevent other programs from accessing it concurrently.

• Database recovery and backup. The database can be initialized,
restructured and backed up on an area-by-area basis. Areas assigned to highly
volatile record types can be given different treatment from areas that are assigned
to record types whose occurrences are changed little.

4.5. Files
Each page corresponds to a physical record that is stored in a file, and all data
transfers between the database and the system buffers are accomplished a page at a
time.

The ways in which areas can be mapped into files in direct access storage are as
follows:

• Many (or all) areas can be mapped into one file if all the areas have the same
page size.
• Each area can be mapped into a different file.
• One area can be mapped into many files.

4.6. Record occurrence – Prefix, Data
An IDMS/R database consists physically of a collection of record occurrences. The
record occurrence represents the smallest directly addressable unit of data. A record
occurrence consists of a fixed or variable number of characters that are subdivided
into units called data elements or fields. These data element values follow the formats
that were defined in the schema for this record type. Application programs work on
these fields. In an application program, we cannot address an individual data element
without first retrieving the record occurrence in which it is stored.

The physical records stored in the database consist of more than the data elements
used by the application program. IDMS/R also maintains information about the
relationships that exist between records. These relationships are physically
implemented by linking record occurrences together with pointers. Pointers contain

35

IDMS/R
the addresses of related record occurrences and are stored with the data elements that
make up each record occurrence.

Following diagram shows the format of a record occurrence, as it is physically stored
in the database. A record occurrence in the database is made up of two parts: a data
portion and a prefix portion. Data element values are stored in the data portion.
Pointers to related record occurrences are stored in the prefix portion. Application
programs generally work only with the data element values that are stored in the data
portion. IDMS/R DBMS automatically maintains the pointers in the prefix portion.

Prefix Data
Pointer 1 Pointer 2 Pointer 3 ………. Data Data Data ……..
Element 1 Element 2 Element 3

36

Record Here. The application program must reference the record’s name in requesting that some DML function be performed on one or more occurrences of a record type. A database administrator assigns record identifiers for each record type that the installation creates. Application programs are not aware that compression and decompression is taking place. 5. It should be a unique name. 5.1.g. 5. we discuss the characteristics that apply to record types. Record Identifier The record identifier is a number (in the range 100 through 9999) that serves as an internal identifier for the record type. E. Application programs do not refer to records using their record identifiers. Storage Mode The storage mode indicates whether occurrences of this record type are fixed or variable in length and whether they are stored in compressed format.3.2.to 16-character name that identifies the record type. Record Name Each record must be assigned a 1. Codes used to represent a record’s storage mode are as follows: • F (fixed length) • V (variable length) • C (compressed) The compressed storage mode can be used in conjunction with the fixed-length or variable-length storage mode. When data compression is used. a storage mode of FC indicates that record occurrences are fixed length and compressed. Each record type must be assigned a unique record identifier within the installation. The name must begin with an alphabetic character. an IDMS/R module automatically compresses and decompresses the data. 37 .IDMS/R 5.

g. Secondly. it allows us to retrieve records directly by supplying a CALC-key value. thus minimizing overflow conditions and leaving space for adding new records. It then stores the record occurrence on that page. and builds an image of the required subschema record in an application program storage area. 5. 38 . Department record type with CALC location mode and Dept-Id-0410 field as CALC-key. When the application program requests that record occurrences be stored into the database. When we add each new Department record occurrence to the database. The use of the CALC location mode results in record occurrences being distributed relatively evenly over the pages in the area. is the actual data length for a fixed-length record or the maximum data length for a variable-length record. the application program moves the Dept-Id-0410 value for the desired department into a designated application program storage area and executes a DML retrieval function.IDMS/R 5. expressed in bytes. and IDMS/R uses the randomizing routine to locate the proper page and directly retrieve the record occurrence that has the supplied CALC-key value. Location Mode The location mode defines the way a record is stored in its database area and tells the application programmer the way in which occurrences of this record type must be accessed. IDMS/R uses the CALC-key value to calculate the page into which the record should be placed. To retrieve the record for a particular department later. IDMS/R uses a randomizing routine to distribute records evenly over its area. the application program supplies IDMS/R with a CALC-key value. E. searches through the page for the desired Department record occurrence. a particular field (data element) within the record itself must be declared as the CALC-key. The three possible location modes are: • CALC • VIA • DIRECT CALC Location Mode With the CALC location mode. IDMS/R then uses the randomizing routine to locate the page on which the desired record is stored.4..5. IDMS/R uses the Dept-Id-0410 value contained in the record we are adding to calculate the specific page within the database to store the record. Record Length The record length. To retrieve a record later. A desired record is typically retrieved with a single access rather than requiring IDMS/R to search through the database for it.

Since IDMS/R transfers data into its buffers one page at a time. Following diagram shows records stored using the VIA location mode. The use of the VIA location mode tends to group together in close physical proximity records that are likely to be accessed together and minimizes the number of disk accesses needed to retrieve all the records that belong to a given set occurrence. or to different page ranges in the same area.IDMS/R VIA Location Mode With the VIA location mode. IDMS/R clusters together the VIA member records of each owner and stores each cluster at a point that is proportionally as far from the beginning of the area as the owner record is from the beginning of its area. 5. Following diagram shows records stored using the VIA location mode when owner and member record types are assigned to different areas. record occurrences are distributed within their associated page range in the same relative position as their owner occurrences is in its associated page range. each member record in a set is stored on or near the page that contains the member record’s owner. If the owner and member record types are assigned to different areas.1. Employee Expertise Expertise Employee Area 1 Area 2 Expertise Expertise Expertise Expertise Employee 39 Expertise Expertise Expertise Expertise . some or all of its member record occurrences will tend to be on the same page. Area 1 Employee Employee Expertise Employee Expertise Expertise Expertise Emp-Expertise Expertise Expertise Expertise Expertise Expertise Expertise Fig. in many cases. to retrieve an owner record and all of its members. in other words – When occurrences of a VIA member record type are stored in a different area from occurrences of the owner record type. only a single physical I/O operation is needed. Each new Expertise record occurrence is stored as close as possible to its owner Employee record occurrence. Or. When an occurrence of the Employee record is retrieved.

5. 5. no CALC-key can be defined for that record type.6. This means that CALC retrievals cannot be requested for record types that are assigned VIA location mode. where records having duplicate CALC-key values are to be placed in the area. after which all the owner’s member record occurrences can then be quickly located. Since it is often difficult for the program to determine the db-key value of the record it wants. and if duplicates are allowed. a record occurrence with a duplicate CALC-key value will be accepted. Duplicates Option The duplicates option is specified only for records that are stored using the CALC location mode. a record occurrence with a duplicate CALC-key value will not be accepted. This allows an owner record type to be retrieved directly.2. With this option. DIRECT Location Mode When storing records into the database using the DIRECT location mode. When a CALC 40 .IDMS/R Emp- Expertise Fig. IDMS/R will signal an error if the program attempts to store a record that has the same CALC-key value as an existing record in the database. This option specifies whether records having duplicate CALC-keys are allowed. When the VIA location mode is assigned to a record type. IDMS/R will store the record before any record in the database that has a matching CALC-key value. this location mode is less often used than CALC or VIA. the program must specify the db-key value of the desired record occurrence. the owner record type of a set type is assigned the CALC location mode. In many cases. Codes used to represent the duplicates options are as follows: • DN (Duplicates Not Allowed). and the member record type is assigned the VIA location mode. Then when retrieving a record occurrence. the application program explicitly specifies the page number into which the record occurrence should be stored. • DF (Duplicates First). With this option.

8.3. Following diagram shows how characteristics of a record are mentioned in the rectangle box. The information for Department record type is as follows. 5. IDMS/R will store the record after any record in the database that has a matching CALC-key value. 5. 5. When a CALC retrieval is made using that CALC-key value. It is called a Bachman diagram.IDMS/R retrieval is made using that CALC-key value. Bachman Diagram For Record Type Please refer to Employee Database mentioned in Appendix A. Area Name The area name is the name of the area into which all record occurrences of the record type are to be stored. the new record will be retrieved last. Record Name Record Id Storage Record Location Mode Length Mode CALC-key or Duplicates VIA Set Name Option Area Name Fig.7. • DL (Duplicates Last). a record occurrence with a duplicate CALC-key value will be accepted. the new record will be retrieved first. A rectangle box is used to describe characteristics of a record. With this option. DEPARTMENT 410 F 56 CALC DEPT-ID-0410 DN ORG-DEMO-REGION 41 .

For a record that is defined with the VIA location mode. 5.4. • F – The storage mode. • Org-Demo-Region – The name of the area in which the Department records are stored. this space is used to specify the name of the set that is used in locating and storing record occurrences. indicating fixed-length records. • DN – The duplicates option. • 56 – The record length. indicating duplicates not allowed. • Department – The record name. • 410 – The unique record identifier assigned to the record type. • CALC – The location mode. indicating records are stored in the database area using the CALC location mode. 42 . • Dept-Id-0410 – The data element (field) name designated as the CALC-key.IDMS/R Fig.

IDMS/R

6. Set
Set relationships are defined according to the following rules:

• Any record type can be a member of any number of sets.
• Any record type can be the owner of any number of sets.
• Any record type can be a member of one set and the owner of another.
• A record need not be part of any set.

Set characteristics:

Set characteristics are assigned to each set when defining the database to IDMS/R. These
characteristics are:

• Set name
• Linkage options
• Membership options
• Order options

6.1. Set Name
The unique name must be assigned to each set type in the database. The set’s name
must be referenced whenever an application program accesses records using that set
relationship. Generally, a set name is formed by concatenation of names of the owner
and the member record types separated by a hyphen. E.g. in the Employee database,
the set Dept-Employee implements the one-to-many relationship between the
Department record and the Employee record.

6.2. Linkage Options
The linkage option indicates the types of pointers that are used to implement the set.
Pointers control flexibility in accessing records within a set. Codes used to represent
the linkage options are as follows:

• N (NEXT pointers). With this linkage option, the pointers in the set identify
the NEXT record occurrence. Following figure shows the use of NEXT pointers
in implementing a set occurrence. This option allows access to member records
only in the forward direction. To access a particular member record occurrence,
we must typically begin with owner record and then walk through all the member
records until we access the one we want. When only NEXT pointers are used to

43

IDMS/R
implement a set, space is required in the prefix of each record for only one
pointer. NEXT pointers must be specified for all sets; all other types of pointers
are optional.

Prefix Data

N Dept. 1000 Rec. occurrence

N Emp-Id 0001 Sudhir

N Emp-Id 0002 Pai

N Emp-Id 0003 Anil

Fig. 6.1.

• NP (NEXT and PRIOR pointers). With this linkage option, a set of PRIOR
pointers are used in addition to the set of NEXT pointers, as shown in the figure
below. This linkage option allows us to access member records in both forward
and backward direction.

Prefix Data

N P Dept. 1000 Rec. occurrence

N P Emp-Id 0001 Sudhir

N P Emp-Id 0002 Pai

N P Emp-Id 0003 Anil

Fig. 6.2.

• NO (NEXT and OWNER pointers). With this linkage option, a set of
OWNER pointers are used in addition to the NEXT pointers. Member record
occurrences contain two pointers, Next and Owner, in the prefix part. Owner
record occurrences contain only Next pointer. Owner pointers provide direct
access from any member record occurrence to its owner record occurrence.
44

IDMS/R

• NPO (NEXT, PRIOR and OWNER pointers). With this linkage option, the
set includes all three pointer options as shown in the following figure. This
linkage option allows access to member records in a set occurrence in both the
next and prior directions and direct access from a member record to the owner
record.

Prefix Data

N P Dept. 1000 Rec. occurrence

N P O Emp-Id 0001 Sudhir

N P O Emp-Id 0002 Pai

N P O Emp-Id 0003 Anil

Fig. 6.3.

Ex.: Consider the following set.

Department

Dept-Employee
Employee
Emp-Expertise

Expertise

Fig. 6.4.

Pointers in Employee record occurrence:

45

5. The order options are as follows: • FIRST. 6. The logical order of member record occurrences is independent of the physical placement of the records themselves. 6. Each new member record occurrence is placed immediately after the owner record (in the next direction). While retrieving. this option achieves a member order of LIFO. this option achieves a 46 . Each new member record occurrence is placed immediately before the owner record (in the prior direction).IDMS/R N P O N P Emp-Id 0001 Sudhir Prior in Emp-Expertise set Next in Emp-Expertise set Owner in Dept-Employee set Prior in Dept-Employee set Next in Dept-Employee set Fig. Before Insertion D1 E1 E3 After Insertion E15 is inserted E2 D1 E1 E3 5 Fig.3.6. 6. Order Options The Order option specifies the logical order in which member record occurrences are placed within a set occurrence. E1 E2 • LAST. While retrieving.

6.IDMS/R member order of FIFO. 6.E2 D1 After Insertion: E15 is inserted E1 E3 E2 D1 E1 E3 Fig. E2 • NEXT. Before Insertion D1 After Insertion: E15 is inserted E1 E3 E2 D1 E1 E1 5 Fig.e. Each new member record E3 occurrence is placed immediately after the member record occurrence that was last accessed (in the next direction) within the set occurrence i.8. Before Insertion Current of set: . E2 E1 5 47 .7. PRIOR pointers are required (NP or NPO linkage option) to satisfy the LAST order option. next to the current of set.

Prior pointers are required in order to specify the PRIOR order option. or sort key. Before Insertion: current of set is E2 D1 After Insertion: E15 is inserted E1 E3 E2 D1 Fig. 6. and sort-key is EMP- LAST-NAME-0415.e. E1 E3 • SORTED. With this option.IDMS/R • PRIOR. the DBMS examines the sort key in each member record occurrence to determine the logical position of the new member record occurrence in the set occurrence. 5 based E2 on the value of a designated sort-control data element. D1 Consider Dept-Employee set. ASC. When a record is placed into a set. A sorted set order is defined by the keywords ASC (ascending) or DES (descending). Order option is sorted. Each new member record occurrence is placed immediately before the member record occurrence that was last accessed (in the prior direction) within the set occurrence i.9. followed by the data element name of the sort key. E1 a new member record occurrence is placed in ascending or descending sequence. contained in each record occurrence. prior to the current of set.Josh Verm i aE3 Patil D1 Jos Verm hi a Kam at Pati l 48 .

49 . After insertion.10. Fig. Codes used to represent the duplicates option for sorted sets are as follows: • DF (Duplicates First).A duplicates option indicates the action to be taken by the DBMS when a duplicate sort-key value occurs. After insertion: Fig. The last duplicate record encountered in the next direction is Patil(1) always the most recently stored duplicate record. With the DL duplicates option. a record with a duplicate sort-key value is stored immediately before the existing duplicate record in the set. a record with a duplicate sort-key value is stored immediately after the existing duplicate Patil(2) record in the set. Patil(2) inserted. D1 Jos Verm hi a • DL (Duplicates Last). The first duplicate record encountered in the next direction is always the most recently stored duplicate record. With the DF duplicates option. Duplicates Option: . 6.IDMS/R Before insertion: Insert “Kamat”. 6.11.

4. D1 Fig.The Order option for the set is ‘Sorted’ in ascending sequence.12 Jos Verm hi a • DN (Duplicates Not Allowed). With the DN duplicates option. The set has Next.13. IDMS/R returns an error code.: Try to insert Patil(2). Please check up Dept-Employee set. which represents the set. a record with a duplicate sort-key value cannot be stored in the set. 50 . the DBMS returns Patil(2) an error code. Prior.: After insertion. Ex. 6. Josh Verm i aE3 6. and Owner pointers. Sort-key is Emp-Last-Name-0415 Emp-First-Name- 0415. It is rejected. 6. When a program Patil(1) attempts to store a record with a duplicate sort-key value. D1 Fig. OA – Membership options. All the set characteristics for Dept-Employee set are shown along side the arrow. DL – The duplicates option of the sorted set. Patil(2) inserted. NPO – The linkage options. Bachman Diagram For Set Patil(1) Please refer to Employee Database Bachman diagram in Appendix A. The set characteristics shown are as follows: Dept-Employee – The set name. ASC (Emp-Last-Name-0415 Emp-First-Name-0415): .IDMS/R Ex.

given Dept-Id (CALC-key). Coding steps are as follows. CALC Retrieval: Random access The syntax is as follows. • By walking sets i. 7. Indexed Set. • Move / assign value to the CALC key-field • Issue “OBTAIN” DML statement 51 . Two of those methods are given below. It makes the data available to the program. The DML statement used for these retrievals is OBTAIN.2. In the above example. It is a random access. Basic Retrieval: CALC. Sweeping Areas 7.e. OBTAIN CALC DEPARTMENT. MOVE 2000 TO DEPT-ID-0410. we discuss how to code the specific DML statements that are used to retrieve information from an IDMS/R database. it retrieves a particular Department record occurrence. Through Relationship Here. By Sort-key. OBTAIN CALC DEPARTMENT. • By performing a CALC retrieval. The “OBTAIN” statement causes IDMS/R to locate the appropriate record occurrence in the database and moves data element values into application program’s variable storage i. MOVE WS-DEPT-ID TO DEPT-ID-0410.1. Retrieval: Basic. There are various ways to access the data.IDMS/R 7. working-storage section.e. Ex.: Retrieve a Department record occurrence. OBTAIN CALC <Record-Type-Name>. access through set relationship.

Error Handling The application program must check up status of any DML statement immediately after its execution. IF ERROR-STATUS = ‘0326’ DISPLAY …… 03 – Major code – For “OBTAIN” DML function 26 – Minor code – Function status: . ERROR-STATUS Condition Name Explanation Field Values “0000” DB-STATUS-OK Successful “0307” DB-END-OF-SET End of set. The last two bytes (minor code) describe the status of that function. retrieves the desired Department record occurrence and constructs a subschema record in the program’s variable storage i. Any non-zero value indicates failure. working-storage section.3. First two bytes (major code) identify the function performed.IDMS/R To perform a CALC retrieval. Any non-zero value Example given above is reproduced below. OBTAIN CALC DEPARTMENT. If Department record occurrence with Dept-Id 2000 does not exist. IDMS/R uses the CALC-key value we supply to locate the appropriate page in the database. IF DB-REC-NOT-FOUND DISPLAY ……. 7. We cannot perform a CALC retrieval for EXPERTISE records. we can use condition name as follows. There are some 88-level condition names associated with ERROR-STATUS field in IDMS Communication Block as given below. The ERROR-STATUS field consists of 4 bytes.e. MOVE 2000 TO DEPT-ID-0410. it can be checked with following IF conditions. and we must know the CALC-key value of the record occurrence we are retrieving. the record type we are retrieving must have a CALC- key defined for it.No record found Or. 52 . A value of “0000” indicates that the DML statement was successful.. ERROR-STATUS field of IDMS Communication Block contains status information of the DML statement just executed. area or index “0326” DB-REC-NOT-FOUND No record found for given key “0001” To “9999” ANY-ERROR-STATUS Any error.

Ex.IDMS/R Standard approach for error handling in the program: DML statement Expected Status IDMS-STATUS Take Appropriate Actions End Continue Processing Fig. Eg.e.1. 7. Access Through Set Relationship There are two types of retrievals through set relationship.1. OBTAIN CALC DEPARTMENT. IF DB-STATUS-OK DISPLAY DEPT-NAME-0410 ELSE IF DB-REC-NOT-FOUND DISPLAY ‘GIVEN DEPT-ID NOT FOUND’ ELSE PERFORM IDMS-STATUS. • Retrieving members from owner • Retrieving owner from members Retrieving members from owner: 53 .4. Access By Walking Sets i. 7.: Coding for error handling. 7. MOVE 2000 TO DEPT-ID-0410.

a CALC-type retrieval is often useful for this purpose. We choose the set occurrence that we wish to access by executing a retrieval statement (either an OBTAIN or a GET) for a particular occurrence of the set’s owner record type.: Next OBTAIN NEXT EMPLOYEE WITHIN DEPT-EMPLOYEE To retrieve each of an owner record’s members in sequence is very useful. Ex.IDMS/R In many application situations. The retrieval statement. OBTAIN First <Record-Name> within <Set-Name> Last Next Prior Nth Ex. then to retrieve member record occurrences from the set occurrence. it is necessary to retrieve a particular owner record occurrence and then to retrieve one or more of that owner’s member record occurrences. can be repeatedly executed to retrieve all of an owner record’s members until it reaches end-of-set. Ex.: First OBTAIN FIRST EMPLOYEE WITHIN DEPT-EMPLOYEE IDMS/R retrieves the first Employee record in the Dept-Employee set. following syntax is used. D1 E1 E3 Department D1 E2 54 . Once we have established the set’s owner record occurrence as current of its record type and also current of its set type. The original Department record remains current of its record type. This is called as walking the set or navigating the set.: Last OBTAIN LAST EMPLOYEE WITHIN DEPT-EMPLOYEE If a set is defined with prior pointers. given above. we can retrieve the last member record occurrence of a set as mentioned above. which then becomes current of the Dept-Employee set.

IDMS/R sets an end-of-set condition code that the program must test to avoid walking the set a second time. Eg. MOVE WS-DEPT-ID TO DEPT-ID-0410.If the <Record-Name> clause is omitted from the above mentioned OBTAIN syntax. Example: Display all employees’ names for a given department. The particular record occurrence that this statement retrieves depends on which record occurrence in the set is established as current of the Dept-Employee set. MOVE ‘N’ TO WS-END-SET. then in case of a multimember set.2. Including a qualifying a record name is useful when walking sets that have more than one member record type. it always retrieves the record that follows the record occurrence that is current of the Dept-Employee set in the next direction. 7.2. ……… ……… RETRIEVE-REC. OBTAIN CALC DEPARTMENT. member record occurrences of any record type will be retrieved. IF DB-STATUS-OK PERFORM RETRIEVE-REC UNTIL WS-END-SET = ‘Y’ ELSE IF DB-REC-NOT-FOUND DISPLAY ‘GIVEN DEPT-ID NOT FOUND’ ELSE PERFORM IDMS-STATUS. Note: . 55 . IF DB-STATUS-OK DISPLAY EMP-NAME-0415 ELSE IF DB-END-OF-SET MOVE ‘Y’ TO WS-END-SET ELSE PERFORM IDMS-STATUS.IDMS/R Employee E1 Employee E3 Employee E2 Fig. OBTAIN NEXT EMPLOYEE WITHIN DEPT-EMPLOYEE. 7.

we can walk the set in the prior direction by repeatedly executing a statement of the above-mentioned type. IDMS/R can get directly to the owner from any member in the set occurrence. OBTAIN OWNER will cause IDMS/R to retrieve the Department record occurrence for D1. OBTAIN CALC EMPLOYEE. IF DB-STATUS-OK 56 . if necessary. to locate the owner record. If owner pointers do not exist. IDMS/R walks the set.: Nth We can retrieve a particular member of a set by a number that specifies the relative sequence in the set of the desired member. Example: Display department name for a given employee-id. OBTAIN SEQ-FIELD EMPLOYEE WITHIN DEPT-EMPLOYEE Retrieving owner from members: We can use the following DML statement to retrieve the owner of a set occurrence: OBTAIN OWNER WITHIN <Set-Name> OBTAIN OWNER WITHIN DEPT-EMPLOYEE If currency is established anywhere in the set occurrence (as shown in above bubble diagram). Ex.IDMS/R Ex. OBTAIN 3 EMPLOYEE WITHIN DEPT-EMPLOYEE Or. OBTAIN PRIOR statements cannot be issued for a member record type if the member’s set does not include PRIOR pointers.: Prior OBTAIN PRIOR EMPLOYEE WITHIN DEPT-EMPLOYEE If a set has been defined as having PRIOR pointers. 01 SEQ-FIELD PIC S9(5) COMP. except in the reverse direction. MOVE WS-EMP-ID TO EMP-ID-0415. we can use a variable (of PIC S9(5) COMP) in place of sequence number. An OBTAIN OWNER retrieval can be issued whether or not the set is defined as having OWNER pointers. OBTAIN PRIOR works in the same manner as OBTAIN NEXT. If the set is defined as having OWNER pointers. MOVE SEQUENCE-NUMBER TO SEQ-FIELD.

3. The logic and programming would be on similar lines. 57 .Refer to Lab Book. who finished these assignments.IDMS/R OBTAIN OWNER WITHIN DEPT-EMPLOYEE IF DB-STATUS-OK DISPLAY DEPT-NAME-0410 ELSE IF DB-REC-NOT-FOUND DISPLAY ‘DEPARTMENT NOT FOUND’ ELSE PERFORM IDMS-STATUS ELSE IF DB-REC-NOT-FOUND DISPLAY ‘GIVEN EMPLOYEE NOT FOUND’ ELSE PERFORM IDMS-STATUS.Refer to Lab Book. Assignment 2: . Source code given. Assignment 1: . Eg. Similar to 1. can continue to Assignment 3. Those participants. 7.

g. we can retrieve a particular member of a set occurrence based on a sort-key value.IDMS/R 7. 58 . as in the example give below. IF DB-STATUS-OK DISPLAY EMP-ID-0415 EMP-NAME-0415 EMP-ADDRESS-0415 ELSE IF DB-REC-NOT-FOUND DISPLAY ‘GIVEN EMPLOYEE NOT FOUND’ ELSE PERFORM IDMS-STATUS.5. The general syntax is as follows: OBTAIN <record-name> WITHIN <set-name> USING <sort-key>. the search for a record is limited to the current set occurrence. regardless of which record occurrence is current of set type. we can base retrievals on sort-key values. OBTAIN EMPLOYEE WITHIN DEPT-EMPLOYEE USING EMP-LAST-NAME-0415.4. Eg. DB-REC-NOT-FOUND. 7. IDMS/R does not search other set occurrences for a member having the specified sort-key value. OBTAIN EMPLOYEE WITHIN DEPT-EMPLOYEE USING EMP-LAST-NAME-0415. Dept-Employee set is with order option of SORTED in ascending sequence and the sort-key is EMP-LAST-NAME-0415. In this example. The expected return-codes are DB-STATUS-OK. MOVE ‘PATIL’ TO EMP-LAST-NAME-0415. IDMS/R begins searching member records from the first member record occurrence in the set occurrence. we move a last name value to the data element in the Employee record description that defines the sort key and issues an OBTAIN statement that references the sort-key data element. With this sorted set. Note that although the retrieval appears similar to a CALC retrieval. MOVE ‘PATIL’ TO EMP-LAST-NAME-0415. We want to access Employee record occurrence “Patil” in the set occurrence of D1. In the previous example. E. Retrieval By Sort-Key Value If we are retrieving member records and the set type is with order option of SORTED. Please check up above diagram of the set occurrence for Department record occurrence D1.

E. Generic Key Retrieval To perform a generic-key retrieval in a sorted set. In an index set. Following is the partial code for this type of retrieval. MOVE WS-INPUT-CHAR TO WS-FIRST-CHAR. 05 WS-FIRST-CHAR PIC X. IF DB-STATUS-OK DISPLAY EMP-ID-0415 EMP-NAME-0415 Process all remaining Employee occurrences for which last name starts with ‘S’ ELSE IF DB-REC-NOT-FOUND Obtain next employee occurrence within the set If db-status-ok If last-name starts with ‘S” Display emp-id.g.IDMS/R 7.5.. 05 FILLER PIC X(14). Please notice that the data element in which we store the generic key must be padded to the right with low values. emp-name Process all remaining Employee occurrences for which last name starts with ‘S’ else display message ‘Not found’ else display message ‘Not found’ ELSE PERFORM IDMS-STATUS. MOVE LOW-VALUES TO WS-LAST-NAME.. 7. member records are chained together by pointers. we supply IDMS/R with a partial key value. In a conventional set. in Dept-Employee sorted set as mentioned above. database key values are stored in a specified order in one or more index 59 . ……. ……. Indexed Set A special type of set is provided by IDMS/R that allows retrieval of records using an index.6. OBTAIN EMPLOYEE WITHIN DEPT-EMPLOYEE USING EMP-LAST-NAME-0415. Eg. 01 WS-LAST-NAME. we want to retrieve all the Employee record occurrences whose last name value begin with the letter ‘S’. 7. MOVE WS-LAST-NAME TO EMP-LAST-NAME-0415.7.

retrieval of members can sometimes be more efficient because the index can be traversed more quickly than the set of chained member records. • Sorted retrieval by key value. Skill record has an index built on skill-name apart from CALC key. apart from CALC key. Retrieval Using Indexed Set By using index sets. Each entry in the index contains a symbolic-key (or index-key) data element value and the db-key value of its corresponding record occurrence. 60 .e. We can have more than one indexes built on different fields. To implement an index. Please refer to Sec. i. The use of indexes can simplify processing in the following situations: • Random retrieval by key value. Also a partial or generic key value can be used. With an index. E.g. IDMS/R builds an index file that contains the database key values of member record occurrences. Employee record has an index built on last-name and first-name fields. 8. • Multiple-key access. Random Retrieval To use the index to find the first record having a particular index-key (a field on which the index is built) value.1. Sometimes we need to access records based on more than one key. DBMS locates the data by searching the index rather than the actual member record. Indexed sets are used mainly to add flexibility to data retrieval. we can do a random retrieval in a similar manner to the method we used for retrieving a member record having a particular sort-key value. 7. IDMS/R records. so that we can retrieve record occurrences based on any index that we need. The syntax and the logic are similar to the sorted set. IDMS/R uses an array of database pointers to quickly access member records. we can perform three types of retrieval that are difficult or impossible without the use of an index: • Sequential retrieval in symbolic-key sequence • Generic-key retrieval • Random retrieval based on the value of a symbolic key other than a CALC- key.8. These db-key values are maintained in the sequence specified for the index.

Sequential Retrieval Consider the index set EMP-NAME-NDX built on last-name field of Employee record.IDMS/R We name the desired record type. it could issue a series of sequential retrievals to locate additional records having that same name: OBTAIN NEXT EMPLOYEE WITHIN EMP-NAME-NDX. DB-REC-NOT-FOUND. Once the program locates the first one through random retrieval. Expected return codes are DB-STATUS-OK. Expected return-codes are DB-STATUS-OK. Employee record and Job record.9. Assignment 3: . 61 .2. The program has to test the last-name field after each sequential retrieval to determine when it has reached the last record with the specified last-name data element value. The index set characteristics are shown along side the arrow representing the indexed set in the Bachman diagram.Refer to Lab Book. There are indexes built on Skill record. Please refer to Sec.Refer to Lab Book. specify the name of the index set and supply a data element value for the indexed data element: OBTAIN SKILL WITHIN SKILL-NAME-NDX USING SKILL-NAME-0455. Please refer to Employee database in Appendix A. Assignment 4: . DB-END-OF-SET. Generic-Key Retrieval The syntax and logic is exactly similar to Sorted set. 7. There may be many Employee records all having the same last-name value. Bachman Diagram: Indexed Set The set characteristics of an Indexed set are similar to the set with order option as Sorted. 8.

10. It uses area currency to retrieve the record occurrence having the next highest database-key value. We can use a sequence number or a variable (of PIC S9(5) COMP) in place of a sequence number as given below. IDMS/R scans through all the records in an area in physical sequence. record-name can be omitted. IDMS/R will simply retrieve the record occurrence of the given record-type having the lowest database-key value in the area. …. Pointers are not used in performing an area sweep. OBTAIN NEXT <record-name> WITHIN <area-name>. Expected return-codes are DB-STATUS-OK. OBTAIN PRIOR <record-name> WITHIN <area-name>. Example: Retrieve all Course record occurrences.IDMS/R 7. We can also used the following syntax: OBTAIN Nth <record-name> WITHIN <area-name>. 01 SEQ-FIELD PIC S9(5) COMP. The order in which records are retrieved will generally have little relationship to the logical sequence of records. E. Retrieval By Sweeping Areas In performing an area sweep. IDMS/R uses currency within the area to determine which record occurrence of the given record- type to retrieve.g. 62 . In the following statement. Area sweeps are useful when we want to retrieve all the records in an area without regard to the order in which we get them. when we are simply gathering statistics about the database. so prior pointers are not necessary for executing OBTAIN PRIOR WITHIN AREA statements. MOVE SEQUENCE-NUMBER TO SEQ-FIELD. Performing an area sweep in the forward direction: OBTAIN FIRST <record-name> WITHIN <area-name>. DB-END-OF-SET. In the above mentioned OBTAIN syntax. OBTAIN SEQ-FIELD EMPLOYEE WITHIN EMP-DEMO-REGION. …. Performing an area sweep in the reverse direction: OBTAIN LAST <record-name> WITHIN <area-name>.

IF DB-STATUS-OK DISPLAY COURSE-ID OBTAIN NEXT COURSE WITHIN COURSE-AREA ELSE IF DB-END-OF-SET MOVE ‘Y’ TO WS-END-OF-COURSE-AREA ELSE PERFORM IDMS-STATUS. PERFORM 2000-RETRIEVE-REC UNTIL WS-END-OF-COURSE-AREA = ‘Y’. …. 7.6. 63 . Eg. 2000-RETRIEVE-REC. ….IDMS/R OBTAIN FIRST COURSE WITHIN COURSE-AREA.

IDMS/R maintains pointers to a number of different record occurrences as each run unit executes. The db-key of the most recent record occurrence of each area accessed by the program. IDMS/R maintains a separate currency for each record type defined in the subschema. Currency Table Currency table is the table of four different types of currencies as explained above. Record Set Area Run Unit Currency Currencies Currencies Currencies • BIND RUN-UNIT statement sets all the currencies to NULL. • Area Currency (Current of area). The db-key of the most recent record occurrence of each record type accessed by the program. • Successful DML statement changes the currencies involved. IDMS/R 8. 8. The currency is the db-key of the most recently accessed record occurrence. The db-key of the most recent record occurrence of each set type accessed by the program. Currency To help keep track of where we are in the database. • Set Currency (Current of set type). IDMS/R maintains a currency table for each run unit. • Run Unit Currency (Current of run unit). IDMS/R maintains four types of currency (Currency Table) for each run unit: • Record Currency (Current of record type). The other currencies remain null until some future database access sets them. We use the term currency to refer to these pointers. 64 . IDMS/R maintains a Currency Table for each run unit.1. IDMS/R maintains a separate currency for each set type defined in the subschema. IDMS/R maintains a separate currency for each area to which the program has access. The db-key of the most recent record occurrence accessed by the program. To enable a program to position itself and move about in the database.

. IDMS/R DBMS accesses records in the database. MVS OBTAIN CALC SUBJECT 65 .IDMS/R • Using the currencies and the NPO pointers stored in record occurrences. 8. • FINISH statement nullifies all the currencies. . CURRENCIES Course SetSub-Course Course-Area Subject Trg-Area Run-Unit Bind Run-unit . - Move ‘MVS’ To Sub-Id MVS . .1. Subject Subject in Trg-Area Sub-Course Course Course in Course-Area MVS C0 C10 7 C09 Fig. MVS MVS . .

Obtain first subject within course-area. MVS OBTAIN CALC SUBJECT Obtain next course within MVS C07 C07 MVS C07 C07 Sub-course Obtain last course within MVS C10 C10 MVS C10 C10 DB-END- Sub-course OF-SET Obtain next course within MVS C10 MVS MVS C10 MVS Sub-course Obtain course within sub-course MVS MVS C10 MVS C10 MVS using ‘C08’ (NPO) DB-REC-NOT- FOUND 8. . . Currency Loss Following example uses retrieval by area sweeping.. If db-status-ok Perform disp-course-para Obtain next subject within course-area Else If db-end-of-set 66 . …. ….2. Next-subject-para. …. Perform next-subject-para until ws-course-area-end = ‘y’. - Move ‘MVS’ To Sub-Id MVS .IDMS/R CURRENCIES Course SetSub-Course Course-Area Subject Trg-Area Run-Unit Bind Run-unit . . Example: Display last Course of all Subjects. …. . MVS MVS .

1. Retrievals by sweeping areas work based on area currency. Due to loss of Course-area currency. C1 C1 1 4 Assumption: Both Record types. Course C1 C1 The program displays courses C142 and C32. 67 . the Subjects S2 and S4 could not be obtained by the area-sweeping logic. 8. the courses C22 and C43 did not get displayed. which it was supposed to do. Eg. So. Subject and Course. Page-1 Page-2 Page-3 Page-4 S1 C21 C31 C32 C11 C13 S4 C42 S2 C14 C22 S5 C12 S3 C41 C43 Sub-Course Subject S1 Fig. Obtain last course within sub-course.2. This happened because of currency loss. COURSE-AREA: Record occurrences are as follows. 8. But3it did not display courses C22 and C43. Disp-course-para. are in Course-Area.IDMS/R Move ‘y’ to ws-course-area-end Else Perform idms-status. If db-status-ok Display course-id Else If db-end-of-set Display ‘No Course’ Else Perform idms-status.

any retrieval of Subject or Course record occurrence changes the area Course-Area currency. Area currency becomes S3. Now. After the execution of the statement ‘Perform disp-course-para’. In the above program. we need to store the area currency. So. Storing and Retrieval By DB-Key Value We can save the db-key / currency value in a working-storage field for later use. Find out the part of code where currency loss takes place. We miss S2 here. area currency changes to C14. So before the execution of the statement ‘Perform disp-course-para’. Solution: The record occurrences of both records. 8. we need to store / maintain the area currency. Then the DML ‘Obtain last course within sub-course’ is executed and it retrieves C14. <record-name> ACCEPT <ws-db-key-v> FROM <set-name> CURRENCY <area-name> Or MOVE DBKEY TO ws-db-key-v. but it started from C14 onwards. This is currency loss. Area currency is S1. Same thing happened with S4 also.IDMS/R Course-Area Currency: S1 C14 S3 C32 S5 The DML ‘Obtain first subject within course-area’ retrieves S1. we need to reestablish the area currency from the stored value. The paragraph ‘Disp-course-para’ is the place where currency loss happens.3. The syntax is as follows. Subject and Course. 68 . Scan for next subject should have started from S1 onwards. Then DML ‘Obtain next subject within course-area’ is executed and it retrieves S3. are in the same area Course-Area.

4. use the following statement: <record-name> FIND / OBTAIN CURRENT WITHIN <set-name> WITHIN <area-name> After this statement. The record-name is optional. If db-status-ok Accept ws-db-key-v from course-area currency Perform disp-course-para Obtain subject db-key is ws-db-key-v Perform idms-status Obtain next subject within course-area Else …. Next-subject-para. 8. To reestablish the currency to stored value. Only affected code is given below. Reestablishing Run-Unit Currency: To reestablish the current record occurrence of record type. Find and Get An OBTAIN statement performs the same function as a FIND followed by a GET. 69 . use following statement. We can latter follow a successful FIND with a GET. Obtain Vs. set type. The find function causes IDMS/R to locate the appropriate record in the database and place it in the system buffers. 01 ws-db-key-v PIC S9(8) COMP SYNC. Eg.2. issue PERFORM IDMS-STATUS. Ex.: The above-mentioned program is modified to take care of area currency loss. or area as the current record occurrence of run unit. 8.IDMS/R The field ws-db-key-v should be defined in working-storage as follows. FIND / OBTAIN <record-name> DB-KEY IS ws-db-key-v. GET causes IDMS/R to move the appropriate data element values from the system buffers into our program’s variable storage – working-storage section..

g. we only wish to locate a record. we may need only to verify that a particular record occurrence exists. GET FACULTY. MOVE ‘SUDHIR’ TO FACULTY-ID.IDMS/R We may not follow a FIND with a GET. or we may need to establish a starting point for some subsequent retrieval sequence. GET DEPARTMENT. 70 . FIND CALC DEPARTMENT. FIND CALC FACULTY. MOVE 2000 TO DEPT-ID-0410. E. The syntax of FIND is similar to OBTAIN. but do not need actually to retrieve it. In some cases.

perform the following steps: i. 71 . Issue the IF EMPTY statement.5. IF <set-name> EMPTY / MEMBER: By using IF statement. OBTAIN NEXT EMPLOYEE WITHIN DEPT-EMPLOYEE.3. To determine if a record participates as a member in a set. iii. ……. 8. perform the following steps: i. Using the IF EMPTY statement: IF <Set-Name> IS [NOT] EMPTY Imperative statement After you have retrieved a owner record occurrence in a set. you can issue the IF EMPTY statement to determine if the set has any member record occurrences. Establish run unit currency for the specified member record. This allows you to control processing based on whether the set is empty. ii. you can determine • If the set is empty • If the record occurrence is member of the specified set occurrence. IDMS/R 8. IF DEPT-EMPLOYEE IS EMPTY MOVE NO-EMP-MSG TO WS-MSG ELSE PERFORM 1000-DEPT-EMP THRU 1000-EXIT UNTIL DB-END-OF-SET. Using the IF MEMBER statement: IF [NOT] <Set-Name> MEMBER Imperative statement You can issue the IF member statement to ensure that a record occurrence currently participates as a member of a specified set occurrence. Eg. Establish currency for the set. ……… ……… 1000-DEPT-EMP. Perform further processing as specified. To determine if a set is empty.

If we do not use IF MEMBER: 72 . 1000-EXIT. 8. D1 Fig. 8. IF DB-STATUS-OK NEXT SENTENCE ELSE IF DB-END-OF-SET GO TO 1000-EXIT ELSE PERFORM IDMS-STATUS. EXIT. as specified. Perform further processing. ……….4. Eg.3. Issue the IF MEMBER statement. ………. OBTAIN NEXT EMPLOYEE WITHIN DEPT-EMPLOYEE. iii. 1000-DEPT-EMP.IDMS/R ii. IF OFFICE-EMPLOYEE MEMBER OBTAIN OWNER WITHIN OFFICE-EMPLOYEE PERFORM IDMS-STATUS DISPLAY OFFICE-ADDRESS-0450 ELSE MOVE NO-OFF-MSG TO WS-MSG. Employee E5 is not attached to any Department. E5 E1 E2 are attached Employees E1 and E2to Dept D1. Please consider the following data.

- Move E1 To Emp-Id-0415 . but the program concludes that it is attached to Dept D1. - Move E1 To Emp-Id-0415 . . This is solved by using IF MEMBER statement as follows. 73 .IDMS/R CURRENCIES SetDept-Employee Run-Unit Department Employee Bind Run-unit . . .Employee D1 E5 E2 E5 Else Display ‘No Owner’ The program will display error message ‘No Owner’. Employee E5 is not attached to any Department. CURRENCIES Run-Unit Department Employee SetDept-Employee Bind Run-unit . E1 E1 E1 Obtain calc Employee Obtain owner within Dept-Employee D1 E1 D1 D1 Move E2 To Emp-Id-0415 D1 E2 E2 E2 Obtain calc Employee Move E5 To Emp-Id-0415 D1 E5 E2 E5 Obtain calc Employee Obtain owner within Dept-Employee D1 E5 D1 D1 This is a wrong result. E1 E1 E1 Obtain calc Employee Obtain owner within Dept-Employee D1 E1 D1 D1 Move E2 To Emp-Id-0415 D1 E2 E2 E2 Obtain calc Employee Move E5 To Emp-Id-0415 D1 E5 E2 E5 Obtain calc Employee IF Dept-Employee MEMBER Obtain owner within Dept. .

Multiple Member Sets: There are more than one member record types in a set type.2. A one-to-many relationship exists between the owner record type and its member record types. Hierarchies Two-Level Hierarchies: A single set implements a two-level hierarchy. Types of Set Relationships 9. This results in a multilevel hierarchy. Coverage 74 Hospital. and member record types are on the second level. Multilevel Hierarchies: A member record of one set can also be the owner of another set. Department Dept-Employee Employee Emp-Expertise Expertise Fig. 9. Department Dept-Employee Employee Fig. 9.IDMS/R 9. While walking a set. Dental- Claim Claim Claim . we can access all member record types.1. The owner record type is on the first level. Non-Hosp.1.

9. Multiple Set Ownership: This form of hierarchy uses one record type as the owner record in more than one set. member record occurrences of any record type will be retrieved.IDMS/R Coverage-Claims Fig.5. Customer Cust-Invice Cust-Overdue-Invoice Invoice Fig. The common owner record provides the means of movement between the two different member record types in different sets.3. Note: . This is implemented by defining two different one-to-many relationships between the Customer record type and the Invoice record type.4. 75 . Employee Emp-Emposition Emp-Expertise Emposition Expertise Fig. in the diagram below about Customer and Invoice record types.If the <Record-Name> clause is omitted from the OBTAIN syntax. Multiple Sets: It is quite possible for two record types to participate in multiple one-to-many relationships with one another. it is useful to separate overdue invoices from other invoices. 9. with each being implemented by a different set type. 9. then in case of a multimember set. For example.

there are two different groups of Invoice record occurrences associated with it. Supplier and Parts have a one-to-many relationship with Quantity.6 I5 9. For each many-to- many relationship that we identify among a set of entities in real world applications. a given Invoice record occurrence will be a member of only one of the two possible set types. 9. Junction Record: I4 Multiple Set Membership IDMS/R does not support many-to-many relationship directly. E. The record type Quantity is called the junction record. Cust-Invoice Cust-Overdue-Invoice C1 I3 I2 I1 Fig. 9. there is a many-to-many relationship between Supplier and Parts record types. An additional record type Quantity is provided. because it represents a junction or intersection between the Supplier and the Parts record types.g. in which information about quantity supplied can be stored.7 S1 P1 76 .IDMS/R The same two record types. Supplier Parts Supplier-Qty Parts-Qty Quantity Fig. but are associated with the intersection between the two entity types. now participate in two different sets. A supplier supplies many parts and a part is supplied by many suppliers.2. The junction record resolves the many-to-many relationship and implements it indirectly. However. Customer and Invoice. we will almost always identify additional attributes that are not associated with either of the two entities alone. The junction record Quantity is the member record in the multiple sets Supplier-Qty and Parts-Qty. For each Customer record occurrence.

a record type cannot be both an owner and a member of the same set. In some applications. 9. consider a typical bill-of-material case of main-parts and sub-parts. A possible intersection data is the quantities required of the Parts. 9. Different quantities of a sub- part are used in construction of many different main-parts. But. there exists a many-to-many relationship among Parts record occurrences.9. 9. The technique of junction record can be used to resolve this situation.IDMS/R S2 P2 Q: S1P1 P3 Q: S1P2 Q: S1P3 Q: S2P1 Q: S2P2 Q: S2P3 Supplier-Qty Parts-Qty Fig. So.3. Parts-Are Parts Parts-For Fig. For example. Parts 77 Quantity . The owner record and the member record both are the same record type. there exists a many-to-many relationship among different occurrences of the same record type. Nested Structure – Bill Of Material Nested structures arise when modeling bill-of-materials structures in the manufacturing environment. It can be shown as follows. In a set relationship in IDMS/R. a main-part and a sub-part are basically Parts.8. Occurrences of a record type are related to other occurrences of the same record type. A main-part consists of many sub-parts and a sub-part belongs to (or takes part in construction of) many main-parts. We can create a junction record called Quantity. A main-part consists of many different sub-parts in certain quantity.

g. MVS is pre-requisite. DBMS. knowledge of Cobol. knowledge of Cobol. 9. E. DB2. Subject 78 . Consider another example of bill-of-materials structure. The set Parts-Are allows us to find out sub-parts of a given part. So. say Cobol.11. The owner record and the member record both are the same record type. The Quantity junction record is related to the Parts record using two sets. Given a particular subject. JCL. and Parts-For helps to find the main-parts where the given part is used as a sub-part. it is a pre-requisite for IDMS. to learn IDMS. there exists a many-to-many relationship among Subject record occurrences.IDMS/R Parts-Are Parts-For Fig. the knowledge of some other subjects is a pre-requisite. To learn a particular subject. It can be shown as follows. 9.10. To learn DB2. JCL. JCL. P1 P2 P11 P21 P81 P82 Q: P1P81 Q: P1P82 Q: P1P11 Q: P2P81 Q: P2P82 Q:P2P21 Parts-Are Parts-For Fig. MVS is a pre-requisite.

To learn DB2.: List out all sub-parts of part-number P1. we need to store the set currency for the set occurrence we want to walk along and reestablish it later.IDMS/R Prereq-Are Prereq-For Fig. JCL with skill-level of 2.Draw the diagram of Subject. Cobol is a pre-requisite for IDMS (Cobol level 3). So. changes the set currencies of both the sets. The member record type is also the same for both the sets. Subject Prereq-Are Prereq-For Skill-Level Fig. JCL (Cobol level 1). MOVE P1 TO PART-NUMBER.12. 79 . OBTAIN CALC PARTS. prerequisite are knowledge of Cobol with skill-level of 2. This is a problem of set currency loss. Quantity shown above). The set Prereq-Are allows us to find out the subjects that are prerequisites of a given subject. MVS with skill-level of 1. retrieval of any of the two record types. Exercise: . We resolve this by creating a junction record Skill-Level. MVS with skill-level of 1.13. The owner record type is same for both the sets. Ex. DB2 (Cobol level 2). Coding for retrieval logic: Please consider record types Parts and Quantity with two sets Parts-Are and Part-For as explained above. DBMS with skill-level of 3. If we want to walk along (navigate) a particular set occurrence sequentially. Skill-Level record occurrences with Prereq- Are and Prereq-For set occurrences (similar to Parts. Parts or Quantity. and the set Prereq-For helps to find the subjects for which the given subject is a prerequisite. then any retrieval through another set during the processing will change the set currency of the set occurrence we are walking along. So. The Skill-Level junction record is related to the Subject record using two sets. 9. 9. To learn IDMS. JCL with skill-level of 2. prerequisite are knowledge of Cobol with skill-level of 3.

those are stand-alone parts. and P13. if we do not write the statements ACCEPT WS-DB-KEY …. IF PARTS-FOR MEMBER OBTAIN OWNER WITHIN PARTS-FOR IF DB-STATUS-OK DISPLAY PART-NUMBER ‘ ‘ PART-NAME ELSE IF DB-REC-NOT-FOUND DISPLAY ‘OWNER NOT FOUND’ ELSE PERFORM IDMS-STATUS ELSE DISPLAY ‘OWNER NOT AVAILABLE’. and P13 do not have any sub-parts i. and OBTAIN QUANTITY DB-KEY …. EXIT.IDMS/R IF DB-STATUS-OK PERFORM 1000-WALK THRU 1000-EXIT ELSE IF DB-REC-NOT-FOUND DISPLAY ‘PART NOT FOUND’ ELSE PERFORM IDMS-STATUS. …. EXIT. OBTAIN NEXT QUANTITY WITHIN PARTS-ARE. …. P12. 1000-EXIT.e. 3000-EXIT. 2000-EXIT. IF DB-STATUS-OK PERFORM 3000-DISPLAY THRU 3000-EXIT FIND CURRENT QUANTITY PERFORM IDMS-STATUS ELSE IF DB-END-OF-SET MOVE ‘Y’ TO WS-END-SET ELSE PERFORM IDMS-STATUS. P12. 3000-DISPLAY.? Consider the following data: Part P1 has three sub-parts as P11.. 80 . EXIT. Parts P11.e.. IF PARTS-ARE IS EMPTY DISPLAY ‘NO SUB-PARTS’ GO TO 1000-EXIT. 1000-WALK. 2000-PROCESS. Eg.1. What will happen if we do not store the Parts-Are set currency i. PERFORM 2000-PROCESS THRU 2000-EXIT UNTIL WS-END-SET = ‘Y’. 9.

Parts-Are (and Parts-For) set currency is P11. - Move P1 To Part-number P1 . say Q11.IDMS/R CURRENCIES Parts-For Set Parts Parts-Are Set ….-Area Run-Unit Quantity Bind Run-unit . the program does not display parts P12 and P13. since P11 Parts-Are set occurrence is empty as per given data. Then DML ‘OBTAIN OWNER WITHIN PARTS-FOR’ is executed and retrieves P11. Then DML ‘OBTAIN NEXT QUANTITY WITHIN PARTS-ARE’ is executed and it encounters DB-END-OF-SET. Then DML ‘OBTAIN NEXT QUANTITY WITHIN PARTS-ARE’ retrieves Quantity occurrence. Parts-Are set currency is Q11. . . So. Parts-Are set currency is P1. . P1 P1 P1 P1 Obtain calc Parts Obtain next Quantity within Parts- P1 Q11 Q11 Q11 Q11 Q11 Are Obtain owner within Part-For P11 Q11 P11 P11 P11 P11 Obtain next Quantity within Parts- P11 Q11 P11 P11 P11 P11 Are DB-END- OF-SET First the program retrieves part P1. Then program ends. To avoid such set currency loss and thereby wrong results. 81 . we have to store the set currency and reestablish it later as shown in the program. .

. P1 P1 P1 P1 Obtain calc Parts Obtain next Quantity within Parts- P1 Q11 Q11 Q11 Q11 Q11 Are Obtain owner within Part-For P11 Q11 P11 P11 P11 P11 Find current Quantity P11 Q11 Q11 Q11 Q11 Q11 Obtain next Quantity within Parts- P11 Q12 Q12 Q12 Q12 Q12 Are Obtain owner within Part-For P12 Q12 P12 P12 P12 P12 Find current Quantity P12 Q12 Q12 Q12 Q12 Q12 Obtain next Quantity within Parts- P12 Q13 Q13 Q13 Q13 Q13 Are Obtain owner within Part-For P13 Q13 P13 P13 P13 P13 Find current Quantity P13 Q13 Q13 Q13 Q13 Q13 Obtain next Quantity within Parts- P1 Q13 P1 P1 P1 P1 Are DB-END- OF-SET 82 .IDMS/R CURRENCIES Parts-For Set Parts Parts-Are Set …. . - Move P1 To Part-number P1 .-Area Run-Unit Quantity Bind Run-unit . . .

Please refer to Lab Book. 9.14.IDMS/R Exercise: P1 P2 P8 P5 (q3) P11 (q6) P4(q2) P7(q11) P5(q7) P2(q9) P4(q2) P7(q1) P7(q11) MAIN -PART SUB-PART QUANTITY P1 P5 3 P1 P11 6 P1 P4 2 P2 P7 11 P8 P5 7 P8 P2 9 P11 P4 2 P11 P7 1 Fig. 83 . Write DML statement: - • List all sub-parts for P8 • List all parts which consists of P5 • List all sub-parts and main parts for P2. P11 • List all parts that are not main parts • List all parts that are only main parts • List all parts that are main part as well as sub-part Assignment 5: .

we must erase the Empo3 record from the database. Disconnect option The disconnect option specifies whether a member record can later be disconnected from a set once its membership has been established. A record occurrence cannot be disconnected from a set unless that record is erased from the database. a record occurrence can be disconnected from a set. as shown in the figure below. To disconnect Empo3 from the Emp-Emposition set.1. E1 Empo Empo Erase Empo3: 1 3 Empo 2 E1 Fig.Empo • O (optional). which indicates the way a record is disconnected from a set. 10. Please check up the set Emp-Emposition with this option in Appendix A. The first part is a disconnect option. which indicates the way a record is connected to a set. 10. as shown in figure below.IDMS/R 10.1 With this option.1. the membership of a record occurrence in a set is permanent once it is established. Codes used to represent the disconnect options are as follows: • M (mandatory). It is defined in two parts. Set Membership Options The membership option indicates the way a member record occurrence is connected to and disconnected from a set occurrence is connected to and disconnected from a set occurrence. With this option. The Emporecord occurrence remains in the database and may 2 84 . The second part is a connect option. Erasing Empo3 record also causes the record to be disconnected from the set.

To transfer employee E3 from D1 department to D2 department. For example. 10. a new member record is not automatically connected to a set occurrence when it is added to the database. as when we are transferring a employee from one department to another. the program needs to indicate in which set the new member is to belong at the time that it adds a new record occurrence. 10. Connect option The second part of the membership option indicates the type of connect option defined for this set.IDMS/R be accessible in other way. With this option. It can then be2 later connected to some other set. we might then connect it to some other Department set occurrence. in Dept-Employee set. • M (manual). 85 . The application program must execute an explicit connect function after it adds a new record occurrence to connect the member record to a set occurrence.E E 3 1 With the optional disconnect option.2.2. With this option. E a record occurrence can be disconnected from a set without erasing it. D1 Disconnect E E3: E 1 3 E 2 D1 Fig. With the automatic connect option. a new member record is automatically connected to a set occurrence when it is added to the database. we disconnect E3 from the set occurrence whose owner record is D1 and connect it to the set occurrence whose owner record is D2. Codes used to represent the connect options are as follows: • A (automatic). A connect option specifies whether or not a member record is automatically connected to a set occurrence when it is added to the database. after disconnecting one Employee record occurrence from one Department set occurrence.

it must remain late-paid. MM: Mandatory / Manual Customer Cust-Late-Paid Invoice Fig. The set characteristics are shown by the side of the arrow representing the set.Invoice when created may not be late-paid. The set membership options are mentioned along with all the other set characteristics.IDMS/R 10. Mandatory: . Manual: .Invoice occurrence cannot exist without Customer occurrence.g. OA: Optional / Automatic Customer 86 Invoice . Examples: MA: Mandatory / Automatic Customer Cust-Inv Invoice Fig.Once the invoice is late-paid. Automatic: .Customer must be known when invoice is created.3. Bachman Diagram and Examples Please refer to Bachman diagram of Employee database in Appendix A. The set Emp- Expertise has membership options as ‘MA’. E. The first character represents the disconnect option and the second character represents the connect option.3. Mandatory: . the set Dept-Employee set has membership options as ‘OA’. 10. 10.4.

10. it is not unpaid. Optional: .Once the invoice is paid.6.5. Optional: . Events Set Relation Today’s date: 05-April-2002 Invoice created Does not participate in the set occurrence Due date: 15-April-2002 On 16-April-2002 Not paid Now participating in the set occurrence On 18-April-2002 Paid Now does not participate in the set Occurrence 87 . it does not participate in this set occurrence. OM: Optional / Manual Customer Cust-Unpaid-And-Overdue-Inv Invoice Fig. Automatic: .IDMS/R Cust-Unpaid-Inv Fig.Once the invoice is paid. 10.All invoices are unpaid when created. Manual: .Invoice is not overdue when it is created.

Ready The Ready statement performs an equivalent function as an OPEN statement for a conventional file. Store The STORE statement is used to add a new record occurrence to the database. The syntax is as follows: SHARED READY <area-name> USAGE-MODE IS PROTECTED RETRIEVAL ALL EXCLUSIVE UPDATE This statement begins a run-unit. 88 . The ‘Usage-Mode Is Retrieval’ clause indicates that the program will retrieve data only and will not be allowed to execute any database modification DML statement for the specified area. A READY statement for update can also specify additional usage mode options that control the way in which database areas can be concurrently accessed by two or more run units. 2.IDMS/R 11. Establish currency within appropriate occurrences of the set types in which the new record participates as an automatic member. 11.2. Construct the new record occurrence in the record's area in working-storage section. We can use FIND for this purpose.1. Adding a new record to the database is a simple three-step process: 1. The ‘Usage-Mode Is Update’ clause informs IDMS/R that the program intends to update records from the specified area. It makes the required area of the database available to the program. Usage mode options for updating are discussed in the Section 13. since we do not need the records to be moved to the program’s working-storage section.2 on ‘Area Usage Modes’. DML Data Update Functions 11.

Before issuing a STORE. 89 . It is an automatic member of the Emp-Expertise set and a manual member of the Skill-Expertise set.IDMS/R 3. the program must have previously stored an appropriate database-key value in the IDMS Communications Block. If the location mode is DIRECT. IDMS/R uses record currencies and the attributes assigned to records and sets to obtain this information. if so. • Where in the set occurrences the new record should be inserted. we can establish currency within the Emp-Expertise set by accessing the appropriate Employee record. specifying the name of the record type we are adding. the only required parameter is the name of the record type. The syntax for the store function is simple. IDMS/R uses this value in finding a place for the record. IDMS/R finds an optimum location for the new record based on the location of the owner record occurrence in the VIA set type. IDMS/R converts the CALC-key value to a database-key value and then stores the new record as close as possible to the calculated page. As shown in Employee Database. • Whether the new record should be made a member of any sets and. Determining Where to Write the New Record: IDMS/R finds an appropriate location for a new record by examining the location mode defined for the record type being added. If the location mode is VIA. Connecting the Record to Sets IDMS/R next determines the set occurrences in which the new record should be a member and where in each set to insert the record. to which set occurrences it should be connected. including the following: • The location in the database in which the new record occurrence should be written. The following STORE statement adds a new occur- rence of the Employee record type: STORE EMPLOYEE. If the location mode is CALC. the Expertise record participates in two set types. IDMS/R must know more than the information we supply in the STORE statement to add the new record occurrence correctly. the program must establish currency within all the sets in which the new record is an automatic member. Before storing an Expertise record. The syntax is as follows: STORE <rec-name> However. Execute the store function.

The new Expertise record will not be auto- matically connected to an occurrence of the Skill-Expertise set. the STORE statement performs the following functions: • Acquires space and a database key for a new record occurrence.IDMS/R IDMS/R connects the new record to an occurrence of each set for which it is an automatic member. • Transfers data element values from working-storage to the database. 11. FIND CALC EMPLOYEE. it does not automatically connect it to any sets in which it is a manual member. each new Expertise record occurrence is placed in the set in descending sorted order of sort-key Skill-Level- 0425. MOVE WS-EMP-ID TO EMP-ID-0415. To summarize. Since the Emp-Expertise set is ordered DEC SORTED. the program can locate the appropriate set occurrences and issue CONNECT statements for the record once the record has been stored. IF DB-STATUS-OK MOVE WS-SKILL-LEVEL TO SKILL-LEVEL-0425 MOVE WS-EXP-DATE TO EXPERTISE-DATE-0425 STORE EXPERTISE PERFORM IDMS-STATUS ELSE IF DB-REC-NOT-FOUND DISPLAY ‘EMPLOYEE NOT FOUND’ ELSE PERFORM IDMS-STATUS. For sets in which the record is a manual member. …. We will have to 90 . • Connects the new record occurrence to all sets in which it participates as an automatic member. Example: Add a new occurrence in Expertise record. We will discuss the CONNECT statement later.. IDMS/R examines the order option for the set. Eg. The new Expertise record will be automatically connected to the current oc- currence of the Emp-Expertise set. Before connecting records to sets. Expertise record is an automatic member in Emp-Expertise and a manual member in Skill-Expertise.1.

We must execute a READY statement with one of the UPDATE usage mode options for the area that contains the record we are modifying. This establishes run-unit currency on the record we are going to change and also places a copy of the record in variable storage. record-type and all sets in which its Connect option is Automatic and sets in which it is an owner is affected. 2. 2. Make changes to the record by storing new data element values in working- storage. Execute an OBTAIN for the desired record. we can use the MODIFY statement to replace the data element values in a record occurrence with new data element values. We must issue an OBTAIN for the record we are updating before we execute the MODIFY statement. Modify Once we have readied one or more areas with one of the UPDATE usage mode options. area. 3.Run unit. naming the record type that we are modifying. There are two requirements for successful execution of the MODIFY statement: 1. OBTAIN CALC EMPLOYEE. Execute the MODIFY function. 11. Remark: . IDMS/R then replaces the data element values in the database with the new data element values in working-storage. IF DB-STATUS-OK MOVE WS-ADDRESS TO EMP-ADDRESS-0415 MOVE WS-PHONE TO EMP-PHONE-0415 MODIFY EMPLOYEE PERFORM IDMS-STATUS ELSE 91 . MOVE WS-EMP-ID TO EMP-ID-0415. In modifying a record occurrence we generally perform the following steps: 1. The syntax is as follows: MODIFY <rec-name> Example: Modify address and phone-number for a given employee.IDMS/R later use a CONNECT statement to connect the Expertise record to an appropriate occurrence of the Skill-Expertise set.3.

If we try to erase an owner record of a nonempty set. members of sets owned by that record. The options with Erase statement are as follows: PERMANENT ERASE <rec-name> SELECTIVE MEMBERS ALL The ERASE statement with no member option is straightforward.After successful execution. object record becomes current of the run unit. the ERASE often affects not only the record that is the object of the ERASE statement but also. Remark: . naming the record type. Example: Delete Employee record occurrence for a given employee-id. Erase This is used to delete a record occurrence from database. We then issue an ERASE.4. IDMS/R returns an error status code value.2. Eg. then removes the record occurrence from the database. MOVE WS-EMP-ID TO EMP-ID-0415. however. all sets in which it participates. IDMS/R first disconnects the record from any sets in which it participates as a member. The Modify and Store functions are fairly straight-forward. 11. in some cases. 11. the record will be erased only if those sets are empty. OBTAIN CALC EMPLOYEE.IDMS/R IF DB-REC-NOT-FOUND DISPLAY ‘EMPLOYEE NOT FOUND’ ELSE PERFORM IDMS-STATUS. they each operate on a single record occurrence. making it current of run unit. If the record we are erasing is the owner of any sets. its record type and area currencies are affected. When we use the erase function. IF DB-STATUS-OK ERASE EMPLOYEE PERFORM IDMS-STATUS ELSE IF DB-REC-NOT-FOUND DISPLAY ‘EMPLOYEE NOT FOUND’ 92 . We begin by retrieving the record we want to erase.

the members that are automatically erased depend on whether the members participate in other sets and what the set dis- connect options are. Remark: . Its mandatory members will be erased. Notice that. If an erased member is the owner of any sets. and its optional members will be erased if they do not participate in any other sets. We must use one of the other three ERASE options if we want to erase an owner of one or more nonempty sets. and its optional members disconnected. will be removed. it is treated as if an ERASE SELECTIVE were issued for it.IDMS/R ELSE PERFORM IDMS-STATUS. Then all its members. When we use ERASE PERMANENT.Run unit and area currencies remain unchanged. Its mandatory members will be erased. 11. Eg. The ERASE PERMANENT Option With the other two ERASE options. IDMS/R also removes all its member records. and it always erases mandatory members in all sets owned by the object record. It also erases all mandatory members all sets owned by the object record. It also erases optional members if they do not participate in any other sets. IDMS/R erases the record that is the object of the ERASE. It nullifies current pointers for: . If the erased member is the owner of any sets. both mandatory and optional. whether or not they are members in other set occurrences.3. The ERASE ALL Option Using ERASE ALL first causes the object record to be removed from the data- base. This means that the Employee record occurrence will only be erased if it is the owner of an empty set occurrence. The ERASE SELECTIVE Option An ERASE SELECTIVE always erases the record that is the object of the ERASE. we did not specify a member option in the ERASE. in this case. along with all their members.All sets in which the erased record participates 93 . It does not erase optional members. it is treated as if an ERASE PERMANENT were issued for it.All record types involved in Erase . it disconnects them instead. If we execute an ERASE ALL for an Employee record. This process continues until all members have been processed.

CONNECT connects the record that is current of run unit to the named set. 94 . OBTAIN CALC EMPLOYEE. ….On successful Connect. the set currency will become current of record occurrence just connected. CONNECT <record-name> TO <set-name>.. 11. Disconnect It is used to disconnect a record occurrence from a set occurrence of which it is a member. The CONNECT statement names both a record type and a set type. Connect It is used to establish a record occurrence as a member in a set occurrence. The CONNECT function can be used in conjunction with STORE for records that must be manually connected to sets. 11.6. IF DB-STATUS-OK MOVE WS-SELN-DATE TO SELECTION-DATE-0400 MOVE WS-TERM-DATE TO TERMINATION-DATE-0400 MOVE WS-TYPE TO TYPE-0400 MOVE WS-PLAN-CODE TO INS-PLAN-CODE-0400 STORE COVERAGE PERFORM IDMS-STATUS CONNECT COVERAGE TO EMP-COVERAGE PERFORM IDMS-STATUS ELSE IF DB-REC-NOT-FOUND DISPLAY ‘EMP-ID NOT FOUND’ ELSE PERFORM IDMS-STATUS. All areas affected must be readied in UPDATE usage mode. Remark: .4. MOVE WS-EMP-ID TO EMP-ID-0415. Membership option must not be MA (mandatory automatic). The CONNECT function causes the record that is current of the named record type to be connected to the set occurrence that is current of the named set type.5.IDMS/R 11. Example: Assumption: The Coverage record is a manual member of the Emp-Coverage set. Eg.

…. OBTAIN CALC EMPLOYEE. Eg.. 2000-TRANSFER. IF DB-STATUS-OK PERFORM 3000-CONNECT. CONNECT EMPLOYEE TO DEPT-EMPLOYEE. All areas affected must be readied in UPDATE usage mode. OBTAIN CALC DEPARTMENT. PERFORM IDMS-STATUS. …. DISCONNECT EMPLOYEE FROM DEPT-EMPLOYEE. The DISCONNECT statement cancels the membership of a record occurrence in a set occurrence in which it currently participates as a member. IDMS/R returns an error status code. …. Example: Transfer a given employee to another given department.IDMS/R DISCONNECT <rec-name> FROM <set-name>.. The DISCONNECT and CONNECT functions are also often used together to move a record occurrence from one set occurrence to another. The record that is the object of a DISCONNECT function must be defined as an optional member of that set. IF DB-STATUS-OK PERFORM 2000-TRANSFER ELSE IF DB-REC-NOT-FOUND DISPLAY ‘EMP-ID NOT FOUND’ ELSE PERFORM IDMS-STATUS. DML Statement Execution Steps: Please refer to Section 3. The DISCONNECT statement removes the record occurrence that is current of run unit from the named set. 11. Otherwise. PERFORM IDMS-STATUS.5. 95 . MOVE WS-EMP-ID TO EMP-ID-0415. MOVE WS-DEPT-ID TO DEPT-ID-0410.7 for the steps that are involved in the execution of a DML statement. …… …… 3000-CONNECT.

Assignment 7: . Assignment 8: .Please refer to Lab Book.Please refer to Lab Book. 96 .Please refer to Lab Book.IDMS/R Assignment 6: .

However. All online applications that use IDMS/DC or some other telecommunications monitor to control access to remote terminals must run under central version. no two central versions are allowed to update the same database area. the preferred method of running an IDMS/R application is under the control of IDMS/R central version. 12. an application runs faster when run in local mode. but IDMS/R provides no automatic restart and recovery facilities for local mode 97 . Local Mode A batch program that operates in local mode has its own copy of the IDMS/R DBMS loaded into its address space. Recovery and Restart IDMS/R provides the facilities for recovering from problem situations and for restarting after failures occur. With central version. The mode in which a particular application program is run is generally chosen by the DBA group and is not of concern to the application developer. a single DMCL module (which maps logical database areas into physical files in DASD) defines all database areas that will be accessed by all the run units that will execute under a particular IDMS/R central version. Central version implements facilities for recovering from system failures and for automatically restarting aborted run units. Multiple copies of IDMS/R central version can execute in the same computing system with each copy normally accessing a different set of database areas. a single copy of the IDMS/R DBMS controls the operation of a particular set of IDMS/R application program run units. Central Version In most situations.IDMS/R 12.1. An application program that operates in batch mode can be run either under the control of central version or in local mode. A local mode run unit operates independently of any other IDMS/R run units that may be operating in the system at the same time. With central version. IDMS/R Operating Environments It is possible to run an IDMS/R application program in two operating environments: local mode or central version. the mode in which the application executes determines the restart and recovery facilities that are available to it. These facilities include procedures that IDMS/R automatically invokes when certain types of failures occur and also services that application programs use to handle restart and recovery. All the run units that will execute under the control of a particular central version are chosen so that they all access the same group of database areas. In general.

since they do not ordinarily require automatic restart and recovery facilities. the journal file contains begin checkpoint. 12. At the conclusion of the run unit. As a run unit executes. Applications that bypass the journaling facilities are responsible for their own restart processing. and then only when the run unit writes the journal files to direct access data sets. When the application ends the run unit by executing a FINISH statement. Journal File Begin Checkpoint Before After … … End Checkpoint image image (FINISH) Start of run unit of updated record ……… 12.2. Journal Files. and an end checkpoint. IDMS/R may also encounter situations that require it to terminate abnormally one or more run units. Applications. For example. A program may cause an error that causes the run unit to be abnormally terminated. Recovery / Restart There are many types of situations that may require recovery and restart processing. If a run unit is abnormally terminated after it has updated one or more database records. Checkpoints IDMS/R maintains a set of journal files that can be used to recover from failures and to restart aborted run units.IDMS/R applications. IDMS/R provides automatic restart and recovery facilities only for run units that operate under the control of central version. A checkpoint record contains information about the current status of the run unit. IDMS/R works backward in the journal file until it reaches the begin checkpoint record and uses the information in the before record images to 98 . to tape tiles. before and after images of all updated records. or to ignore completely the journaling facility. IDMS/R writes a begin checkpoint record on a journal file. it may update records in the database. either central version or local mode. IDMS/R writes out an end checkpoint record. Batch retrieval programs are good candidates for running in local mode. it writes to the journal file a before image and an after image of the updated record. As IDMS/R processes each update request.3. IDMS/R may terminate a run unit after a wait time limit has been exceeded to prevent deadlocks from occurring. An IDMS/R application can choose to write the journal files to direct access data sets. that write tape journal files can use the journal files to restart manually an aborted run unit. When a run unit begins by issuing the BIND RUN-UNIT statement.

1. 99 . no more than a few database updates are processed during the execution of each run unit. In the simplest case. it is often necessary to divide a run unit into multiple recovery units to reduce the time that it takes to recover from a run unit failure.4. 12. A separate run unit may be started to process each incoming transaction. 12. Commit All run units that terminate normally create at least two checkpoint records on the journal file. In such a case. a single online run unit may process many transactions and perform many database updates. The processing that a unit performs between checkpoints is called a recovery unit.IDMS/R reverse the effect of the database updates already made by aborted run unit. Batch applications are even more likely to make a great many updates during the execution of a single run unit. 15 Journal File 17 Begin Before After Checkpoint: Checkpoint: image image Abnormal Start of RU 15 17 termination 17 Journal File 15 Begin Before After Checkpoint: Checkpoint: image image Abnormal Start of RU 15 17 termination Fig. The run unit can then be restarted from the beginning. In some situations. Many online applications operate in this manner. Another form of the COMMIT statement is: COMMIT ALL. The before and after record images that are recorded between these two checkpoints constitute a record of all the updating the run unit performed. and each run unit constitutes a single recovery unit. In such situations. a begin checkpoint when the READY statement is executed and an end checkpoint when the FINISH statement is executed. the run unit periodically issues a COMMIT statement to make permanent all database updates that the run unit has already made: COMMIT. To create intermediate checkpoints. the entire run unit constitutes a single recovery unit.

the run unit might issue a COMMIT statement. No special application programming is necessary to invoke the automatic recovery and restart facilities in the central version environment with journal files written to direct access data sets.IDMS/R The COMMIT statement causes IDMS/R to release all locks except for those that are placed on current records. COMMIT ALL releases all record locks. 12. IDMS/R stops at the commit checkpoint rather than proceeding all the way back to the begin checkpoint that was written when the run unit began. One simple technique is simply to count the number of updates the run unit processes. 100 . 12. it can be restarted from the point at which it wrote the most recent commit checkpoint. IDMS/R again works backward in the journal file and uses the information in the before record images to reverse the effect of changes that the run unit made. Recovering From Failures If the run unit is operating under the control of central version and is writing the journal files to direct access data sets. Every one hundred updates or so. Journal File 15 17 Begin Before After Checkpoint: Checkpoint: Checkpoint: image image Commit Abnormal Start of RU 15 17 termination Journal File 17 Begin Before After Checkpoint: Checkpoint: Checkpoint: image image Commit Abnormal Start of RU 15 17 termination Fig. causing IDMS/R to write an inter- mediate checkpoint to the journal file. Now.2. Many different techniques can be used for determining how often a COMMIT statement should be executed. IDMS/R handles all the processing that is necessary to roll back database changes and to restart run units that it aborts.5. however. This time. If the run unit is later abnormally terminated after it has issued a COMMIT statement. Both forms of the COMMIT statement cause IDVIS/R to write a commit checkpoint on the journal file. when the run unit is restarted.

the program can request that IDMS/R do this automatically by simply abnormally terminating the run unit. This form of the ROLLBACK statement causes IDMS/R to write a checkpoint record to the journal file. and terminate the run unit. to access the database again. nullify all currencies.IDMS/R In the local mode environment and in the central version environment with tapes journal files. To restart the run unit. ROLLBACK. automatically restore the database using the before images from the journal. The application issues a COMMIT statement to write a commit checkpoint every few hundred updates. We may now access the database immediately without reissuing the BIND/READY sequence. we can issue a ROLLBACK statement. IDMSIR restores the database but does not terminate the run unit. It may also need to reestablish the appropriate positions within the database to resume processing at the appropriate point in the database. Suppose the application now fails. There are two formats of ROLLBACK statement as given below. Suppose a batch application is reading transactions from a sequential transaction file and processing database updates based on the data read from the transaction file. IDMS/R provides utility programs to handle manual restarting of aborted applications. In the central version environment with journal files written to direct access data sets. After issuing this form of ROLLBACK. the run unit must contain application logic that will reposition the transaction file at the appropriate point so the run unit will reapply the changes that were backed out. a program may itself determine during program processing that it needs to back out the changes that it has made to the database since it wrote the most recent checkpoint record. Rollback In some cases. A utility program can be run that backs out the changes that the program made up to the previous commit checkpoint that the aborted run unit wrote to the journal file. we must reissue the BIND/READY sequence. 101 . If we would like to back out the changes but not abend the run unit. ROLLBACK CONTINUE. 12. If we issue this statement.6.

No other local mode application or CV will be given access to locked areas. and no other local mode application or IDMS/R central version will be given access to those areas. and record locks. In the central version environment. IDMS/R provides area usage mode options to control the concurrent access of database areas by different run units. then CV locks those and are available to all run units of that CV. Locking IDMSIR provides locking facilities for controlling access to areas and to individual records when two or more run units require access to the same database areas. 13.e. If an area lock is already set on an area that is required by an IDMS/R central version. at central version level and local mode application level. An area lock is released by FINISH statement of the local mode application. 102 . If all required areas are available. If an area lock is already set on an area that is required by a local mode application. Area usage modes.1 for READY statement.IDMS/R 13. the execution of that central version continues with no access to those areas for the run units of the CV. otherwise the local mode application locks those areas. that local mode application abends. i. The area is said to be varied offline to that central version. Please refer to Section 12.1.2. IDMS/R provides three levels of locks: Area locks. This lock works at operating environment level. Run units that attempt to access an area that is varied offline are abnormally terminated. An area that is locked by a particular CV is released only when the central version is shut down or when the area is varied offline. Area Usage Modes All the run units that operate under the control of a particular IDMS/R central version can access the same set of database areas. 13. Area Locks IDMS/R uses area locks to prevent areas from being updated by more than one IDMS/R central version or by more than one application running in local mode. The area usage mode option is specified with READY statement.

and we are specifying that no other run unit be allowed to retrieve or update records in the area while our run unit executes. we are requesting retrieval access.IDMS/R SHARED READY <area-name> USAGE-MODE IS PROTECTED RETRIEVAL ALL EXCLUSIVE UPDATE There are six usage modes as follows. and we are specifying that no other run unit should either retrieve or update 103 . we are requesting retrieval access to the area. With the RETRIEVAL or SHARED RETRIEVAL usage modes. we are requesting update access to the area. • Usage mode is UPDATE. also called shared update mode. • Usage mode is EXCLUSIVE UPDATE. However. With the EXCLUSIVE UPDATE usage mode option. we are requesting update access to the area. or if other run units are accessing the area with the PROTECTED RETRIEVAL or EXCLUSIVE RETRIEVAL usage mode. and we are specifying that other run units also be allowed to retrieve or update records in the area as long as they do not specify the PROTECTED or EXCLUSIVE options in their READY statements. other run units of our CV can retrieve the records in the area as long as they did not specify a usage mode of EXCLUSIVE for the same area. we are requesting update access to the area. If another run unit is already updating the records in the area. With the PROTECTED RETRIEVAL usage mode. If another run unit is already updating the records in the area. and we are specifying that no other run unit should be able to update records while our run unit executes. and we are specifying that other run units of our CV will also be allowed to retrieve or update records in the same area. • Usage mode is PROTECTED UPDATE. our run unit will wait until all other run units finish with the area. This usage mode is not often used. With the PROTECTED UPDATE usage mode option. • Usage mode is EXCLUSIVE RETRIEVAL. we are requesting retrieval access to the area. • Usage mode is RETRIEVAL. our run unit will wait until all other run units finish with the area. and we are specifying that no other run unit should update the records in the same area for the duration of our run unit. With the UPDATE usage mode option. Other run units may also be allowed to retrieve records in the same area or areas as long as they do not specify the PROTECTED or EXCLU- SIVE usage mode options. • Usage mode is PROTECTED RETRIEVAL. If other run units are already accessing the area. our run unit will wait until that run unit finishes. With the EXCLUSIVE RE- TRIEVAL usage mode.

Implicit record locks are only maintained for run units operating under central version. Record locks are never maintained for run units operating in local mode. An implicit exclusive record lock is used to guarantee that no other run unit can either update or retrieve the record while the exclusive lock is in effect. Implicit shared locks remain in effect until currency changes. Implicit lock example: Two users are trying to update the same Employee record occurrence. This essentially gives the run unit exclusive use of the area. concurrent updates are prevented by setting locks on entire areas. Implicit locks are placed on records as they are made current of run unit. Record Locks – Implicit. and area. and an implicit exclusive lock is placed on a record when it is accessed via update DML functions.IDMS/R records in the area while our run unit executes. any number of run units will be allowed to retrieve a record protected by a shared record lock. set type.3. An implicit shared lock is placed on a record when it is retrieved. Run Unit 1 Run Unit 2 104 . When we use usage mode options that allow more than one run unit to access the same area while updating is taking place. Explicit Preventing other run units from accessing the same areas can cause system wide performance problems. In this way. but that any number of run units will be allowed to retrieve a given record. IDMS/R guarantees that only one run unit at a time will be allowed to access a record that is being updated. record type. implicit exclusive locks remain in effect until the run unit ends or until the run unit executes a COMMIT statement. 13. Implicit record locks: There are two types of implicit record locks: implicitshared record locks and implicit exclusive record locks. An implicit shared record lock is used to guarantee that only one run unit at a time will be allowed to update a specific record occurrence. In local mode. IDMS/R sets implicit record locks to prevent the same record from being concurrently updated by two or more run units. Central version always maintains record locks for run units executing in shared update mode.

IDMS/R places an implicit shared lock on the E1 record. Run unit 1 retrieves the Employee record for E1. Since a shared lock does not prevent other run units from accessing a record. Retrieve Wait E1 E1 E1 E1 105 . Run unit 1 waits. IDMS/R places another shared record lock on the E1 record on behalf of run unit 2. run unit 1 is not allowed to update the record. Run unit 1 issues a MODIFY function to change address for E1. IDMS/R gives the record to run unit 2. Retrieve E1 E1 E1 E1 Implicit shared lock 2. Since run unit 1 has also locked the record. run unit 2 also waits. Run unit 2 issues a MODIFY function to change address for E1. Modify E1 E1 E1 3. Wait Modify E1 E1 E1 E1 4.IDMS/R Retrieve E1 E1 E1 Implicit shared lock 1. Since run unit 2 has placed a shared lock on the record. Run unit 2 retrieves the Employee record for E1.

Exclusive lock: OBTAIN KEEP EXCLUSIVE CALC EMPLOYEE. . the MODIFY issued by run unit 1 is allowed to complete. Explicit locks provide a better way of handling the same situation. The lock set by run unit 2 is now removed. In a high volume application such as an airline reservation system. Eg. a deadlock has occurred. . In either case. Since each run unit is now waiting for a record that the other run unit locked. 106 . We can issue a separate KEEP statement to set an explicit lock on a record after retrieving it. Sensing a deadlock. Explicit record locks: To set an explicit record lock. 13. the lock remains set until we either end the run unit by executing the FINISH statement or we execute a COMMIT statement.. Shared lock: OBTAIN KEEP CALC EMPLOYEE.. Deadlock Detected Abend 6.IDMS/R 5. abnormally terminating a run unit would be an inefficient method of handling a common res- ervation system problem: contention for the same seat. Retrieve E1 E1 E1 E1 Modified Implicit Exclusive Lock 7.1. and IDMS/R sets an implicit exclusive lock on the record until run unit 1 ends. Following are two examples of CALC retrievals during which locks are set on the retrieved Employee record. code the KEEP clause in the DML statement that is used to retrieve the record. IDMS/R automatically abends run unit 2 to recover.

Run unit 1 issues a MODIFY to update address information for the E1 record. Modify E1 E1 E1 Wait 5.Run unit 1 retrieves the Employee record.Run unit 1 places an explicit exclusive lock on the Employee record just retrieved.Since run unit 1 has already placed an exclusive lock on the E1 record. Attempt to retrieve E1 E1 3.Run unit 2 attempts to retrieve the record.IDMS/R Explicit lock example: Run Unit 1 Run Unit 2 Retrieve E1 E1 E1 1. Issue KEEP EXCLUSIVE CURRENT statement E1 E1 Explicit Exclusive Lock 2. Wait E1 4. run unit 2 waits. 107 .

the user 2 will see the record with the latest address information. 108 .Run unit 2 is now allowed to retrieve the E1 record. Eg. and IDMS/R releases the lock on the E1 record. Now that the address has been updated.2. 13.IDMS/R End Run Unit E1 Wait Lock Released 6. Record Retrieved E1 E1 7.Run unit 1 issues a FINISH.

This will display department occurrence for the give id. Otherwise. it will display error message as ‘db-rec-not-found’ and the value of Error-Status field as well. Steps to invoke DMLO for Employee Database (Training Dept): • On CCS screen. DMLO DMLO stands for DML-Online. schema-name. Enter the value for Dept-Id-0410. type ccscv24t <Enter>. Utilities 14. In DMLO.IDMS/R 14. 109 .: Display department <Enter> This will display record layout of Department. E. type following: signon IBM-id password dcuf set dictname patni dcuf set dbname patni dmlo • On the first screen of DMLO: select mode as R (for retrieval mode) type subschema-name. ver • On the next screen of DMLO at the bottom: Type various retrieval DMLs. if exists. you can access one DB-record at a time. • On ‘Enter next task code’ prompt.1.g. Please refer to Lab Book Appendix A. Then type following DML: Obtain calc department <Enter>.

Note: . There are two types of OLQ sessions: Online and Batch. type mode as U (for Update mode) To come out of DMLO. then do following: On the first screen of DMLO. type following: Bye (Type ‘bye’ again if required). • To get back to CCS screen. you can generate a report as per the specifications. OLQ OLQ stands for On-Line Query. i. After that. type following: Finish nosave <Enter>. Please refer to Lab Book Appendix B. upto setting the environment for DB and dictionary.2. First 3 steps are same as that of DMLO. type Finish save. to come out of DMLO.e. type OLQ. On the first screen: Type ‘menu’ at the top left corner On the next screen: Select subschema with any non-blank character Next screen: Select from the given record types Next screen: Select the required elements of the selected record types as columns of the report. If you want to make any updation in the database.IDMS/R • At the end.Everywhere selection should be done with nonblank character. 14. In OLQ. 110 .

IDMS/R Next: Give the required attributes i.to go to the record type selection screen ret .to take you one screen forward 111 .to take you back to the 1st screen PF7 key . Following are some of the toggle commands: rec . sort on columns etc.to take you to the previous screen PF8 key .to go to the continue processing screen Esc 3 or PF3 key . On continue processing.e. mark NO as an active option. change headers.

112 .IDMS/R 15. Appendix A: Employee Database The diagram is shown on next page.

EMPLOYEE DATABASE IDMS/R EMPSS01 OF EMPSCHM VERSION 100 DEPARTMENT OFFICE JOB-TITLE-NDX 410 F 56 CALC 450 F 76 CALC SKILL-NAME-NDX N OA N OA ASC TITLE-0440 DN DEPT-ID-0410 DN OFFICE-CODE-0450 DN ASC SKILL-NAME-0455 DM ORG-DEMO-REGION ORG-DEMO-REGION JOB EMP-NAME-NDX SKILL DEPT-EMPLOYEE OFFICE-EMPLOYEE N OA NPO OA NO OA 440 FC 296 CALC ASC(EMP-LAST-NAME-0415 455 F 76 CALC ASC (EMP-LAST-NAME-0415 EMP-FIRST-NAME-0415) ASC (EMP-LAST-NAME-0415 DL EMP-FIRST-NAME-0415) EMP-FIRST-NAME-0415) EMP-EMPOSITION DN DL DL SKILL-ID-0455 DN EMPLOYEE EMP-DEMO-REGION ORG-DEMO-REGION 415 F 116 CALC JOB-EMPOSITION SKILL-EXPERTISE NPO MA FIRST EMP-ID-0415 DN NO AM EMP-EXPERTISE DEC SKILL-LEVEL-0425 EMP-DEMO-REGION NPO MA DF EMPOSITION DEC SKILL-LEVEL--0425 EXPERTISE EMP-EMPOSITION DF NPO MA FIRST 420 F 26 VIA 425 F 8 VIA EMP-EMPOSITION EMP-EXPERTISE REPORTS-TO MANAGES EMP-COVERAGE NPO OM NPO MA NPO MA EMP-DEMO-REGION NEXT FIRST FIRST EMP-DEMO-REGION STRUCTURE COVERAGE 460 F 8 VIA 400 F 16 VIA MANAGES DN EMP-COVERAGE DN EMP-DEMO-REGION INS-DEMO-REGION COVERAGE-CLAIMS NP MA LAST INSURAN\CE-PLAN HOSPITAL-CLAIM NON-HOSP-CLAIM DENTAL-CLAIM 435 FC 132 CALC 430 F 232 VIA 445 V 1006 VIA 405 V 830 VIA INS-PLAN-CODE-0435 DN COVERAGE-CLAIMS DN COVERAGE-CLAIMS DN COVERAGE-CLAIMS INS-DEMO-REGION INS-DEMO-REGION INS-DEMO-REGION INS-DEMO-REGION 113 .

SPACE=(TRK.5) //IDMSDMLC PROC CREG=512K.SPACE=(CYL.LET."SIZE=4096K.IDMS/R 16.PASS).PASS).NOTIFY=DA0000T. // PARM='&CPARM'. COBOL COMPILER REGION SIZE // CV=CV24T. LAST 3 CHARACTERS OF CV NAME //* DREG=4M.1)) //SYSLIN DD DSN=&&OBJ.SPACE=(CYL.MAP' //* +-----------------------------------------------------------------+ //* | EXECUTE IDMSDMLC IN EITHER CV OR LOCAL MODE | //* +-----------------------------------------------------------------+ //DML EXEC PGM=IDMSDMLC //STEPLIB DD DSN=SYS5. LINK EDITOR OUTPUT LIB // LREG=512K. SYSOUT DESTINATION // UTUNIT=SYSALLDA.BASELOAD.CCS.COND=(5.'TEST2'. // SPACE=(TRK.&CV.DISP=(MOD.LOADLIB.DISP=SHR // DD DSN=SYS5.(4.COBOL(IDMST1).(4.IDMS. UTILITY DATASET UNIT NAME // CPARM='LOAD.(10.IDMS.LOADLIB.&CV.(4.SPACE=(TRK. // LPARM='LIST. Appendix B: Compilation and Run JCL Compilation JCL: - //DA0000TY JOB LA2719.SUDHIR.DISP=SHR //SYSUT1 DD UNIT=&UTUNIT.1)) //SYSUT2 DD UNIT=&UTUNIT.&CV.DISP=SHR //SYSLST DD SYSOUT=* //SYS001 DD UNIT=&UTUNIT.IDMS.DELETE) //* +-----------------------------------------------------------------+ //* | LINK EDIT THE COMPILED PROGRAM | //* +-----------------------------------------------------------------+ //LKED EXEC PGM=IEWL.5)) //SYSIPT DD DSN=DA0000T.DISP=SHR //* +-----------------------------------------------------------------+ //* | COMPILE THE TRANSLATED COBOL PROGRAM | //* +-----------------------------------------------------------------+ //COB EXEC PGM=IKFCBL00. LOAD MODULE NAME // PRT='SYSOUT=*'. // DISP=(NEW.10)) //SYS002 DD UNIT=&UTUNIT. LINKAGE EDITOR REGION SIZE // MODE=BATCH.(10. IDMSDMLC REGION SIZE //* LINKLIB='NO "LINKLIB" PARM'...SUPMAP.10)) //SYSPCH DD DSN=&&DMLOUT.APOST.1)) //SYSUT4 DD UNIT=&UTUNIT. // SPACE=(TRK.LT.TIME=(0.DISP=SHR // DD DSN=SYSZ. 114 .IDMS. PROGRAM EXECUTION MODE //* PROGNAM='NO "PROGNAM" PARM'.SPACE=(CYL.COBCOMP.1)) //SYSUT3 DD UNIT=&UTUNIT.(40.PARM='&LPARM'.REGION=&CREG.DISP=SHR //SYSIDMS DD DUMMY //SYSCTL DD DSN=SYS5.DISP=(OLD.SYSCTL.BUF=116K"'..(4.(10.(5.SPACE=(CYL.XREF.SPACE=(TRK.10)) //SYS003 DD UNIT=&UTUNIT. // UNIT=&UTUNIT.40)) //SYSIN DD DSN=&&DMLOUT.DML) //SYSPRINT DD &PRT //SYSLIB DD DSN=SYS1.UNIT=&UTUNIT.

CCS..DISP=(OLD.LT.DISP=SHR //USERLIB DD DSN=SYS5.LOADLIB(IDMST1).(50.CARDLIB(&MODE.LOADLIB.(5.DISP=SHR //SYSLMOD DD DSN=DA0000T.SUDHIR.&CV.DELETE) // DD DDNAME=SYSIN //SYSLIB DD DSN=SYS1.IDMS.COB)).IDMS.20)) //SYSPRINT DD &PRT // PEND //STEP1 EXEC IDMSDMLC //SYSIDMS DD * DICTNAME=PATNI DBNAME=PATNI ECHO=ON DMCL=IDMSDMCL JOURNAL=OFF 115 ..C).BASELOAD.REGION=&LREG //SYSLIN DD DSN=&&OBJ.DISP=SHR // DD DSN=SYS5.&CV.DISP=OLD //SYSUT1 DD UNIT=&UTUNIT.LT.IDMS.&CV.DISP=SHR // DD DDNAME=USERLIB //SYSIN DD DSN=SYSZ.IDMS/R // COND=((5.SPACE=(1024.DML).LOADLIB..COBLIB.DISP=SHR // DD DSN=SYS5.IDMS.

CV24T.1) //* //STEP020 EXEC PGM=IDMST1 //STEPLIB DD DSN=DA0000T.MSGCLASS=X.IDMS.IDMS.LOADLIB.IDMS.CV24T.SYSCTL.IDMS/R Run JCL: - //DA0000TA JOB LA2719.SUDHIR.'PRASANNA'.CV24T.REGION=0M.NOTIFY=DA0000T.BASELOAD. // CLASS=A.DISP=SHR //SYSPRINT DD SYSOUT=* //SYSIN DD * 2222 /* //SYSOUT DD SYSOUT=* //SYSIDMS DD * ECHO=ON DBNAME=PATNI JOURNAL=OFF /* 116 .DISP=SHR //SYSCTL DD DSN=SYS5.LOADLIB.TIME=(0.DISP=SHR // DD DSN=SYS5.DISP=SHR // DD DSN=SYS5.

Appendix C: IDMS/R ERROR-STATUS VALUES MAJOR CODES Code Database Function 00 Any DML statement 01 FINISH 02 ERASE 03 FIND/OBTAIN 05 GET 06 KEEP 07 CONNECT 08 MODIFY 09 READY 11 DISCONNECT 12 STORE 14 BIND 15 ACCEPT 16 IF 17 RETURN 18 COMMIT 19 ROLLBACK 20 LRF request 117 .IDMS/R 17.

sets and areas affected are in subschema 22 Named record not currently member of named set 23 Named area not in subschema 25 Currency not established for object set 26 Record or SPF index entry not found. indicates unsuccessful completion due to problems related to CV 01 Area not readied: OR IF operation determined that set not empty or current record of run unit not a member of set 02 Db-Key used with a FIND/OBTAIN DBKEY. indicates successful completion. or LR verb not in subschema. or area 07 End of a set. OR set empty 08 Object record. OR not all records. if nonzero. OR no more duplicates exists for object record 28 Run unit attempted to ready a previously readied area 29 DB-Key KEEP deadlock 30 Attempt made to erase owner of nonempty set 31 Retrieval statement’s format conflicts with record’s location mode 32 CALC field value in variable storage not equal to CALC control element value in current record of record type 33 One or more sets in which the record participates not in subschema 118 . or direct db-key on a STORE. set. procedure. may indicate improper use of an ERASE 11 Record not stored because of insufficient space in area 13 Run-unit currency not established or nullified by a previous ERASE. for SPF users. area. OR object record not member of object set 09 Area readied for retrieval. or index set reached. 14 CONNECT not executed because object record defined as mandatory automatic member of set 15 DISCONNECT not executed because object record defined as mandatory member of set 16 Record already member of set 18 Record not bound 20 Current record of run unit not the same type as specified record 21 Not all areas being updated were readied in update usage mode. OR zero is sequence number for FIND/OBTAIN sequence-vn WITHIN SET/AREA 05 Execution of DML function would violate duplicates-not-allowed restriction 06 Currency not established for object record.IDMS/R MINOR CODES 00 If major code 00. set. but DML issued requires update usage mode 10 Access restriction or subschema USAGE restriction prevents execution of requested DML. not within page range for specified record 04 Occurs-depending-on value negative or exceeds maximum.

IDMS/R 40 WHERE clause in OBTAIN NEXT logical record inconsistent with previous OBTAIN FIRST or NEXT for same logical record 41 Subschema contains no path to match logical record request’s WHERE clause 42 Error occurred in processing logical record path 43 Bad or inconsistent data in the logical record’s variable storage location. or in request’s or path’s WEHRE clause 44 Logical record request’s WHERE clause did not supply a key element expected by path 45 Subscript value in logical record request’s WHERE clause invalid 46 Arithmetic program check would occur in evaluation of logical record request’s WHERE clause 55 Invalid length defined for variable-length record 56 Insufficient memory available for IDMS compression/decompression routines 60 Record type inconsistent with set named in error set field of the IDMS Communications Block 61 No record found for pointer db-key 63 DBMS could not interpret DML function 64 CALC control element not described properly 65 Database page read not page requested 66 Area specified not available for update 67 Subschema invoked does not match subschema object tables 68 CICS interface (IDMSINTC) was not started 69 Run unit not bound to DBMS 70 Database or journal file would not open properly 71 Page range for area being readied or page requested not in DMCL 72 Insufficient memory available for load or storage allocation 73 New central vision run unit would exceed MAXERUS value specified at CV generation 74 Dynamic load of module failed 75 Read error 76 Write error 77 Run unit not bound or bound twice 78 Area wait deadlock 79 Run unit requested more db-keys locks than available to system 80 Target node not active or disconnected from DDS configuration 81 Database name specified not known 82 Subschema not allowed under specified database 83 Error was made in use of native VSAM datasets 119 .

IDMS-DB / DC Programmer’s Guide • IDMS/R A Professional’s Guide to Concepts. Richard Derer. Joe Leben 120 . Design and Programming By James Martin.IDMS/R 18. Towner • IDMS/R Concepts. Appendix D: References • Manual: . Design and Programming By Larry E.