Sie sind auf Seite 1von 90

IMS Class Room Session

IMS/DB Program is the user of IMS/DB. Types of processing

IMS

Online Transaction Processing Message Processing Program (MPP) Two Batch Environment Shared Batch Processing (BMP) Exclusive Batch (DL/I)(DBB)

Level of Abstraction

Cobol READ

VSAM Macro

MVS Low Level Routines GET, PUT

DASD

CCHH

IMS Database

EMP PERSONAL DATA

EMP PAYROLL

EMP LIBRARY

EMP SKILL

If EMP personal data is deleted, all the others should get deleted. This is referential integrity.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 1 of 90

IMS Class Room Session

IMS data manager

VIEW

LOGICAL MODEL

PHYSICAL LAYER

What user wants

DASD

Hierarchical Model

User deals with logical view only. He is not bothered about how data is stored physically. This is data independence. IMS Logical Structure

Level 1

Parent CUSTOMER

Parent/Child

ORDER

Level 2

Child DELIVERY ITEM Twins

Level 3

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 2 of 90

IMS Class Room Session


Process and Level Of Abstraction IMS/DM PSB DBD

PCB P R O G R A M

ACB

DL/I

Hierarchical Access Methods

File Management

Low Level I/O routines

HISAM VSAM HDAM OSAM HIDAM

MVS

Disk Volumes Note: PSB and DBD must be created before executing program.

View determines what user can see and PSB determines View How to use IMS Database Manager?

1. Create Hierarchical Model 2. Inform IMS/DM about your data model. This model is to be translated to physical medium. The process is called Database Description Generation. DBDGEN:- Creates DBD elements for IMS. Now IMS knows about your data model. Now model is created, need to put segments into it. Therefore need to provide access to user. 3. Provide access to user -Which database/segments/fields -What user can do CRUD How this view is defined? This is done by Program Specification Block Generation. PSBGEN:- Creates PSB elements PSB restricts/allows what user can see. Here user is a program. DBA looks after these things i.e. 1,2,3 Programmer never defines new databases. For any new program, you need to create PSB element.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 3 of 90

IMS Class Room Session

Process Access Request What CRUD (Create, Replace, Update, Delete) On what dbd(one PCB for each database)/segment/segment qualification With what/where segment i-o Area (Here IMS returns the required data in this area defined in working storage) Was it successful Communication PCB (equivalent to SQLCA)

IMS reports on the call through program communication block. IMS provides this programming interface through DL/I calls. CALL CBLTDLI USING FUNCTION PCB I-O-AREA SSA

DBD feedback Segment Qualification

Individual hierarchical model is one database. Collection of all databases is corporate database. (Only for IMS) Assignment1 :Utility CAISACB is equivalent of DBDGEN. Create a file DBD1.ACB using text editor (EDIT), invoke the utility CAISACB to create a database. In the same file write DBD and then PSB specification.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 4 of 90

IMS Class Room Session


Day 3

Persistent Data

Problems:1. Durability 2. Concurrent Usage (Isolation) 3. Manage (catalog) Catalog policy:- Recovery ,Easy Access

IMSSRCLIB: DBD source DBDLIB: Generated DBD---------------Get the information IMS/ESA Version 6.0 Manual, Utilities Reference-System (Generated Utilities) Library Reader for Windows (download from Internet or Cds)

Assignment2: Two Entities: EMPLOYEE & PROJECT Hierarchical Model EMP PROJECT

PR

SKL

ASSIGN

Here there are two databases.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 5 of 90

IMS Class Room Session


EMP EMPNOPIC EMPNAME EMPADR PR PRYYYYMM PIC NET-PAY-AMT PIC SKL SKL-ID SKL-NAME EXPYRS PROJECT PROJECT-ID PIC NAME PIC CLIENT-NAME PIC ASSIGN EMPNOPIC X(06) Unique START-DATE PIC X(08) END-DATE PIC X(08) X(04) Unique X(20) X(50) PIC PIC PIC X(03) Unique X(30) 9(02) X(06) Unique 9(06) X(06) Unique PIC X(30) PIC X(40)

Three ways of accessing information:1. Random 2. Sequential (all) 3. Sequential with criteria EMPNO is a Key field. Therefore all the EMP occurrences will be in ascending order of EMPNO One root with all dependents is a database record

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 6 of 90

IMS Class Room Session

PRINT NOGEN DBD NAME=EMPDB SEG NAME=EMP,PARENT=0,BYTES=76 FIELD FIELD FIELD SEG NAME=PR,PARENT=EMP,BYTES=12 FIELD FIELD SEG NAME=SKL,PARENT=EMP,BYTES=35 FIELD FIELD FIELD DBDGEN FINISH END (SEQ,U): Unique key field (SEQ,M): Non-unique key field IMS.MACLIB: Look out in for DBD,SEG FIELD etc. Utility to analyze DBD: ISPF;Option 1 (IMS DBT (DataBase Tools) Manuals) DBDSRC: Contains DBD source DBDLIB: Contains DBD elements

Assignment3: 1. 2. 3. 4. Print pictures of all the database Report of DBD used by different program PSBwise Report DBD by access methods: HISAM, HDAM, and HIDAM. There wont be Report for GSAM

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 7 of 90

IMS Class Room Session

Hierarchical Sequence 1. Top to Bottom 2. Left to Right IMS puts the segments in this order. If needs to add new segments into the defined sequence, every time that sequence has to be break therefore IMS gives 3 access methods 3. 4. 5. 6. HSAM (Sequential) HISAM (Indexed) HDAM (Direct) HIDAM (Indexed direct)

HSAM Hierarchical sequential access method (HSAM) databases use the sequential method of accessing data. All database records and all segments within each database record are physically adjacent in storage. An HSAM database can be stored on tape or on a direct-access storage device. HSAM databases can only be updated by rewriting them. Delete (DLET) and replace (REPL) calls are not allowed, and insert (ISRT) calls are only allowed when the database is being loaded. Although the field-level sensitivity option can be used with HSAM databases. Although the uses of HSAM are limited because of its processing characteristics, it is used for applications requiring sequential processing only. Typically, HSAM is used for low-use files. These are files containing, for example, statistical reports or files containing historical or archive data that has been purged from the main database. In the data set, a database record is stored in one or more consecutive blocks. You define what the block size will be. Each block is filled with segments of the database record until there is not enough space left in the block to store the next segment. When this happens, the remaining space in the block is padded with zeros and the next segment is stored in the next consecutive block. When the last segment of a database record has been stored in a block, any unused space, if sufficient, is filled with segments from the next database record. In storage, an HSAM segment consists of a 2-byte prefix followed by user data. The first byte of the prefix is the segment code, which identifies the segment type to IMS. This number can be from 1 to 255. The segment code is assigned to the segment by IMS in ascending sequence, starting with the root segment and continuing through all dependents in hierarchic sequence. The second byte of the prefix is the delete byte. Because DLET calls cannot be used against an HSAM database, the second byte is not used.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 8 of 90

IMS Class Room Session


Initial entry to an HSAM database is through GU or GN calls. When the first call is issued, the search for the desired segment starts at the beginning of the database and passes sequentially through all segments stored in the database until the desired segment is reached. After the desired segment is reached, its position is used as the starting position for any additional calls that process the database in a forward direction.

HISAM Distributes one dataset into two datasets. Is a slowest access method of all. When DBD generation takes place, it suggests space, CI size etc. then accordingly DBA creates the two datasets, KSDS & ESDS

EMP EMP EMP Primary Dataset

RBA RBA

PR SKL

PR SKL

SKL

RBA

Overflow Dataset

HISAM data-base requires frequent reorganization

In a hierarchical indexed sequential access method (HISAM) database segments in each database record are related through physical adjacency in storage. Each HISAM database record is indexed, allowing direct access to a database record. In defining a HISAM database, you must define a unique sequence field in each root segment. These sequence fields are then used to construct an index to root segments (and therefore database records) in the database. HISAM is typically used for databases that require direct access to database records and sequential processing of segments in a database record.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 9 of 90

IMS Class Room Session

Database Record: Starting from root to the last dependant is one complete database record. Logical Record The logical record is a part of database record, which can be stored in one CI. In a logical record, the first 4 bytes are a direct-address pointer to the next logical record in the database record. This pointer maintains all logical records in a database record in correct sequence. The last logical record in a database record contains zeros in this field. Following the pointer are one or more segments of the database record in hierarchic sequence. Following the segments is a 1-byte segment code of 0. It says that the last segment in the logical record has been reached.

HISAM database records are stored in two data sets. The first data set, called the primary data set, contains an index and all segments in a database record that can fit in one logical record. The index provides direct access to the root segment (and therefore to database records). The second data set, called the overflow data set, contains all segments in the database record that cannot fit in the primary data set. A KSDS is the primary data set and an ESDS is the overflow data set. Logical records are grouped into control intervals (CIs). A control interval is the unit of data transferred between an I/O device and storage. You define the size of CIs. Each database record starts at the beginning of a logical record in the primary data set. A database record can only occupy one logical record in the primary data set, but overflow segments of the database record can occupy more than one logical record in the overflow data set. Segments in a database record cannot be split and stored across two logical records. Because of this and because each database record starts a new logical record, unused space exists at the end of many logical records. When the database is initially loaded, IMS inserts a root segment with a key of all X'FF's as the last root segment in the database. Each logical record in the primary data set contains the root plus all dependents of the root (in hierarchic sequence) for which there is enough space. The remaining segments of the database record are put in the overflow data set (again in hierarchic sequence). The two "parts" of the database record are chained together with a direct-address pointer. When overflow segments in a database record use more than one logical record in the overflow data set the logical records are also chained together with a direct-address pointer.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 10 of 90

IMS Class Room Session


In HISAM, when an application program issue a call with a segment search argument (SSA) qualified on the key of the root segment, the segment is found by: 1. Searching the index for the first pointer with a value greater than or equal to the specified root key (the index points to the highest root key in each CI)

2. Following the index pointer to the correct CI 3. Searching this CI for the correct logical record (the root key value is compared with each root key in the CI) 4. When the correct logical record (and therefore database record) is found, searching sequentially through it for the specified segment If an application program issues a GU call with an unqualified SSA for a root segment or with an SSA qualified on other than the root key, the HISAM index cannot be used. The search for the segment starts at the beginning of the database and proceeds sequentially until the specified segment is found. Picture to be drawn for database How new segments are inserted ? CI split?

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 11 of 90

IMS Class Room Session


Pointers Used in HD database Types of Pointers You Can Specify: The hierarchic sequence of segments in a database record using the sequential access methods is maintained by keeping segments physically adjacent to each other in storage. In the HD access methods, segments in a database record are kept in hierarchic sequence using direct-address pointers. Each pointer is 4 bytes long and consists of the relative byte address of the segment to which it points. Several different types of direct-address pointers exist: Hierarchic pointers, which point from one segment to the next in either forward or forward and backward hierarchic sequence Physical child pointers, which point from a parent to each of its first or first and last children, for each child segment type Physical twin pointers, which point forward or forward and backward from one segment occurrence of a segment type to the next, under the same parent

