Beruflich Dokumente
Kultur Dokumente
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
DASD
CCHH
IMS Database
EMP PAYROLL
EMP LIBRARY
EMP SKILL
If EMP personal data is deleted, all the others should get deleted. This is referential integrity.
Page 1 of 90
VIEW
LOGICAL MODEL
PHYSICAL LAYER
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
Level 3
Page 2 of 90
PCB P R O G R A M
ACB
DL/I
File Management
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.
Page 3 of 90
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
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.
Page 4 of 90
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
Page 5 of 90
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
Page 6 of 90
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
Page 7 of 90
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.
Page 8 of 90
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
RBA RBA
PR SKL
PR SKL
SKL
RBA
Overflow Dataset
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.
Page 9 of 90
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.
Page 10 of 90
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?
Page 11 of 90
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.
Page 12 of 90
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.
Page 13 of 90
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
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.
Page 15 of 90
HDAM Defined using one dataset, ESDS or OSAM which is logically divided into 2 parts
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
Page 16 of 90
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.
Page 17 of 90
Page 18 of 90
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)
Page 19 of 90
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.
Page 20 of 90
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
Page 21 of 90
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
Page 22 of 90
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
Page 23 of 90
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
Page 24 of 90
(AMEX Standard)
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)
Assignment4: 1. Create test data 2. Write DBD for EMP, PROJECT and PSB in one single .ACB file. Keep PROCOPT = A 3. Invoke CAISUTIL
Page 25 of 90
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
Page 26 of 90
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)
(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.
A EMPSEG
B PRSEG
D E SKLSEG
Page 27 of 90
2. GET NEXT (Sequential Processing) Function Code: GN Function: Used to retrieve next sequential segment
CALL GU GN GN GN GN
SEGMENT RETRIEVED A B C D E
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:
Page 28 of 90
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)
Page 29 of 90
Page 30 of 90
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
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
Page 31 of 90
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
Page 32 of 90
Tools
Process
Reception
Example: Knowledge-ware Co. Experts Home Library Books Manuals Periodicals Phy Ref. Papers : : : : : P C M A Maths s Reception
User
Delivery Tray Forms to be delivered Data Layer Business Layer Presentation Layer
Page 33 of 90
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
Page 34 of 90
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 ---------------------
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
Page 35 of 90
/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
Page 36 of 90
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
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.
Page 37 of 90
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.
Page 38 of 90
Screen Definitions (Fields & attributes) MFS ABC Company Mydata Empno: Name :
Page 39 of 90
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.
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.
Page 40 of 90
Page 41 of 90
MESG2
DFLD
X X
MFLD
MFLD
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
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
Page 42 of 90
Page 43 of 90
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.
Page 44 of 90
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.
Page 45 of 90
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.
Page 46 of 90
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.
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
Page 47 of 90
(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.
Page 48 of 90
System
EMPTRN01 EMPPGM01
GET REQUEST 01 request (II) LL ------ 12 ZZ ------ 0 EMPTRN01 Menu Pf1: Add Pf2: Inquiry :
12 bytes
If PF1 is Pressed
(IV)
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
Page 49 of 90
Page 50 of 90
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
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
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=
Page 52 of 90
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.
Page 53 of 90
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
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.
Page 54 of 90
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)
Page 55 of 90
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
Page 56 of 90
Page 57 of 90
Page 58 of 90
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.
Page 59 of 90
Source
Target Pointer
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.
Page 60 of 90
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=.
Page 61 of 90
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.
Page 62 of 90
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.
Page 63 of 90
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.
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
Page 64 of 90
Page 65 of 90
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
Page 66 of 90
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
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
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.
Page 67 of 90
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)
Page 68 of 90
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.
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
Page 69 of 90
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
Page 70 of 90
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.
Page 71 of 90
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.
Page 72 of 90
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
Page 73 of 90
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
Page 74 of 90
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.
Page 75 of 90
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
GSAM database cannot be used by MPP programs GSAM database can only be processed by BMP and DL/I programs
Page 76 of 90
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
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
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
Page 77 of 90
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:
Page 78 of 90
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
Page 79 of 90
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
Page 80 of 90
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
Page 81 of 90
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
Page 82 of 90
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
Page 83 of 90
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).
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.
Page 84 of 90
Page 85 of 90
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.
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.
Page 86 of 90
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 2 2 4 LL ZZ E M P T 2 0 1 2
ZZ 2 3
0 1 2
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
Page 87 of 90
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
Page 88 of 90
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
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.
Page 89 of 90
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)
Page 90 of 90