Wednesday, 25 April 2018

IMS Tutorial


1.       OVERVIEW - Data Language Interface (DL/I), IMS Transaction Manager, IMS Database Management System (Access Method / Operating System / Disk Storage).  

2.       IMS DB Structure

a)       Hierarchical Structure - Segment (Student), Data Fields (Roll Number, Name, Course, Mobile Number).
b)      Segment Type - 255 different Segment types & 15 levels of hierarchy. Segment Occurrence. DL/I to manipulate IMS database. Call level interface (EXEC DL/I).

Aapplication Program à IMS Control Blocks à Call DL/I à Operating System access method (i.e. VSAM) -> Database

3.       IMS COBOL PGM Structure
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION à FILE SECTION, WORKING STORAGE SECTION (Function Codes / I/O Area / Segment Search Argument), LINKAGE SECTION (PCB Mask)
PROCEDURE DIVISION

4.       IMS DB - DL/I Terminology - Root Segment (Only One), Parent Segment, Dependent Segment, Child Segment, TWIN Segments, Sibling Segment, Database Record, Database Path.

5.       IMS DB - DL/I Processing - DL/I Call Sequential, Random Processing, Key Field, Search Field.


6.       IMS DB - Control Blocks
a)      Three Types - Database Descriptor (DBD), Program Specification Block (PSB), Access Control Block (ACB).
b)      Database Descriptor (DBD)1 for each database / DBDGEN (Database Descriptor Generator) - Assembly Language macro statements are used to create control blocks.  This control statement executes in JCL to create physical structure LIBRARY (root segment) & BOOKS as child segment.
c)       Program Specification Block(PSB) – 1 for each Program, application program can have diff views called application data structure defined in the PSB, one program use one PSB in single execution, multiple pgms can share PSB. PSB contains one PCB for each DL/I database the application program will access. If one pgm access 3 database than 3 PCB (Program Communication Block) in 1 PSB.
d)      SENSEG (Segment Level Sensitivity), Field Level Sensitivity.
e)       Access Control Block (ACB) - Combines the Database Descriptor and the Program Specification Block into an executable form. ACBGEN (Access Control Blocks Generator), generate ASB's, Online Pgm, need to prebuild ACB's for Batch can be at Pgm execution.

7.       IMS DB Programming
f)       JCL to run IMS DL/I batch module(DFSRRC00) - DL/I Module, PCB Mask, DLI/ Call Info, Input-Output Area.
g)      Application Pgm - Program Entry, Define PCB Area, Calls To DL/I, Check Status Codes, Termination. 
h)      Application pgm interfaces with IMS DL/I modules via following pgm elements. 
1)      An ENTRY statement specifies PCBs are utilized by pgm.
2)      PCB-mask co-relates with the information preserved in the pre-constructed PCB which receives return information from the IMS.
3)      Input-Output Area is used for passing data segments to and from the IMS database. 
4)      Calls to DL/I specify processing functions (fetch, insert, delete, replace, etc.). Check Status Codes to check the SQL return code of processing option to inform whether operation successful or not. Terminate statement end the processing application pgm includes the DL/I. 

8.       IMS DB - Cobol Basics   -
i)        DL/I calls inside COBOL pgm to communicate with IMS database - Entry Statement, Goback Statement, Call Statement.
j)       Entry Statement - Pass control from DL/I to COBOL pgm and vice versa. --> ENTRY 'DLITCBL' USING pcb-name1 [pcb-name2]. PCB definition inside the Linkage Section is called as PCB Mask. Relation between PCB masks and actual PCBs in storage is created by listing the PCBs in the entry statement. The sequence of listing in the entry statement should be same as they appear in the PSBGEN.
k)      GOBACK Statement - Returns the control to DL/I from the program.
l)        Call Statement - To request for DL/I services such as executing certain operations on the IMS database CALL 'CBLTDLI' USING DLI Function Code PCB Mask Segment I/O Area [Segment Search Arguments].
m)    DLI Function Code - Four-character fields that describe the I/O operation.
n)      PCB Mask – must be listed in ENTRY statement in same sequence as they appear in your pgm’s PSBGEN. PCB definition inside the Linkage Section, used in the entry statement.
o)      Segment I/O Area (Host Variable) - Name of an input/output work area, area of the application program into which the DL/I puts a requested segment (retrieved data) or from which it will get data for an update operation.
p)      Segment Search Arguments (Where condition, Segment name*Command Codes) - Optional parameters depending on the type of the call issued, to search data segments inside the IMS database. After each DL/I call, the DLI stores a status code. Single DL/I call have multiple SSAs (Unqualified / Qualified SSA)

9.       DL/I Function Codes4 Byte Code to tell DLI call pgm is making. what kind of which operation is going to be performed on the IMS database by the IMS DL/I call.
q)      Get Function – Get Unique (GU/GHU), Get Next (GN/GHN), Get Next Within Parent (GNP)
r)       Update Function – Insert(ISRT), Delete (DLET), Replace (REPL)
s)       Other Function – Checkpoint (CHKP), Restart (XRST), PCB (PCB)