When segments in a database record are typically processed in hierarchic sequence, use hierarchic pointers. When segments in a database record are typically processed randomly, use a combination of physical child and physical twin pointers. When an application program issues a call for a segment, HF pointers are followed until the specified segment is found. In this sense, the use of HF pointers in an HD database is similar to using a sequentially organized database. In both, to reach a dependent segment all segments that hierarchically precede it in the database record must be examined. HF pointers should be used when segments in a database record are typically processed in hierarchic sequence and processing does not require a significant number of delete operations. If there are a lot of delete operations, hierarchic forward and backward pointers (explained next) might be a better choice. Four bytes are needed in each dependent segment's prefix for the HF pointer. Eight bytes are needed in the root segment. More bytes are needed in the root segment because the root points to both the next root segment and first dependent segment in the database record. HF pointers are specified by coding PTR=H in the SEGM statement in the DBD. Hierarchic Forward and Backward Pointers: With hierarchic forward and backward pointers (HF and HB), each segment in a database record points to both the segment that follows and the one that precedes it in the hierarchy (except dependent segments do not point back to root segments). HF and HB pointers must be used together, since you cannot use HB pointers alone.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 12 of 90

IMS Class Room Session

HF and HB pointers are specified by coding PTR=HB in the SEGM statement in the DBD.

Physical Child First Pointers: With physical child first (PCF) pointers, each parent segment in a database record points to the first occurrence of each of its immediately dependent child segment types. With PCF pointers, the hierarchy is only partly connected. No pointers exist to connect occurrences of the same segment type under a parent. Physical twin pointers (explained later) can be used to form this connection. PCF pointers should be used when segments in a database record are typically processed randomly and sequence fields are either defined for the segment type. If not, new segments are not inserted at the end of all existing segment occurrences. If sequence fields are not defined and new segments are inserted at the end of existing segment occurrences, the combination of PCF and physical child last (PCL) pointers (explained next) can be a better choice. Four bytes are needed in each parent segment for each PCF pointer. PCF pointers are specified by coding PARENT=((name,SNGL)) in the SEGM statement in the DBD. This is the SEGM statement for the child being pointed to, not the SEGM statement for the parent. Note, however, that the pointer is stored in the parent segment.

Physical Child First and Last Pointers: With physical child first and last pointers (PCF and PCL), each parent segment in a database record points to both the first and last occurrence of its immediately dependent child segment types. PCF and PCL pointers must be used together, since you cannot use PCL pointers alone. PCF and PCL pointers (as opposed to just PCF pointers) are typically used when: No sequence field is defined for the segment type. New segment occurrences of a segment type are inserted at the end of all existing segment occurrences.

On insert operations, if the ISRT rule of LAST has been specified, segments are inserted at the end of all existing segment occurrences for that segment type. When PCL pointers are used, fast access to the place where the segment will be inserted is possible. This is because there is no need to search forward through all segment occurrences stored before the last occurrence. PCL pointers also give application programs fast retrieval of the last segment in a chain of segment occurrences. Application programs can issue calls to retrieve the last segment by using an unqualified SSA with the command code L. When a PCL pointer is followed to get the last segment occurrence, any further movement in the database is forward.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 13 of 90

IMS Class Room Session

A PCL pointer does not enable you to search from the last to the first occurrence of a series of dependent child segment occurrences. Four bytes are needed in each parent segment for each PCF and PCL pointer. PCF and PCL pointers are specified by coding the PARENT= operand in the SEGM statement in the DBD as PARENT=((name,DBLE)). This is the SEGM statement for the child being pointed to, not the SEGM statement for the parent. Note, however, that the pointers are stored in the parent segment. A parent segment can have SNGL specified on one immediately dependent child segment type and DBLE specified on another. Coding these pointers in the DBD: DBD SEGM A SEGM B PARENT=((name.SNGL)) (specifies PCF pointer only) SEGM C PARENT=((name.DBLE)) (specified PCF and PCL pointers)

Results in these pointers being created: Physical Twin Forward Pointers: With physical twin forward (PTF) pointers, each segment occurrence of a given segment type under the same parent points forward to the next segment occurrence. Note that PTF pointers can be specified for root segments. When this is done in an HDAM database, the root segment points to the next root in the database chained off the same root anchor points (RAP). (RAPs are explained in a following section called "General Format of HD Databases and Use of Special Fields.") If no more root segments are chained from this RAP, the PTF pointer is zero. When PTF pointers are specified for root segments in HIDAM database, the root segment does not point to the next root in the database. What happens is explained in a subsequent section called "Use of RAPs in a HIDAM Database." The important thing for you to know now is that if you specify PTF pointers on a root segment in a HIDAM database, the HIDAM index must be used for all sequential processing of root segments. This increases access time. This problem is eliminated if you specify PTF and physical twin backward (PTB) pointers (discussed next). With PTF pointers, the hierarchy is only partly connected. No pointers exist to connect parent and child segments. Physical child pointers can be used to form this connection. PTF pointers should be used when segments in a database record are typically processed randomly, and you do not need sequential processing of database records. Four bytes are needed for the PTF pointer in each segment occurrence of a given segment type. PTF pointers are specified by coding PTR=T in the SEGM statement in the DBD. This is Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 14 of 90

IMS Class Room Session


the SEGM statement for the segment containing the pointer. The combination of PCF and PTF pointers is used as the default when pointers are not specified in the DBD. Physical Twin Forward and Backward Pointers: With physical twin forward and backward (PTF and PTB) pointers, each segment occurrence of a given segment type under the same parent points both forward to the next segment occurrence and backward to the previous segment occurrence. PTF and PTB pointers must be used together, since you cannot use PTB pointers alone. Note that PTF and PTB pointers can be specified for root segments. When this is done, the root segment points to both the next and the previous root segment in the database. As with PTF pointers, PTF and PTB pointers leave the hierarchy only partly connected. No pointers exist to connect parent and child segments. Physical child pointers (explained previously) can be used to form this connection. PTF and PTB pointers (as opposed to just PTF pointers) should be used on the root segment of a HIDAM database when you need fast sequential processing of database records. By using PTB pointers in root segments, database records can be sequentially processed without intervening references to the HIDAM index. PTB pointers improve performance when deleting a segment in a twin chain accessed by a virtually paired logical relationship. This happens when the delete that causes DASD space to be released occurs on a delete from the logical access path. Eight bytes are needed for the PTF and PTB pointers in each segment occurrence of a given segment type. PTF and PTB pointers are specified by coding PTR=TB in the SEGM statement in the DBD. Mixing Pointers: Because pointers are specified by segment type, the various types of pointers can be mixed within a database record. However, only hierarchic or physical, but not both, can be specified for a given segment type. The types of pointers that can be specified for a segment type are: HF HF and HB PCF PCF and PCL PTF PTF and PTB Hierarchic forward Hierarchic forward and backward Physical child first Physical child first and last Physical twin forward Physical twin forward and backward

When a segment is deleted in an HD database, it is physically removed from the database. The space it occupied can be reused when new segments are inserted.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 15 of 90

IMS Class Room Session

HDAM Defined using one dataset, ESDS or OSAM which is logically divided into 2 parts

RAA CIs (Root Addressible Area) 00001

Overflow Area Cis

How data is placed ? IMS provides Randomizing Module (Assembly language module) Key value (00001) will be the input Randomizing Module Output will be a block number, which will be Available range. If it is 8, then record gets Stored into 8th block. Here there is a problem. If the block number is duplicated, the record gets stored into same block. Which requires more overhead. Therefore required to choose proper randomizing module and number of RAA blocks. If segment is deleted that space is available for new segments. HDAM supports random access. It does not support for sequential access. 1968-IMS 1973-VSAM Therefore IMS used OSAM (Overflow Sequential Access Method), ISAM prior to VSAM KSDS,ESDS

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 16 of 90

IMS Class Room Session


HDAM databases are typically used when you need primarily direct access to database records. The randomizing module provides fast access to the root segment (and therefore the database record). HDAM databases also give you fast access to paths of segments as specified in the DBD in a database record. You cannot process HDAM database records in key sequence unless the randomizing module you use stores root segments in physical key sequence. HIDAM It makes use of two data-sets, ESDS and KSDS

ESDS 1 5 6 99

KSDS

A HIDAM database is actually composed of two databases. (HIDAM uses an index to get to a specific root segment rather than the root anchor points used by HDAM.) The first database contains the database records as the database. The second database contains the HIDAM index as the index database. Root segments in a HIDAM database must have a unique key field, because an index entry exists for each root segment based on the root's key. When initially loading a HIDAM database, all root segments should be presented to the load program in ascending key sequence, and all dependents of a root should follow the root in hierarchic sequence. Note that HIDAM, unlike HDAM, has no root addressable or overflow area, just a series of blocks or CIs. When database records are initially loaded, they are simply loaded one after another in the order in which they are presented to the load program. The space in Note how segments in a database record are chained together. In this case, hierarchic pointers were used instead of the combination of physical child/physical twin pointers. Each segment points to the next segment in hierarchic sequence. Although HIDAM databases can have RAPs, you probably do not need to use them.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 17 of 90

IMS Class Room Session


As each root is stored in a HIDAM database, IMS creates an index segment for the root and stores it in the index database. The index database consists of a single VSAM KSDS. The KSDS contains an index segment for each root in the database. When initially loading a HIDAM database, IMS will insert a root segment with a key of all X'FF's as the last root in the database. The prefix portion of the index segment contains the delete byte and the root's address. The data portion of the index segment contains the key field of the root being indexed. This key field identifies which root segment the index segment is for and remains the reason why root segments in a HIDAM database must have unique sequence fields. Each index segment is a separate logical record. Persistent Data Contd Recovery DBRC:- Database Recovery Control You need to define DBRC for every database. All the recovery process is automatic. Each and every activity is recorded by IMS. DBRC makes use of a log. Whenever changes are made to databases, are stored in log. Using that DBRC does the recovery. It can be semiautomatic that is JCLs are created but not submitted. DBRC is located in a separate address space. It is invoked by an MVS start procedure command that is issued from the IMS control region. An IMS online system uses this separate address space to contain the DBRC code. Each system must obtain authorization from DBRC before it can access the database, even if the database is not registered for sharing. For area-level sharing, authorization is obtained at the point in the processing when that data resource is requested. Isolation IRLM:- IMS Resource Lock Manager or Internal Lock manager. It puts the lock automatically.

DBRC DL/I IRLM

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 18 of 90

IMS Class Room Session

Automicity of transaction: Rolling back the transaction Transaction starts Changes kept in log Transaction completes Changes are made permanent or else changes are undone by IMS if transaction fails COMMIT releases the locks (Checkpoint)

DB/DC Dictionary:Separate product along with IMS, takes care of database management.(catalog service)

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 19 of 90

IMS Class Room Session


Day 4

CALL CBLTDLI USING

FUNCTION PCB IOAREA SSA

FUNCTION:

ISRT REPL DELT GU GN GNP Program working storage area used by IMS to store, retrieve data. Segment Search Argument. To inform IMS - which segment to work on.

IOAREA: SSA:

To insert new EMP segment: 1. 2. 3. 4. ISRT I/O area to be prepared PCB which indicates DB Segment Name (EMP)

Programs are users to IMS. IMS always talks to you through program. PSB 1. Which database to be worked on: EMPDBD 2. Which segment to be worked on: 3 segments 3. What is the operation; ISRT IMS wont allow to perform any other operation, or use any other DBD not specified here. This way you can obtain control on the database operation a program can perform.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 20 of 90

IMS Class Room Session

PCB

TYPE=DB,NAME=EMPDBD,PROCOPT=I/A/IRD/G/GON/GOT

Once this PSB is ready, you can work on it. Now define the segments of the database. Here there are 3 segments used therefore SENSEG NAME=___________ SENSEG NAME=___________ SENSEG NAME=___________ PSBGEN NAME=EMPADD,LANG=COBOL [SENSEG-Sensitive Segment] So before writing COBOL program all these things need to prepare. Note: Use PROCOPT = A As many no. of PCB = No. Of databases You can also give restriction at field level that is one particular field only should get modified and not others

PCB -------------SENSEG NAME=EMP SENFLD NAME=EMPNAME : : So here only EMPNAME can be modified. You cannot touch any other field from that segment.

IMS1.DBDLIB (pds) contains DBD generated. For example: EMPDBD IMS1.PSBLIB (pds) contains PSB generated. For example: EMPADD

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 21 of 90

IMS Class Room Session

When you execute IMS program, IMS first look for PSB therefore specify program name with PSBname. IMS will create one area by acquiring memory. If there use multiple PCB statements it will create occurrences of that area. PCB PCB PCB PCBGEN

Program does not start execution, IMS first does its job then program starts execution because JES is not aware of PCB mask. DBPCB Mask: Definition for this area is defined by IMS. Here only concatenated key length will vary

11 3 9

22

11

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 22 of 90

IMS Class Room Session


In our case concatenated key will be 12

EMP 6

PR 6

SKL 3

This entire pcb mask IMS puts into acquired memory. EMP-PCB-MASK. DBDNAME= EMPDBD PROCOPT=A NO-SEN-SEG=3 CONCATENATED-KEY=12

This structure is known as program communication block. So first thing required for executing IMS Program:

1. Create PSB 2. Program executed 3. IMS creates PCB into its own area & not in program work area. It is created to inform you about your IMS operation. This is outside the program work area therefore needs to define PCB in linkage section of COBOL program. In the procedure division you should write as: PROCEDURE DIVISION USING EMP-PCB-MASK You are not suppose to change PCB. It is read only. If you try to change it. You will get ABEND for storage violation

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 23 of 90

IMS Class Room Session

IMS STORAGE KEY 7

PROGRAM STORAGE KEY 8

Lowest key can operate on any high key area. But if higher value key area tries to change anything from low-key area, storage violation will occur & program will ABEND. Even CICS operates at lower level. In case if you are using two PCBs

PCB PCB

EMPDBD PROJDBD

LINKAGE SECTION. 01 EMP-PCB-MASK : : 01 PROJ-PCB-MASK

This order must match

PROCEDURE DIVISION should be: PROCEDURE DIVISION USING EMP-PCB-MASK PROJ-PCB-MASK.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 24 of 90

IMS Class Room Session


Another way of using PCB mask in Procedure Division:PROCEDURE DIVISION. ENTRY DLICBLT USING EMP-PCB-MASK..

(AMEX Standard)

just cant directly executes your Program.

DFSRRC00 Execute DFSRRC00 program to execute your IMS cobol program. You

EXEC PGM=DFSRRC00. PGMNAME=EMPADD PSBNAME=EMPPSB.. It first loads PCB-mask into memory & then it will load your program into memory. Then it passes Address of PCB-mask to the program. 1 INVENTORY-PCB-MASK. 05 DBD-NAME 05 SEGMENT-LEVEL 05 STATUS-CODE 05 PROC-OPTIONS 05 FILLER 05 SEGMENT-NAME 05 KEY-LENGTH 05 NUMB-SENS-SEGS 05 CONCAT-KEY

X(08). X(02). X(02). X(04) S9(05) COMP X(08) S9(05) COMP S9(05) COMP X(11)

This will be always same

This will change as per the segment level

Assignment4: 1. Create test data 2. Write DBD for EMP, PROJECT and PSB in one single .ACB file. Keep PROCOPT = A 3. Invoke CAISUTIL

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 25 of 90

IMS Class Room Session

Day 5 Segment can have only one SEQ field If field is SEQ and you are looking out for 16. It will stop search when it reaches 17. It wont search beyond that. Whereas if the field is SEARCH field, it will search all the records. Therefore slower performance

In DBDGEN, fields defined using FIELD other than SEQ field are SEARCH fields. Only these fields you can use in SSA. Rules are coded for segment having SEQ field but which is nonunique. Still IMS needs to arrange it in order. Give it as (SEQ, M) This is non-unique so duplicates are allowed.

Type Of CALL 1. Unqualified CALL If CALL statement does not include SSA then that CALL is unqualified CALL. 2. Qualified CALL If SSA is specified in a CALL, it is qualified CALL. Type Of SSA Qualified SSA Containing segment name with some qualification Example: EMP (EMPNO EQ 123456) Unqualified SSA Contains just segment name Example: INSRT EMP

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 26 of 90

IMS Class Room Session

CALLS

1. GET UNIQUE Function Code: GU Functions: Used to retrieve a segment Used for random access GU-------------------------------------------------(A) GU EMPSEG GU EMPSEG PRSEG GU PRSEG----------------------------------(B) GU SKLSEG--------------------------------(E) GU EMPSEG (EMPNO=123456)--------(H)

Unqualified Call Qualified Call Qualified SSA

(A) will give first root occurrences. If SSAs are missing for any level, then IMS assumes unqualified SSA for that level. It is equivalent to GU EMPSEG. IMS always starts search in hierarchical sequence.

Return Code: GE: Segment not found Blank: Segment found

A EMPSEG

B PRSEG

D E SKLSEG

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 27 of 90

IMS Class Room Session

2. GET NEXT (Sequential Processing) Function Code: GN Function: Used to retrieve next sequential segment

EMPSEG G 234562 EMPSEG A 123456

PRSEG D 200102 PRSEG C 200101 PRSEG B 200012

SKLSEG F 02JAVA SKLSEG E 01CICS

CALL GU GN GN GN GN

SEGMENT RETRIEVED A B C D E

RETURN CODE BLANK BLANK BLANK BLANK GK

COMMENT EMPSEG (123456) MOVED AT LOWER LEVEL

MOVED AT SAME LEVEL BUT DIFFERENT SEGMENT MOVED AT HIGHER LEVEL

GN GN

F G

BLANK GA

Now suppose if you want to retrieved skill-id 01 of first employee Then you need to code following:

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 28 of 90

IMS Class Room Session


GU EMPSEG (EMPNO=123456) GN SKLSEG OR GN SKLSEG(SKLID=01) But what if you want to retrieve particular segment for all the employees. Say, For each employee print payroll record. So for this is use GNP call. GNP: Get Next Within Parent. GU or GN call establishes parentage. If want to use GNP, first you have to use GU or GN to establish parent. Scope of GNP: All the dependents of the particular parent. GU EMPSEG GNP SKLSEG Will retrieve all the skill segments under that employee. When skill segment will end for that employee, you will get return code of GE.

3. Replace and Delete Call Function Code: REPL and DLET Function: Used to replace and delete the specified segment 1] Read With Hold is necessary before you work on with these calls GHU, GHN, GHNP 2] While replacing, key portion cannot be modified 3] For delete call do not move anything into segment area. GHU EMPSEG (EMPNO=123456) DLET (here no need to specify qualification, it will work on old call) GHU EMPSEG (EMPNO=123456) MOVE .. DLET (here it will give return code DX)

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 29 of 90

IMS Class Room Session


4] Once EMP segment is deleted all the dependents of this segment will get deleted.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 30 of 90

IMS Class Room Session

5] Some other formats you can use: GHU GHN EMPSEG(EMPNO=123456) PRSEG---*L *F DLET * indicates Command Code Follows Three spaces go for last PRSEG go for first PRSEG

REPL & DLET must be preceded by HOLD call. Otherwise IMS will give you the return code DA, DJ

Status codes you can expect during sequential processing

Status Code Blank GE GB

GA

GK GP

Description Blank in the PCB status code after GN or GNP call indicates that the call was successful Segment not found Can occur with GN but not with GNP call. It indicates that youve tried to retrieve a segment, but are at the end of database. It is like AT END condition raised during COBOL READ statement. When you reach the end of database with GNP call, DL/I returns the GE status code. When an unqualified GN or GNP call moves to upper level in the hierarchy to retrieve a segment Raised by unqualified GN or GNP at same hierarchical level but different segment. GNP is given before establishing a parentage

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 31 of 90

IMS Class Room Session


Day 6 Application Control Block Hierarchical access method is a general purpose routine But we dont want all the routines to be run We need to have customized version of Hierarchical Access Method So to customize this use PROCOPT

Restrict and Provide access requires buffers. Access Method cannot work direct with PSB. ACB is the combined version of PSB and DBD. Buffer creation for DBD segments is done by use of ACB. In a mainframe, under batch mode i.e. DL/I environment. IMS initialization needs to be done before program starts execution. EXEC PGM=DFSRRC00 PARM (DL/I,.)

In DL/I batch mode, generation of ACB is dynamically invoked. DFSRRC00 looks PSB & take corresponding DBD and create the ACB block & then create PCBs. After this it gives control to your program and then the execution starts. If this facility is available in batch DL/I, then why it is not in Online? Why in Online, ACB block generation is required? Since in Online programs response time is critical therefore instead of creating it dynamically it is generated first. Each program triggers ACB generation therefore in Online it is generated first. It is a separate entity stored in ACBLIB.

In DBBATCH (newer version) in batch environment (PARM=(DBB,..)), ACB should be generated in advance like online Assembly language code routines are stored as a member of SYS1.RESLIB Find out how many members are present in ACBLIB Whether many PSB can reside in one ACB?

Summary:-In DL/I In Online -ACB creation is dynamic (Using DFSRRC00 in RUN JCL)

-ACBGEN is required (Saves Time) Also in DBB (newer version) -ACBGEN is required

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 32 of 90

IMS Class Room Session


IMS/DC Service Architecture

Tools

Process

Reception

User Data Layer Business Layer Presentation Layer User User

Example: Knowledge-ware Co. Experts Home Library Books Manuals Periodicals Phy Ref. Papers : : : : : P C M A Maths s Reception

Call to Expert Manager P C Forms to be processed

Cupboard for Blank Forms M A

Blank form ------(II) Filled in form---(III) User(I)

Reception slots Delivery

User

Delivery Tray Forms to be delivered Data Layer Business Layer Presentation Layer

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 33 of 90

IMS Class Room Session


Reception Responsibilities: 1. 2. 3. Provide Blank forms Accept filled in forms Deliver reply

Experts are on call experts Physics and Astrophysics are high priority jobs Manager will take decision based on 1. Priority 2. Resources (No. of cabins) 3. Load If it is just one request, You may not call expert. You will have a policy for when to call expert.

Expert Work Flow 1. 2. 3. 4. 5. Take form Process reply-after-referring-library Put into delivery tray Repeat step 1 thru 3 until no request Go Home

IMS/DC or IMS/TM PGMLIB Programs Home Control Region IMS/ DB IMS/ DM MPP Region User User Out /FOR PHY Out

Qmanager

MFSLIB

MPP Region In MFS User

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 34 of 90

IMS Class Room Session

MFS looks for physics form in MFSLIB and gives it to user. Who will design the physics forms? Total 4 forms to be designed and kept in MFSLIB. User will enter data in physics form and presses enter. Now MFS will put this in QMGR. We need to provide these blank forms. Same as CICS BMS maps

Managers Work Sheet: Requirement Physics Chemistry Maths Astrophysics Priority 2 3 4 1 Program Phy pgm. Che pgm. Math pgm. Astro pgm. Address ---------------------

Worksheet is provided by you. Same as CICS PPT table entry