10.   PCB MASKPCB (Programme communication block). For each database, the DL/I maintain an area of storage that is known as the program communication block. ENTRY statement creates a connection between PCB masks in the Linkage Section and the PCBs within the program’s PSB.
a)      PCB NAME, DBD NAME, Segment Level (never has a value greater than 15 because that is the maximum number of levels permitted in a DL/I database).
b)      Status Code - Two bytes of Character, Spaces – call successful, Non-Spaces – Unsuccessful, GB – end of file, GE – requested segment not found.
c)       PROC Options - Processing Option indicates what kind of processing the program is authorized to do on database.
d)      Reserved DL/I - Segment Name, Length FB Key, Number of Sensitivity Segments, Key Feedback Area

11.   IMS- SSA (Segment Search Arguments) - used to identify the segment occurrence being accessed, optional parameter.
e)       Two types – Unqualified SSA, Qualified SSA
f)       Unqualified SSA - Name of the segment being used inside the call.
g)      Qualified SSA - Provides the segment name with additional information that specifies signet occurrence to be processed.
h)      Command Codes - Reduce the number of DL/I calls, making the programs simple, used in both Qualified and Unqualified Call, specify asterisk in 9th position, command coded coded at 10th position, From 10th position onwards, DL/I considers all characters to be command codes until it encounters a space for an unqualified SSA and a left parenthesis for a qualified SSA – C (Concatenated Key), D (Path Call), F(First Occurrence), L(Last Occurrence), N(Path call ignore), P(Set Parentage)  etc. MUL-QUAL is a short term for Multiple Qualification in which we can provide boolean operators like AND or OR.
i)        Unqualified CALL doesn’t contain any SSA’s.
j)       Qualified CALL one or more SSA’s / GU call with single unqualified SSA’s.
k)      Message format Service (MFS) – MFSGEN

1.       IMS DB - Data Retrieval GU CALL, GN CALL, Using Command Codes, Multiple processing (Multiple PCB’s – define for single database), Multiple positioning – can maintain multiple positions in a database using a single PCB.

2.       IMS DB - Data ManipulationISRT Call, Get Hold Calls, REPL Call, DLET Call.


3.       IMS DB – Recovery - 
a)       Simple Approach - Periodical copies of imp datasets/ restoring backup copy in case dataset damaged.
b)      Abnormal Termination Routines - system interferes so that recovery can be done after the Abnormal END.
c)       DL/I Log - DL/I records all the changes made by an application program in a file which is known as the log file.
d)      Recovery – Forward and Backward – Forward and Backward recovery.
e)       Checkpoint - stage where the database changes done by the application program are considered complete and accurate, can be established using a checkpoint call (CHKP), causes a checkpoint record to be written on the DL/I log. CALL 'CBLTDLI' USING DLI-CHKP PCB-NAME CHECKPOINT-ID – Basic and Symbolic Check-pointing.

4.       IMS DB - Secondary Indexing - Used when we want to access a database without using the complete concatenated key, Index Pointer Segment (Prefix & Data Element), Secondary Keys, Secondary Data Structures, Independent AND Operator, Sparse Sequencing.
a)       DBDGEN – need to create two DBD’s using two DBDGEN’s for creating a relationship between an indexed database and a secondary indexed database.
b)      PSBGEN - Processing sequence for the database on the PROCSEQ parameter of the PSB macro.


5.       IMS DB - Logical Database - IMS database has a rule that each segment type can have only one parent. DL/I allow the DBA to implement logical relationships in which a segment can have both physical and logical parents. New data structure after implementing the logical relationship is known as the Logical Database, Logical Child Segment, Logical Twins.
Logical Relationship Types – Unidirectional, Bidirectional, Physical & Virtual.
Concatenated Segment - Logical child segment, Destination parent segment.

6.       IMS status Codes
a)       SPACES – Successful IMS call
b)      GB – End of DB
c)       GE – Requested segment not found
d)      II – End of DB reached without satisfying a GN call.
e)       GA, GK – Tried insert a segment that already exists on database.
f)       DA – REPL issued, Key field modified.
g)      DJ – DLET or REPL issued without successful ‘GET’ or ‘GET Hold’ commands. (Get – High level interface / Get Hold – call level interface).

7.       IMS Checkpoint Logic

To commit n(i.e. 1000) records in COBOL-IMS-DB2 program. In normal COBOL program we can COMMIT. In COBOL IMS DB2 program we require check point logic. DFRSCOO Utility to run IMS program, parameter DBR (Database recovery) = 4.
CBLDLI – XRST, If IO – AREA = ‘SPACE’, job running for first time. IO – AREA store file Key. CHKP (Check Point) – To commit 1000 records (frequency) – CBLDLI – CHKP IO-PCB IO-AREA.

8.       IMS Imp Points
-          STOP RUN not be used only GOBACK.
-          BMP (Batch Message Processing)
-          MPP (Message Processing Program)
-          CICS & Online IMS MPP does not allow COBOL definition of files, IMS allow only for Batch Programs.

9.       Introduction to DL/I database Organization
HS, HSAM, HISAM, SHSAM, SHISAM, HD, HDAM, HIDAM, GSAM, MSDB, DEDB.
10.   A -> B -> C (How to access with GNP Syntax).

No comments:

Post a Comment