Manager will call associated program depending on the priority given. IMS is not aware of this worksheet. So somebody has to inform that there are different forms, with associated experts. Once Program is loaded, it will take forms from QMGR until no more forms.

Pseudocode for subject matter expert work flow: Receive Form Perform Process Until no-more-form Go back Process. Find the required information Send form with details Receive form

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 35 of 90

IMS Class Room Session

Day 7 EMPO EMPADD EMPNO: EMPNAME: ADDRESS: _______ _______ _______

/FOR EMPO MFS will pick up EMPO from MFSLIB and send it to terminal. User will enter details and form goes to QMGR when user presses ENTER. There should be identification form each form. So accordingly it gets stored in QMGR. n number of users can invoke same form to enter details. 8 characters transaction-id is associated for each screen. Control region provides this facility of system definition. It uses 2 macros 1. Transact 2. Applctn After typing transaction id at the terminal, program is loaded into memory & starts execution. Terminology CICS IMS Quasi-reentrancy

Serial reusability

If any program fails, IMS provides transaction support to undo all changes. Control region provides a log where IMS writes. All the entries like pgm1 start, pgm2 start ,empadd delt are stored into log. Memory Disk Tape

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 36 of 90

IMS Class Room Session

When transaction is under execution, changes are put into memory. All requests go through control region. So that in case of failure control region undo the changes. Thats how control region keeps track of all database changes. Program should not directly talk to database. It should be thru control region. If program 2 fails control goes back to control region. It will look out for the changes in the log for program 2 and undo the changes. Therefore IMS provides atomicity to undo the changes. IMS talks to database on behalf of program Isolation is available by IRLM. At the time of IMS generation, select : 1. IMS Component Program Isolation Manager (In-built) or IRLM 2. DBRC Yes/No While testing your program in batch DL/I mode, DBRC is N. Because here you are working on dummy databases or copy of databases. You are not working on real databases. Therefore DBRC is not required over here. Here databases are used for the creation of test data. If anything fails you just have to reload the data & start again. Therefore DBRC is N here. In real application it must be Y.

IRLM

DBRC

DL/I

CR QMGR

IMS/DB

PGM1 PGM 2 PGM 3 MFS

Users

Above environment is a normal environment, which run during office time (9-6) You run batch program during off time i.e. after 6 pm. So during office time, control region will take charge of all the database. If you try to use any database for batch job, you wont get exclusive control over it since control region is having exclusive control on all the databases. Therefore you have to use this database for batch job after 6pm.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 37 of 90

IMS Class Room Session


But if online environment uses databases for 24 hours, when the batch job will run? -Needs to put this batch job into memory.

DL/I Memory MPP pgm1 MPP pgm2 MPP pgm3 MPP pgm4 BMP pgm1

CR Qmgr

In a queue all messages gets accumulated & then once in a day or so get processed by batch program. This wont have trans-id associated to any program. Control region wont schedule for this. There are two types of BMP:1. Transaction Oriented BMP 2. Batch Oriented BMP Process 1. 2. MPP: Immediately BMP-Transaction: Defer-Accumulate(accumulated into queue & processed by batch pgm)-Process When? 1 day, 1week, 1 month: depends on Business needs BMP-Batch: Accumulated by somebody-file Here events are captured by third party and given to us as files

3.

Databases are always in shared mode, therefore we have to use BMP.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 38 of 90

IMS Class Room Session


IBM Terminal IBM terminals are 3270 compliant. Attention identifiers for this terminal type are as follows: 1. Enter 2. PF1 to PF24 3. PA1 to PA3 4. CLEAR Attribute byte precedes every field on screen. NMDS: Native Mode Data stream format. Attributes, fields and extended data characteristics, positions etc. is given here. NMDS is understood by terminals & it displays the data on 3270 terminal format While sending NMDS = Mydata + Device Characteristics While receiving Mydata = NMDS Device Characteristics + the AID key pressed So if you see Device Characteristics in common in both the operations. Therefore it is good to use common utility which will work on terminal characteristics and Mydata. This process in IMS is done by MFS

Screen Definitions (Fields & attributes) MFS ABC Company Mydata Empno: Name :

Mydata + Aid Key

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 39 of 90

IMS Class Room Session


Day 8

Data + Format + Device Characteristics 24,80 : Terminal type (3270,2) Format: 1. 2. 3. 4. Position Attribute Initial Value Length

Terminal

Format, device characteristics and AID key pressed this information you should give to IMS. Application Programming Transaction Manual contains information about devices under 3270 category with full syntax.

Attributes: PROT UNPROT HI NORM NODISP MOD NOMOD ALPHA NUM

Note: 1. Keep all the fields on screen as ALPHA only. In a program you take care of numeric and decimal place etc. validation are done in program only. 2. After pressing AID key, terminal hardware will send back only modified fields. It keeps track of it by one bit in attribute byte, which is MOD or NOMOD. 3. CLEAR, PA1 to PA3 keys have special meaning for IMS. Data is not transmitted for these keys. Only IMS works on these keys.

Following is a EMPADD.MFS code:

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 40 of 90

IMS Class Room Session


PRINT NOGEN If you give 00C0, all the fields are cleared TITLE 'ADD EMP SCREEN' before sending the screen to the terminal. *********************************************************************** ADDEMP FMT DEV TYPE=(3270,2), X FEAT=IGNORE, X SYSMSG=MESG2, Only unprotected fields X DSCA='00A0', are cleared X PFK=(PFKFLD2,'01','02','03','04','05','06','07','08', X '09','10','11','12','13','14','15','16','17','18','19', X '20','21','22','23','24') DIV TYPE=INOUT DPAGE CURSOR=((8,35)), X FILL=PT DFLD 'SYNTEL EMPLOYEE SYSTEM', X POS=(2,21), X ATTR=(PROT,ALPHA,HI,NOMOD) DFLD '**********************', X POS=(3,21), X ATTR=(PROT,ALPHA,HI,NOMOD) DFLD 'ADD EMPLOYEE', X POS=(5,27), X ATTR=(PROT,ALPHA,HI,NOMOD) DFLD '------------', X POS=(6,27), X ATTR=(PROT,ALPHA,HI,NOMOD) DFLD 'EMP NO: ', X POS=(8,22), X ATTR=(PROT,ALPHA,HI,NOMOD) EMPNO DFLD POS=(8,35), X LTH=6, X ATTR=(UNPROT,ALPHA,NORM,MOD) DFLD 'EMP NAME: ', X POS=(10,22), X ATTR=(PROT,ALPHA,HI,NOMOD) EMPNAME DFLD POS=(10,35), X LTH=30, X ATTR=(UNPROT,ALPHA,NORM,MOD) DFLD 'EMP ADDRESS: ', X POS=(12,22), X ATTR=(PROT,ALPHA,HI,NOMOD) EMPADDR DFLD POS=(12,35), X LTH=40, X ATTR=(UNPROT,ALPHA,NORM,MOD) DFLD 'PF3 - BACK TO MENU ENTER - TO PROCESS', X POS=(22,21), X

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 41 of 90

IMS Class Room Session


ATTR(PROT,ALPHA,HI,NOMOD) POS=(23,2), LTH=79, ATTR=(PROT,ALPHA,HI,NOMOD)

MESG2

DFLD

X X

FMTEND * ADDI MSG

MFLD MFLD MFLD

MFLD

MFLD

MSGEND * ADDO MSG

TYPE=INPUT, SOR=(ADDEMP,IGNORE), NXT=ADDO SEG MFSTRN02', LTH=8 (PFKFLD2,'00'), LTH=2 EMPNO, LTH=6, JUST=R, FILL=C'0' EMPNAME, LTH=30, JUST=R, FILL=C' ' EMPADDR, LTH=40, JUST=R, FILL=C' '

X X ENTER key

X X X X X X X X X X X

SEG MFLD

MFLD

MFLD

MFLD MSGEND END

TYPE=OUTPUT, X SOR=(ADDEMP,IGNORE), X NXT=ADDI When ATTR=YES, length is increased by 2 bytes EMPNO, X LTH=8, X ATTR=YES EMPNAME, X LTH=32, X ATTR=YES EMPADDR, X LTH=42, X ATTR=YES ERRMSG, X LTH=79

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 42 of 90

IMS Class Room Session

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 43 of 90

IMS Class Room Session


COBOL Copy Book

01 INPUT-MSG. 05 INPUT-LL 05 INPUT-ZZ 05 INPUT-TRAN 05 INPUT-PFKEY 05 INPUT-NO 05 INPUT-NAME 05 INPUT-ADDR 01 OUTPUT-MSG. 05 OUTPUT-LL 05 OUTPUT-ZZ 05 OUTPUT-NO-ATTR 05 OUTPUT-NO 05 OUTPUT-NAME-ATTR 05 OUTPUT-NAME 05 OUTPUT-ADDR-ATTR 05 OUTPUT-ADDR 05 OUTPUT-MESG1-ATTR 05 OUTPUT-MESG1

PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC

S9(03) S9(03) X(08). X(02). X(06). X(30). X(40). S9(03) S9(03) X(02). X(06). X(02). X(30). X(02). X(40). X(02). X(79).

COMP. COMP.

COMP VALUE +165. COMP VALUE +0.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 44 of 90

IMS Class Room Session


Day 9

How DD statements for databases are given? Take DD names from DBDGEN & dataset names (physical names) from DBA. If you want to test the DL/I program, you allocate dataset for yourself, you cannot use production dataset. Populate the dataset from production dataset records. Find out database/dataset, psb-name naming standards. (I) Get the list of production database & corresponding datasets.(Take help of DBA or onsite person) (II) You want to test a program so you should know which datasets you are using. For this refer to PSBGEN for the program A. Get the dataset names B. Using list (II) datasets as model, allocate datasets for test. (Use File-Aid). So using this empty dataset will get allocated C. Load test data using A. MTD B. Select some data segments from the production dataset i.e. extract records from production using file-aid. But tests data? We dont know whether it covers all the conditions or not. If you modify this test data, then it should be updated elsewhere. It might be using secondary index etc. Therefore it is not a reliable method of creating test data. C. Rexx routine for test data. DD names & dataset names are given in test JCL.

STEPLIB DD points to IMS.RESLIB, which contains the IMS nucleus and required action modules. It must be authorized. PROCLIB DD points to IMS.PROCLIB, which contains all cataloged procedures and jobs for IMS. SYSUDUMP DD defines a dump data set. This DD statement is optional. The following DD Statements are optional, depending upon your particular requirements. DFSCTL DD contains the SETR and/or SETO statements to specify the processing options and ranges required at scheduling time. The SETO (SET Options) statement provides the ability to set the processing options to control the execution of HSSP. The SETR (SET Range) statement is used to restrict access to specified parts of a DEDB.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 45 of 90

IMS Class Room Session

DFSSTAT DD defines a data set describing DB call and buffering activity during an application's execution. The reports are written when the application terminates. If you are interested in receiving //DFSSTAT reports, include a //DFSSTAT DD statement in this procedure. An example of this statement follows: //DFSSTAT DD SYSOUT=A For more information on these reports, see IMS/ESA Database Administration Guide. IMS DD Add an IMS DD statement for IMS.PSBLIB, concatenated with IMS.DBDLIB, if GSAM databases are accessed by the batch application. The statements are: //IMS DD DSN=IMS.PSBLIB,DISP=SHR // DD DSN=IMS.DBDLIB,DISP=SHR The PSB for the batch application program must be contained in the IMS.PSBLIB, and the DBDs for the GSAM databases referenced by the PSB must be contained in the MS.DBDLIB. DFSESL DD When the SSM parameter is specified (or defaulted to by specification in the control region), the subsystem libraries, which must be APF authorized, must be available to this region. If JOBLIB/STEPLIB/LINKLIST concatenation is not authorized, you must use the DFSESL DD statement. For online IMS regions, the subsystem library or libraries must be concatenated after the library containing the IMS modules (usually IMS.RESLIB). When multiple subsystems are connected, additional subsystem data sets can be concatenated.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 46 of 90

IMS Class Room Session

Transaction Log Thru Control region DL/I CR

Database MPP Call No JCL No JCL MPP Database Call

BMP JCL

Here how you get the dataset names and ddnames? All the databases information is available with control region therefore the dd statements should be known to control region for BMP programs. We are not required to give ddnames & datasets names since they are available with IMS control region.

IMS program Execution

1. 2. 3. 4.

Log on to IMS region IBM screen will be in front of user Inform about Transaction-id of MENU program Screens EMPMENUI EMPMENUO EMPADDI EMPADDO EMPLISTI EMPLISTO

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 47 of 90

IMS Class Room Session

What will happen when following is typed in: 1. /FOR EMPMNUO

(III) MFSLIB IMS (II) /FOR EMPMNUO MFS (I) 1. 2. MENU ADD INQUIRY

2. EMPMNUO

Control Region Check for valid transaction id. Qmgr MFS / EMPMNUO Unknown Transid

3. EMPTRN01 Valid Transaction Id. LL, ZZ, EMPTRN01 (total 12 bytes) Message is created in queue with length 12, rest all will be spaces. Program associated with EMPTRN01 will be started by IMS and program will display a sreen.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 48 of 90

IMS Class Room Session

User (I) Transaction Id Queue LL ZZ

System

EMPTRN01 EMPPGM01

GET REQUEST 01 request (II) LL ------ 12 ZZ ------ 0 EMPTRN01 Menu Pf1: Add Pf2: Inquiry :

12 bytes

SEND MENU Screen (III)

If PF1 is Pressed

(IV)

LL ------ 14 ZZ ------ 0 EMPTRN01 01 LL ZZ

14 bytes

01

GET REQUEST 01 request (V) LL ------ 14 ZZ ------ 0 14 bytes EMPTRN01 01 (VI) Program validates key pressed if key is valid transfer control to respective program else display error message on screen

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 49 of 90

IMS Class Room Session


There are four major actions involved in this processing 1. 2. 3. 4. get request display screens transfer analyze MOVE ANALYZE TO NEXT-ACTION. PERFORM PROCESS-REQUEST THRU PROCESS-REQUEST-EXIT UNTIL EOT. PROCESS-REQUEST SECTION. IF NEXT-ACTION = ANALYZE PERFORM ANALYSIS THRU ANALYSIS-EXIT ELSE IF NEXT-ACTION = TRANSFER PERFORM TRANSFER THRU TRANSFER-EXIT ELSE IF NEXT-ACTION = REPLY-BACK PERFORM REPLY-BACK THRU REPLY-BACK-EXIT ELSE ERRRO (ABEND) ON PC GIVE DIVIDE 1 BY ZERO TO ABEND PROCESS-EXIT. EXIT. ANALYSIS SECTION. Check for LL field. IF LL-INPUT = 12 MOVE SPACES TO ERRMSG MOVE REPLY-BACK TO NEXT-ACTION GO TO ANALYSIS-EXIT. IF LL-INPUT = 14 IF invalid PF key MOVE INVALID KEY TO ERRMSG MOVE REPLY BACK TO NEXT-ACTION GO TO ANALYSIS-EXIT. IF PFKFLD = 01 MOVE EMPADD TO WS-PGM-NAME ELSE IF PFKFLD = 02 MOVE EMPLIST TO WS-PGM-NAME ELSE MOVE TRANSFER TO NEXT-ACTION. ANALYSIS-EXIT.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 50 of 90

IMS Class Room Session


EXIT. Get Unique Call

Call

CBLTDLI

GU IO-PCB INPUT-MSG-AREA.

All system service call works with IO-PCB If IO-STATUS-CODE-PCB = QC Move y to no-more-mesg Else If IO-STATUS-CODE-PCB NOT = QC AND NOT = SPACES CALL error routine End-if End-if

Call

CBLTDLI

ISRT IO-PCB OUTPUT-MSG-AREA.

Check for blank status code. Move y to end-of-transaction.

IO-PCB 01 IO-PCB. 05 IOPCB-LTERM PIC 05 FILLER PIC 05 IOPCB-STATUS-CODE PIC 05 IOPCB-JULIAN-DATE PIC 05 IOPCB-TIME-OF-DAY PIC 05 IOPCB-MSG-SEQ PIC 05 IOPCB-MOD-NAME PIC 05 IOPCB-USER-ID PIC Alternate PCB 01 TRANSFER-PCB. 05 TRANSFER-LTERM PIC X(08). 05 FILLER PIC X(02). 05 TRANSFER-STATUS-CODE PIC X(02). Developed By: Shilpa Keluskar & Suvarnalata Naik

X(08). X(02). X(02). S9(07) COMP-3. S9(07) COMP-3. S9(07) COMP. X(08). X(08).

Page 51 of 90

IMS Class Room Session

PSBs should have a PCBs in the following order: 1. 2. 3. 4. IO-PCB ALTERNATE-PCBs DB-PCBs GSAM-PCBs

An Online programs get IO-PCB automatically. Therefore BMP programs will get IO-PCB automatically. Note: For Realia, in .ACB file add following statement: PCB TYPE=TP,MODIFY=YES PSBGEN NAME=

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 52 of 90

IMS Class Room Session


Day 10 Secondary Index When DBA designs the databases they design them on the basis of certain application needs. They will come up with the segments, fields, key fields & the structure of the database. However the designed structure may not be suitable for all applications. One may need to view the data using different view. Secondary indexing enables the application to design their own data structure. Secondary indexing is a solution to the different processing requirements of various applications. It allows you to have an index based on any field in the database, and not just the key field in the root segment. Secondary indexes can be used with HISAM, HDAM, and HIDAM databases. A secondary index is in its own separate database and must use VSAM as its access method. Because a secondary index is in its own database, it can be processed as a separate database. Secondary indexes are invisible to the application program. When an application program needs to do processing using the secondary index, this fact is communicated to IMS by coding the PROCSEQ= parameter in the PCB. If an application program needs to do processing using the regular processing sequence, PROCSEQ= is simply not coded. If the application program needs to do processing using both the regular processing sequence and the secondary index, the application program's PSB must contain two PCBs, one with PROCSEQ= coded and one without. When two PCBs are used, it enables an application program to use two paths into the database and two sequence fields. One path and sequence field is provided by the regular processing sequence, and one is provided by the secondary index. The secondary index gives an application program both an alternative way to enter the database and an alternative way to sequentially process database records. A final characteristic of secondary indexes is that there can be 32 secondary indexes for a segment type and a total of 1000 secondary indexes for a single database.

Concatenated Key: Used in HISAM, HDAM, HIDAM. Pointer is a number, which is used to reference a particular segment. To get employee information for particular skill then you will use empno and skillid as a concatenated key. If concatenated key is used as pointer then all the keys involved in that concatenated key must be unique. RBA: Another way of locating segment. Can be used in HDAM and HIDAM. For HISAM use Concatenated Key. In HISAM RBA is not fix. It changes as new split takes place in control interval therefore RBA value changes accordingly therefore in HISAM you cannot use RBA to locate a segment. Whereas in HIDAM, the RBA remains unchanged.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 53 of 90

IMS Class Room Session

IMS Terminology Symbolic (Concatenated Key). Direct (RBA). This is more efficient but has restriction of not being used for HISAM. GU EMP (ENAME EQ ABC) All search fields can also be used to qualify a segment but here performance as compared to sequence field will be lowered, because it will scan all the root segment occurrences till it finds ename ABC. Search field cannot be used to produce a list in ascending order of the search field. In VSAM the solution for this is Alternate Indexes. So we need to define another index on NAME. In IMS it is referred as Secondary Index. If there are more employee with same name! IMS resolves this problem by introducing another ESDS file. So Secondary index is KSDS plus ESDS file.

NAME

PTR

2 3

All other pointers pointing to that name.

In IMS all things are in terms of database therefore you need to define secondary index database. Index database will be a root only database, which contains search field and pointer NAME PTR

If search field is not unique, another dataset gets added to this database and together this is your secondary index database.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 54 of 90

IMS Class Room Session

Database KSDS NAME PTR First Match ESDS PTR PTR PTR .. Second Match and so on

Here there is delay in access therefore IMS does not recommend to keep secondary index as nonunique. Which is not practical. IMS provides some mechanism for making Index key unique. 1. Indexed field can be made of (up to) 5 fields in any order i.e. index can be built on combination of multiple fields. 2. You can add upto 5 fields as sub-sequence fields. But IMS will look for main index field only. Even programmers will see just NAME field only. Sub-sequence fields are not visible to program. IMS uses them to make key unique and avoid overhead of ESDS. For IMS NAME Sub-seq-field PTR

For programmer

Here duplicates are not avoided but now they are stored into one dataset therefore reduced overhead. As a programmer you dont have access to sub-sequence field. Programmer has to take care of duplicates. 3. Inspite of using subsequence field, you cannot guarantee to make key unique, So IMS uses system related field: /SX (direct Pointer) and /CK (Concatenated Key) /SX: IMS uses index field and RBA (HDAM,HIDAM) /CK: IMS uses index field and concatenated field (HISAM, HDAM, HIDAM)

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 55 of 90

IMS Class Room Session

Some Terminology in Secondary Indexes:

Target Segment: One, which is retrieved using secondary index. Source Segment: One, which supplies values for secondary index. Pointer Segment: One, which stores supplied key value and pointers to target segment. For example: Secondary Index: ENAME Source Segment: EMPSEG Target Segment: EMPSEG Pointer Segment: Index database segment Target and source segment need not be same. If we want to build secondary index on skill then create skill-id secondary index. Here again many employees will have same skill-id. If used /CK Secondary Index: SKILLID Source Segment: SKL Target Segment: EMPSEG Pointer Segment: Index database segment, which is rootonly

Skill-id

CK PTR

To employee

Will be of SKL segment empid + sklid

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 56 of 90

IMS Class Room Session


Assignment: Secondary Index: Name
PRINT NOGEN DBD NAME=EMP-DBD,ACCESS=(HISAM,ISAM) DATASET DD1=PRIME,OVFLW=OVERFLOW,DEVICE=3350 SEGM NAME=EMP,PARENT=0,BYTES=76 FIELD NAME=(EMPNO,SEQ,U)BYTES=6,START=1,TYPE=C FIELD NAME=EMPNAME,BYTES=30,START=7,TYPE=C FIELD NAME=EMPADR,BYTES=40,START=37,TYPE=C FIELD NAME=/CK1,BYTES=6 LCHILD NAME=(NAMESEG,NAMEDBD),POINTER=INDEX XDFLD NAME=XNAME,SEGMENT=EMP,SRCH=EMPNAME,SUBSEQ=/CK1 SEGM NAME=PAYROLL,PARENT=EMP,BYTES=12 FIELD NAME=(PRYYYYMM,SEQ,U),BYTES=6,START=1,TYPE=C FIELD NAME=PAYAMT,BYTES=6,START=7,TYPE=C SEGM NAME=SKILL,PARENT=EMP,BYTES=35 FIELD NAME=(SKILLID,SEQ,U),BYTES=3,START=1,TYPE=C FIELD NAME=SKILLNAME,BYTES=30,START=4,TYPE=C FIELD NAME=EXPYRS,BYTES=2,START=34,TYPE=C DBDGEN FINISH DBD NAME=NAMEDBD,ACCESS=(HISAM,ISAM) Name DATASET DD1=PRIME,OVFLW=OVERFLOW,DEVICE=3350 Name=30,No.=6 SEGM NAME=NAMESEG,PARENT=0,BYTES=36 If /SX then bytes=34, 30+4 FIELD NAME=(SECNAME,SEQ,U),BYTES=36,START=1,TYPE=C LCHILD NAME=(EMP,EMP-DBD),INDEX=XNAME,POINTER=SNGL RBA DBDGEN FINISH END

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 57 of 90

IMS Class Room Session


Secondary Index: Name, Skill-Name
PRINT NOGEN DBD NAME=EMP-DBD,ACCESS=(HISAM,ISAM) DATASET DD1=PRIME,OVFLW=OVERFLOW,DEVICE=3350 SEGM NAME=EMP,PARENT=0,BYTES=76 FIELD NAME=(EMPNO,SEQ,U)BYTES=6,START=1,TYPE=C FIELD NAME=EMPNAME,BYTES=30,START=7,TYPE=C FIELD NAME=EMPADR,BYTES=40,START=37,TYPE=C FIELD NAME=/CK1,BYTES=6 FIELD NAME=/CK2,BYTES=9,START=1 LCHILD NAME=(NAMESEG,NAMEDBD),POINTER=INDEX XDFLD NAME=XNAME,SEGMENT=EMP,SRCH=EMPNAME,SUBSEQ=/CK1 LCHILD NAME=(SKILLSEG,SKILLDBD),POINTER=INDEX XDFLD NAME=XSKILL,SEGMENT=SKILL,SRCH=SKILLNAME,SUBSEQ=/CK2 SEGM NAME=PAYROLL,PARENT=EMP,BYTES=12 FIELD NAME=(PRYYYYMM,SEQ,U),BYTES=6,START=1,TYPE=C FIELD NAME=PAYAMT,BYTES=6,START=7,TYPE=C SEGM NAME=SKILL,PARENT=EMP,BYTES=35 FIELD NAME=(SKILLID,SEQ,U),BYTES=3,START=1,TYPE=C FIELD NAME=SKILLNAME,BYTES=30,START=4,TYPE=C FIELD NAME=EXPYRS,BYTES=2,START=34,TYPE=C DBDGEN FINISH DBD NAME=SKILLDBD,ACCESS=(HISAM,ISAM) DATASET DD1=PRIME,OVFLW=OVERFLOW,DEVICE=3350 SEGM NAME=SKILLSEG,PARENT=0,BYTES=39 FIELD NAME=(SECSKILL,SEQ,U),BYTES=39,START=1,TYPE=C LCHILD NAME=(SKILL,EMP-DBD),INDEX=XSKILL,POINTER=SNGL DBDGEN FINISH END

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 58 of 90

IMS Class Room Session


How to inform IMS about Secondary Index? LCHILD XDFLD

LCHILD establishes relationship between segments of two physically separate databases. LCHILD statement comes under target segment and it should be immediately followed by XDFLD statement.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 59 of 90

IMS Class Room Session


Day 11 Summary: 1. Secondary Index: Order other than segments sequence field. 2. Need to have a separate database (Index database). This will only have root only segment.

Source

Target Pointer

On which index is required

From any source segment, you can select 1 to 5 fields. 3. Identify 1. 2. 3.

Source Segment Target Segment Pointer (You have to build this segment. It is a separate database)

If EMPNAME is a secondary index: Source Segment: EMPSEG Target Segment: EMPSEG If SKILL-ID is a secondary index: Source Segment: SKLSEG Target Segment: EMPSEG 4. LCHILD & XDFLD statements are to be coded under target segment.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 60 of 90

IMS Class Room Session

5. If duplicates names are present then IMS requires another ESDS dataset to store those pointers. KSDS ESDS ABC 007 015 029 035 045

This requires high overhead. So the solution for this is use to Sub Sequence field. Pick up some value from same segment and put it in KSDS dataset. But still index will be on NAME. But now NAME + field is unique. Programmer will still refer to NAME, but IMS builds the index on NAME + field. So for IMS duplicates are not there. 6. Sometimes there wont be any field which makes index unique then IMS gives other option of /CK and /SX (these are system related fields) FIELD NAME=/CK1 START=1 BYTES=6 XDFLD .SUBSEQ=/CK1

Refers to concatenated key. Here it is EMPNO so 6 characters. This field is not stored as a part of your segment. This field is stored in Index database. /SX requires 4 bytes because it works with RBA. This is used with HDAM and HIDAM but not HISAM. Whereas use /CK with all. FIELD NAME=/SX1 START=1 (here BYTES are not required since it is always 4 bytes) 7. If Indexed database is HISAM then in Index database POINTER must be SYMBOLIC 8. If Indexed database is HIDAM then in Index database POINTER may be SYMBOLIC or SNGLE 9. How to make use of this Index?

Normal Way of Access (EMPNO) PSB PCB TYPE =DB, NAME=EMPDBD,PROCOPT=A SEGM SEGM PSBGEN PSBNAME=.., LANGUAGE=.

Using Secondary Index (EMPNAME) PSB PCB TYPE =DB, NAME=EMPDBD, PROCOPT=A, PROCSEQ=NAMEDBD SEGM SEGM PSBGEN PSBNAME=.., LANGUAGE=.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 61 of 90

IMS Class Room Session

10. You can code n number of PCB depending on your access requirement 11. Use INDICES to access database in normal sequence and faster access to segments. How the Secondary Index Is Maintained When a source segment is inserted, deleted, or replaced in the database, IMS keeps the index current. IMS does this whether or not the application program performing the update uses the secondary index. The way in which IMS maintains the index depends on the operation being performed. Regardless of the operation, IMS always begins index maintenance by building a pointer segment from information in the source segment that is being inserted, deleted, or replaced. (This pointer segment is built but not yet put in the secondary index database.) When a source segment is inserted, DL/I determines whether the pointer segment needs to be suppressed. If the pointer segment needs to be suppressed, it is not put in the secondary index. If the pointer segment does not need to be suppressed, it is put in the secondary index. When a source segment is deleted, IMS determines whether the pointer segment is one that was suppressed. If so, IMS does not do any index maintenance. If the segment is one that was suppressed, there should not be a corresponding pointer segment in the index to delete. If the pointer segment is not one that was suppressed, IMS finds the matching pointer segment in the index and deletes it. Unless the segment contains a pointer to the ESDS data set, which can occur with a non-unique secondary index, the logical record containing the deleted pointer segment in a KSDS data set is erased. When a source segment is replaced, the pointer segment in the index might or might not be affected. The pointer segment in the index might need to be replaced, or it might need to be deleted. After replacement or deletion, a new pointer segment is inserted. On the other hand, the pointer segment might need no changes. IMS determines what needs to be done by comparing the pointer segment it built (the new one) with the matching pointer segment in the secondary index (the old one). If both the new and the old pointer segments need to be suppressed, IMS does not do anything (no pointer segment exists in the index). If the new pointer segment needs to be suppressed but the old one does not, then the old pointer segment is deleted from the index. If the new pointer segment does not need to be suppressed but the old pointer segment is suppressed, then the new pointer segment is inserted into the secondary index.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 62 of 90

IMS Class Room Session

If neither the new or the old segment needs to be suppressed and: If there is no change to the old pointer segment, IMS does not do anything.

If the nonkey data portion in the new pointer segment is different from the old one, the old pointer segment is replaced. User data in the index pointer segment is preserved when the pointer segment is replaced.

If the key portion in the new pointer segment is different from the old one, the old pointer segment is deleted and the new pointer segment is inserted. User data is not preserved when the index pointer segment is deleted and a new one inserted.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 63 of 90

IMS Class Room Session

IMS/DC Transfer Control to other program To transfer control to another program use: Alternate PCB CHNG Call ISRT Call PCB TYPE=TP, MODIFY=YES 1. Set alternate PCB to required destination i.e. transaction code of the program. 2. Insert a message using alternate PCB. 1 1 WS-DEST PIC X(08). SWT-MSG. 05 SWT-LL 05 SWT-ZZ 05 FILLER PIC S9(03) COMP VALUE +5. PIC S9(03) COMP VALUE ZEROS. PIC X VALUE HIGH-VALUES.

(Message length cannot be less than 5 characters)

TRANSFER SECTION. MOVE MFSTRN02 TO WS-DEST. CALL CBLTDLI USING DLI-CHNG ALT-PCB WS-DEST. Alternate PCB is generated by IMS to change the content of this area. We are suppose to use this call. You cannot directly assign value to Alternate-LTERM field of alternate PCB to MFSTRN02 Then you issue, CALL CBLTDLI USING DLI-ISRT ALT-PCB SWT-MSG This message is just for syntax completion

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 64 of 90

IMS Class Room Session

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 65 of 90

IMS Class Room Session


normally CLEAR key is used to return control back to IMS therefore programmatically you need not return to IMS (In Menu program). Tips: 1. Use CLEAR key for non-conversational programs 2. Conversational program can return control back to IMS programmatically.

Program 1 1. EMPTRN01 (Defined in realims.ims)

LL 2 12

ZZ 2

EMPTRN01 8

Program will receive this message now you are suppose to send MENU screen 2. /FOR EMPMENUO

LL 2

ZZ 2

EMPTRN01 8

XX 2

14

So Menu Program will receive 2 types of messages. One will be 12 bytes length and other will be 14 bytes length

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 66 of 90

IMS Class Room Session


Program 2

1. EMPTRN02 2. /FOR EMPADDO

Must be rejected

It will receive 5 bytes length message from MENU program Send Add Screen, user will add data and will press specified AID key to save data. Program will receive input message of 96 characters. LL 2 ZZ 2 EMPTRN02 8 XX 2 NO 6 NAME ADDR 30 40

So this program deals with 2 messages, 5 characters and 96 characters

Program 3 Program 1 will transfer 5 bytes to program 3. Take first five employees into working storage then reply back. If PF7 is pressed:

LL 2

ZZ 2

EMPTRN03 8

XX 2

Which indicates program 3 to program 3, 14 bytes get transferred

How to get last employee number of previous screen to display next five records? There are two possibilities: 1. LL 2 ZZ 2 EMPTRN03 8 08 2 EMPNO 6

2. Store employee-number some where before reply back. Then afterwards corelate with terminal user and use it.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 67 of 90

IMS Class Room Session

So, 1. Create one database (HDAM) which will be root only

LTERM

EMPNO

2. Create one field on screen, keep it as hidden field, store start and stop values to it.

LL

ZZ

EMPTRN03

08

0001

0005

Note : Creation of list on screen DO 5 DFLD : : END 3. Store this in memory (Like commarea in CICS)

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 68 of 90

IMS Class Room Session


Day 12 Cursor positioning and Dynamic Attribute Modification You can change the attributes of any field before sending it to user. This can be done dynamically in the program as per the requirement. Otherwise the original attributes will be in effect. The attribute setting and cursor positioning is done using 2 bytes attribute field. Dynamic Cursor Positioning:0 1 2 3 4 5 6 7

Bits 0 and 1 are use for cursor positioning: 00 : Positioning not required 11 : Position cursor on this field

Bits 2 to 7 are always zeros. 000000000 : x 00 110000000 : x C0 So if validation of field fails Move C0 to attribute byte of the field to position cursor on that field.

Dynamic Attribute Setting:-

Bit 0 : Always 1 Bit 1 : 0 or 1 (use always 1) Bit 2 : Protection Attribute. 0-Unprotected, 1-Protected Bit 3 : Shift Attribute. 0-Alphanumeric Shift, 1-Numeric Shift Bit 4 and 5 : Intensity Attribute. 00-Normal, 01-No Display, 10-Bright, 11-Bright Bit 6 : Light Pen Detection. Should always be zeros Bit 7 : Modified data tag. 0-MDF OFF, 1-MDT ON

For example: To position the cursor on field and making it bright 0 1 1 1 2 0 3 0 4 0 5 0 6 0 7 0 0 1 1 1 2 0 3 0 4 1 5 1 6 0 7 1

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 69 of 90

IMS Class Room Session


X C 0 Output message format: X C D

01 OUTPUT-MSG. 05 LL 05 ZZ . 05 ATTR1A PIC X(01). 05 ATTR1B PIC X(01). 05 FIELD1 PIC X(-). 05 ATTR2A PIC X(01). 05 ATTR2B PIC X(01). 05 FIELD2 PIC X(-). : MOVE XC0 TO ATTR1A. MOVE XCD TO ATTR1B. Alternate PCB

There are two types of Alternate PCB 1. Modifiable PCB TYPE=TP, MODIFY=YES Alternate PCBs are also used to send messages to other terminals (for business needs) For such case use this type. And issue 1. CALL CHNG LTERM01 2. CALL ISRT 3. Use PURG call. This will force the message to go to that terminal 2. Fixed PCB TYPE=TP, LTERM=EMPTRN02 PCB TYPE=TP, LTERM=EMPTRN03

Here there is no need of CHNG call because destination is already specified.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 70 of 90

IMS Class Room Session


Some Important Points: 1. DL/I call gets translated to VSAM dataset internally 2. HDAM requires 1 ESDS file. (IMS0.PROD.EMPDB) 3. Program is accessing EMPDBD

CALL CBLTDLI USING DLI-REPL DB-PCB SEG-AREA SSA

This call goes to control region. Database is known by Db-PCB. In this DBD mention DATASET = DDNAME In a startup JCL you specify the dd statement for DL/I database. This is the way of IMS to inform control region about datasets. Whatever is running under IMS/DC, does not require any DD statement that is how all online programs, which are MPP, accesses databases. Also for BMP programs DD names are not required.

4. Instead of allocating all the datasets in advance which increases the overhead of system, another way is: DFSMDA macro statements: Dynamic allocation on demand DFSMDA DD..EMPDB..DSN=. : : : For 300 databases , youll get 300 DFSMDA members. When they are translated they are kept into one library. This library must be concatenated to your RESLIB. Initially database is not allocated. When program starts execution and it makes call to that database, IMS looks it into this library and allocates space. For each database there will be a separate PDS member. Which will have DD and dataset name. 5. Why we run programs in BMP? We cannot give exclusive control to database. We want other programs to share the database therefore in production most of the programs are BMP programs. If they are DL/I they must run during nighttime, when online system is off. In DL/I , data sharing in not available. You r job is directly running under MVS, gains exclusive control on databases.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 71 of 90

IMS Class Room Session

6. Concurrency: Many users using databases simultaneously -ACID property of transaction 7. MPP online programs: Each message is a transaction. When program fetches next message, previous transaction is completed and resources are released. In a shared system it is necessary to release a lock as soon as possible Online transaction should not take long time

8. BMP Batch programs: IMS assumes Start of the program and End of the program as one transaction. If you are updating payroll at end of month, which is a BMP transaction. So until this program finishes, all the involved segments will not be available which is not a welcome situation therefore some mechanism, which should release the resources in between (otherwise data wont be available to other program, might get 777error) since batch program is holding those resources. To resolve this, some position in between is required. There are 2 types of breaks: a. Break it by time b. Break it by number of input records processed The way to break is use of Checkpoint call. IMS provides this facility. Whatever is locked up to that checkpoint call is released for other programs to use.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 72 of 90

IMS Class Room Session


Day 13 Frequent Checkpoints 1. Concurrent Usage Of Data

How to find out whether any other concurrent user is using that resource or a segment? Make use of Log (System Log) Analyze PSB, how many programs are using the database you are going to update. If you found that P1, P7, P56, P35 programs also uses the databases you are using, next find out The usage or frequency of the program going to run. If they are running frequently then you have to give frequent checkpoints. If the frequency is low, you may not give checkpoints after every transaction

2. Determine frequency (Not for AMEX) 3. ARC: Application Restart Control. Its a utility to dynamically change the checkpoints. 4. Checkpoint after every transaction.

Another reason for checkpoint: 1. Restart: If program abends, you should start from the transaction, which was not committed. 2. Recovery: If disk drive fails, then you have a database backup, take log dataset, from log get the updates and update the backed up database and bring it to current position where the failure occurred. Therefore take image copy of every database daily, hourly, weekly etc. So that you can take a latest copy of it and then apply all the changes from log for that database to the image copy. This is forward recovery. Now you have to restart the program from the point where the ABEND occurred in the last execution. How program will decide from which point to start? (for example in the previous execution 399000 records were processed so now it should start from 400000th record) Every checkpoint will have checkpoint identifier. How to get unique Checkpoint-id? First time run a normal run without ABEND. You will get JES message for last transaction, which will have some message number. From where you will get checkpoint id? (JOBLOG) JES

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 73 of 90

IMS Class Room Session


Store other details when you are taking checkpoint You need to store variables, which were changed in the last execution during last checkpoint. After restart, you need to supply this detail along with checkpoint-id. Also store key information along with checkpoint-id. For files you should have number of records read during last execution. I.e. count of number of records processed, So with this count you can restart from next record in a file (Input file)

1.

When you are running program as a BMP, if ABEND occurs then IMS backs out the changes you have made up to the previous checkpoint. 2. When you are running program as a DL/I, this does not happens automatically, you have to backed out using some utility(Batch Backout Utility). You have to give the checkpoint-id to which you want to backed out for restart. (options in JCL)

LOG IMS/DC uses OLDS (Online Log dataset). It contains system related information and database (IMS) related information. It is implemented in 3 stages: 1. Memory Buffer 2. Disk Dataset (there are 3 identical datasets. When this gets full, it is moved on to Tape) 3. Tape Memory buffer and disk datasets are WADS (Write Ahead Datasets, smaller size, faster devices) DBRC software reads OLDS from Tape Again Tape is divided into 2 types 1. System Log dataset (SLDS) 2. Database recovery Log (RLDS) In addition to OLDS, IMS also maintains RDS(Restart Dataset). This is nothing but IMS checkpoints to restart IMS in case of IMS failure. These are not our program checkpoints.

777 Abend-deadlock abend. From system log take print of x67 report to know which other concurrent programs are using database the one which your program is using Checkpoint frequency needs to be increased

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 74 of 90

IMS Class Room Session


Checkpoint Identifier It is of 8 characters in IMS. First 4 characters will be program-id. Last 4 characters will be a number

First 4 characters will be program id: F350 or F355 Last 4 characters will be number up to 9999 But in this case if 9999 limit is reached it resets to zero. So here now 2 records can have duplicate checkpoint. Then which one will IMS use the first one or last one? So for this also include time-stamp information into checkpoint-id. Format for which is: IIDDDHHMMDSSST II: Region Id DDDHHMMDSSST: Actual time in days, hours, minutes, seconds, and 10th of second. Or IMS checks log backward, so always it will take the latest one.

IMS takes care of IMS databases only. IMS Log will not support anything, which is not IMS supported.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 75 of 90

IMS Class Room Session

GSAM Files IMS cannot handle other sequential file for recovery. That is IMS does not support other files checkpoint. COBOL support for checkpoint is RERUN clause in SELECT statement. MVS provides checkpoint facility for all files. Therefore sequential file have to use MVS checkpoints. And IMS files will use IMS checkpoints. Both need to be identified by one single checkpoint mechanism. So how to resolve this? Some how we need to make sequential file as IMS database. So here sequential file is wrapped as database. Now IMS will understand this sequential file as a IMS database. This type of database is known as GSAM (Generalized Sequential Access Method) database. It is a wrapper for your input or output sequential file

If you take directly sequential file, as it is then you will not able to use IMS checkpoints therefore convert this file to GSAM database. Now IMS will work on it. This file will be treated as an IMS database

DBD definition DBD NAME=TRANDBD, ACCESS=(GSAM,BSAM) DATASET DD1=TRANIN, RECFM=F, RECORD=70 DBDGEN FINISH END

PSB definition PCB TYPE=DB,NAME=EMPDBD PCB TYPE=GSAM,NAME=TRANDBD PSBGEN END

GSAM database cannot be used by MPP programs GSAM database can only be processed by BMP and DL/I programs

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 76 of 90

IMS Class Room Session


Day 14

Four possible values given to GSAM: Access L G LS Meaning Load Get Load Sequential. For every write disk IO wont take place. Records get stored into buffer. When buffer gets full, records are written to dataset Get Sequential. While reading data, group of records gets written into buffer. Whenever user asks for particular record, it is given from buffer. Remark Write to database Read database Write to database. AMEX standard. Used to improve performance by reducing IO time.

GS

Read database. AMEX standard. Used to improve performance by reducing IO time.

Reading GSAM in Random Mode Using Record Search Argument, you can read the GSAM file randomly. Record Search Argument (RSA): Record Search Argument is made up of two fields: 01 GSAM-RSA. 05 WORD1 05 WORD2

PIC S9(05) COMP. PIC S9(05) COMP.

Declare this area in working storage of the program. When this area is specified with GN call. Address associated with record gets store in this area(RSA). Like this you can get all the records address. Create an array for storing all RSA values. Then in the same program you can read record randomly using RSA. Simple GN call: (Here you wont get RSA information) CALL CBLTDLI USING DLI-GN GSAM-PCB IO-AREA

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 77 of 90

IMS Class Room Session

Variation On GN call: CALL CBLTDLI USING DLI-GN GSAM-PCB IO-AREA GSAM-RSA Here you will get the value associated with record. This will be a identifier for that record. You can create an array of all RSA values 01 RSA-TABLE. 05 GSAM-RSA OCCURS 200 TIMES. : :

In the same program now you can read GSAM file randomly by issuing GU call: CALL CBLTDLI USING DLI-GU GSAM-PCB IO-AREA GSAM-RSA You can use GSAM-RSA with ISRT call. This is optional. When record gets written, GSAMRSA will have some value, Which you can use to retrieve the same record. Two special calls used with GSAM GSAM databases are opened IMS or you can open explicitly by issuing following calls:

CALL CBLTDLI USING DLI-OPEN GSAM-PCB

CALL CBLTDLI USING DLI-CLSE GSAM-PCB

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 78 of 90

IMS Class Room Session


Scratch Pad Area (SPA): Hidden field, which is used to store page number and Start, Stop value may not be sufficient in case if the number of pages increases. So the solution is create HDAM database, which will be root-only to store page number, start-key and stop-key value. Before sending employee listing to user store all these details in this database. All user of this program will use the same HDAM database therefore make LTERM-ID as a part of its record. So now HDAM database record segment will be: LTERM PAGE START-KEY END-KEY

When PF3 key is pressed from your terminal, i.e. go back to MENU, delete the record associated with your LTERM-ID. When user and program are interacting with each other, 79 character hidden field or HDAM database can be used. Another way is Scratch Pad Area (SPA) size: 32760 bytes: This area is used when programs interact with each other and they need to pass data to each other. Scratch Pad Area: IMS facility for session management used between programs. Also in single program. Definition of SPA should be such that it should take care of all communication iterations.

Pgm1

Pgm2

Pgm3

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 79 of 90

IMS Class Room Session

Program Pgm1 Pgm2 Pgm3

Called By Transaction Id Transaction Id + details Pgm1 Pgm1

Calls Pgm2, Pgm3 Pgm1 Pgm1

Program2 and Program3 should not be allowed to start by typing transaction-id of the program. To keep track of this you should store called programs transaction id. This is a general requirement. In addition for program 3 you need to save page details and then at top you need to add IMS related fields. So SPA declaration will look like this: 01 SPA-AREA. 05 SPA-LL PIC S9(04) COMP. 05 SPA-ZZ1 PIC S9(04) COMP. 05 SPA-ZZ2 PIC S9(04) COMP. 05 SPA-TRANSACTION-CODE PIC X(08). 05 WORK-AREA. 10 CALLING-PGM PIC X(08). 05 PGM3-SAVE. 10 SCROLL-INFO OCCURS 5 TIMES. 15 SCROLL-PAGE PIC 9(01). 15 SCROLL-START PIC X(06). 15 SCROLL-END PIC X(06). 05 FILLER PIC X(13). All the 3 programs are going to use this 100 bytes SPA area. Reading SPA: First GU call will retrieve the SPA followed by GN call, which retrieves the message. CALL CBLTDLI DLI-GU IO-PCB SPA-AREA When nothing is send, you will get QC status code. So check for this status code. After this issue following to retrieve messages. This will be in loop until end-of-message which is status code QD CALL CBLTDLI DLI-GN IO-PCB MSG-AREA

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 80 of 90

IMS Class Room Session

Writing SPA:

CALL CBLTDLI USING DLI-ISRT IO-PCB SPA-AREA. CALL CBLTDLI USING DLI-ISRT IO-PCB OUTPUT-MESG.

Transferring control:

CALL CBLTDLI USING DLI-CHNG ALT-PCB WS-DEST CALL CBLIDLI USING DLI-ISRT ALT-PCB SPA-AREA CALL CBLTDLI USING DLI-ISRT ALT-PCB SWT-MSG

Mandatory

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 81 of 90

IMS Class Room Session

How SPA Works?

Menu MENU PF1: ADD PF2: LIST CLEAR:EXIT

Employee Addition ADD EMP NO.: NAME: ADDR: PF3 TO MENU

Employee Listing EMP LIST NO NAME ADDR ----- --------- ----------- --------- -------PF7-UP PF8-DOWN PF3-MENU

Pgm:Pgm001 Trans-id:EMPRN01

Pgm:Pgm002 Trans-id:EMPTRN02

Pgm:Pgm003 Trans-id:EMPTRN03

User must start this system with MENU 1. By typing transaction id EMPTRN01 2. /FOR MENUO If user starts with /FOR ADDO, then how to stop user to start pgm002 directly?

Solution 1: (By using switch message) Check for message length. If it is 5, its a valid start. But how to check for calling program name so modified swt-msg will be: LL ZZ TRANSACTION ID PFKEY

Transaction id of the calling program Create one blank field on ADD screen. When pgm001 starts pgm002 store calling programs transaction code into this dark field. So now pgm002 can check for transaction code of pgm001 in this dark field to check for a valid start. If pgm002 is start by typing /FOR ADDO then this field will be blank. Like this you can check for the correct start of the program

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 82 of 90

IMS Class Room Session


Solution 2: (By using VSAM dataset) VSAM ksds dataset will have following fields: 1. Unique LTERM 2. Calling programs transaction id

EMPTRN01 LLZZEMPTRN01 (12 bytes message) : : :

MENU

From IO-PCB get the LTERM and look into VSAM dataset. First time you wont find it so write it into the dataset. Display blank MENU screen. Now control goes to MENU program. User enters 1st option so control goes to pgm002. Before transferring control to pgm002 change the calling programs transaction code to EMPTRN01 in VSAM dataset. So now pgm002 can check for this transaction code to see whether its a valid start or not. Same for the LIST program.

Menu Program: GET-MSSAGE. GET-FROM-VSAM. GET-MSG. REPLY-BACK. REPL-ISRT-VSAM ISRT-MSG TRANSFER REPL-INTO-VSAM ISRT-ALT-DEST

Solution 3: All these things can be provided by Scratch Pad Area, facility provided by IMS. Our requirement of storage For MNEU and ADD program: 8 bytes For LIST program: 8 bytes + 100 bytes In addition 14 bytes will be for: SPA-LL SPA-ZZ1 SPA- ZZ2 SPA-TRAN

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 83 of 90

IMS Class Room Session


2 2 2 8

01 SPA-AREA. 05 SPA-LL PIC S9(04) COMP. 05 SPA-ZZ1 PIC S9(04) COMP. 05 SPA-ZZ2 PIC S9(04) COMP. 05 SPA-TRANSACTION-CODE PIC X(08). 05 WORK-AREA. 10 CALLING-PGM PIC X(08). 05 PGM3-SAVE. 10 SCROLL-INFO OCCURS 5 TIMES. 15 SCROLL-PAGE PIC 9(01). 15 SCROLL-START PIC X(06). 15 SCROLL-END PIC X(06). 05 FILLER PIC X(13).

For IMS. You should not Change this area.

Each terminal will have a SPA.

EMPTRN01

The content of this SPA will be all binary zeros. IMS looks at your message first since it is for the first time IMS creates this area, puts transaction-id over here. Calling program will be blank. Which is acceptable condition since it is a starting program. Make it as a EMPTRN01. Suppose it is not a binary zeros that indicates pgm002 or pgm003 must have called the MENU program. So all these are valid values for pgm001 to start Program Pgm001 Values to be checked Binary zeros EMPTRN01 EMPTRN02 EMPTRN03 Binary zeros EMPTRN01 EMPTRN02 Binary Zeros EMPTRN01 EMPTRN03 Remark First start Calling itself Called by pgm002 Called by pgm003 Raise an error Called by pgm001 Calling itself Raise an error Called by pgm001 Calling itself

Pgm002

Pgm003

By pressing CLEAR key SPA associated with that terminal will be deleted.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 84 of 90

IMS Class Room Session

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 85 of 90

IMS Class Room Session

When SPA is created first time by IMS, IMS pulls out the transaction code from the message and puts it into SPA transaction code. That is if the message is: LL 2 SPA will be ZZ 2 TRANS-CODE 8 PFKEY 2

LL 2

ZZ1 2

ZZ2 2

TRANS-CODE 8.

Then message will shorten to: LL 22 ZZ 2 PFKEY 2

You have to take care of this situation. (Message length 6). So for this read SPA, take transaction-code put it into message. So now message is back to 12 characters length. There is a problem if transaction code is less than 8 characters. The thing is IMS parsing for transaction code stops only after 8 characters or when blank is encountered. Thats the reason of taking care for keeping transaction-id 8 characters long. If you keep transaction code 8 characters long only check for 6 characters length need to be done after writing SPA area.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 86 of 90

IMS Class Room Session

Some examples of transaction code less than 8 characters: Input Message Message After writing transaction code to SPA LL 2 ZZ 2 2 You have to take care of this 9 character length message 0 1 Remark You have to take care of this 6 character length message

LL ZZ E M P TRN 0 1 0 1 2 2 Transactioncode pfkey 8 2

LL 2 2 4 LL ZZ E M P T 2 0 1 2

ZZ 2 3

0 1 2

You have to take care of this 7 character length message 2 2 6 LL ZZ E M P TRN 2 0 1 2 LL 2 ZZ 1 2 0 1

Programs with SPA are conversational programs Programs without SPA are non conversational programs

When moving back to IMS from any screen that is pressing PF 3 to exit, write following steps in the associated section: 1. insert spaces to transaction code of SPA 2. insert that spa to IMS, using IO PCB

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 87 of 90

IMS Class Room Session


Day 15 Check point Syntax: CALL CBLTDLI USING DLI-CHKP IO-PCB IO-AREA-LEN CKPT-ID-AREA AREA1-LEN AREA1 : : AREA7-LEN AREA7

When this call gets executed 1. 2. 3. 4. 5. Restart: Restart will do the repositioning of the database, it will keep the memory content identical as of previous run fail. So if checkpoint is given when ckptr=17, needs to restart from FA350017. Program is required to work in two modes: 1. Normal Run 2. Restart Run Therefore needs to communicate with program to inform whether its a normal run or restart run IMS creates records with checkpoint identification. It will also contain repositioning information All this will be attached with checkpoint identification. All this information will go into log All the updates to database since the last checkpoint will be made permanent

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 88 of 90

IMS Class Room Session

Syntax: CALL CBLTDLI DLI-XRST IO-PCB IO-AREA-LEN XRST-AREA AREA1-LEN AREA1 : : AREA7-LEN AREA7

It is same as checkpoint call except here CKPT-ID-AREA that is XRST-AREA will be 12 bytes 01 XRST-AREA. 05 CKPT-ID 05 FILLER

PIC X(08) VALUE SPACES. PIC X(04) VALUE SPACES.

Initialization with spaces is must XRST call is written as a first call in your program. Program should determine the mode of run by checking the CKPT-ID field of XRST-AREA. If it is blank. It indicates a Normal run. If it contains the checkpoint-id then it is a restart run. Therefore it must to put VALUE SPACES at the time of declaration. XRST call will read log backwards, moves all area back to program work area. Also repositions the database if it is a restart run.

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 89 of 90

IMS Class Room Session


Programming tips for program using checkpoint and restart logic. Else Call XRST Check for restart-id If spaces Normal run Move restart-area to working-storage-area End-if Process

If want to take checkpoint after 500 updates: Process Some update activities Increment update counter If update counter = 500 CALL CBLTDLI USING DLI-CHKP : check for blank status code and SK status code SK status code is raised when checkpoint is taken before setting given in AES. That is if in AES the entry is given as 700, then AES will not honored this checkpoint. It will automatically take the checkpoint after 700 updates. Now this can be overridden thru JCL by giving PACECHP = no parameter. TSO BMCARC or BMCAES will allow you to delete all the previous checkpoints To terminate program after 5 checkpoints mention following in JCL: //ARCSYSIN DD * PACECHKP=N TRMAFTERCKP=5

IEFRDER: System Log. Current updates are maintained over here. This is used for Normal run When Checkpoint is given and program abends, IEFRDER is moved into IMSLOGR. IMS uses IMSLOGR to restart. So for restart IEFRDER becomes IMSLOGR and IEFRDER will be used for the current run. For normal run IMSLOGR is not required. Only need to specify IEFRDER This is only for DL/I jobs. For BMP IEFRDER is not required. It is done by control region (IMS startup and shutdown)

Developed By: Shilpa Keluskar & Suvarnalata Naik

Page 90 of 90

Das könnte Ihnen auch gefallen