Sei sulla pagina 1di 28

Introduction to IMS/DB

25 April 2013 19:04

Introduction to IMS/DB
Q. What is IMS/DB? IMS(Information Management System) is the Hierarchical-Data Management System from IBM. When hierarchical data-structures are implemented using Flat-Files, it is the responsibility of Application-Programmers to ensure that it works flawlessly. Why storing huge-volumes of data having hierarchical-relationship in Flat-Files is a bad idea? Let's say, a list of Employees and the Departments in which they work this Data is stored in Flat Files.

The Departments Data is stored in DEPARTMENT File. The record-layout of the DEPARTMENT File is shown in the picture above. Every Department has a DEPARTMENTID, that uniquely identifies the Department. Moreover, a Department has a DEPARMENT-NAME and the total number of employees working under that department are recorded in DEPARTMENT-STRENGTH.

Every Department of the company has several Employees working under it. The Employees data is stored in EMPLOYEE File. The snap above shows its recordlayout. Each Employee is identified by Unique EMP-KEY, consisting of EMP-ID and DEPT-ID. The Employee's name EMP-NAME is further broken down in FNAME, MNAME and LNAME. The Employees Joining Date is stored in EMP-JDATE. This hierarchical relationship between DEPARTMENT File and EMPLOYEE File is depicted in the picture below.

IMS Page 1

However, there are certain problems with this design. 1. Maintaining Data Consistency - For instance, if the Program adds a new Employee-Record, that has no DEPT-ID, no corresponding department, the DEPARTMENT and EMPLOYEE Files will no longer be synchronized. And the same is true, if a Department-Record is deleted, when active Employees work for that Department. These Employee-Records are orphaned out. 2. COBOL Program and Data Dependency Because the structure of the Data(File Layout) is hard-coded or embedded in the COBOL Program accessing the data, whenever the data's structure changes(say you add one more field to the DEPARTMENT File), the COBOL Program has to be re-written and re-compiled all over again. The Program heavily depends on the Data. When you use IMS/DB for storing data, difficulties like these don't come up. That's because the hierarchical relationships between data is now taken care of by IMS. IMS would use a single file for storing DEPARTMENT and its EMPLOYEE's data. The structural information is stored in IMS.
Q. What is meant by Segment-Type, Segment-Occurrence and Levels in IMS?

In IMS/DB, when data is stored about any real-world thing, you call it a Segment. For example, if you record information about Employees, Employee is one-Segment. Because you would be storing Departments is another segment. In IMS Jargon, I would call them DEPARTMENT Segment and EMPLOYEE Segment.
I'll introduce two new terms as well Segment Type and Segment Occurrence. A segment-type is one category or class of data. For example, DEPARTMENT SegmentType. Each instance of a Department is called a Segment-Occurrence. For example, you may have 3 segment-occurrences HR, MARKETING and FINANCE of the Segment-Type DEPARTMENT. Bear in mind, there can be only one segment-type of a particular kind, but infinite occurrences of it.

An IMS Hierarchical-Database can be looked upon as an inverted-tree. The Height of the Tree tells you the number-of-levels in the Tree.

This Hierarchical-database has two Levels.

Q. What is meant by Root-Segment and Database Record?

IMS Page 2

In an IMS Hierarchical-Database, the segment-type at the top of the hierarchytree is called the Root-Segment. For example, in the below database, the DEPARTMENT-Segment is called the Root-Segment.

Suppose the DEPARTMENT Segment-type has 3 segment-occurrences HR, Marketing and Finance. Each of these Department segment-occurrences have Employee Segmentoccurrences subordinate to them. HR Department has 2 sub-ordinate Employee Segment-Occurrences RAM and RAJ. Marketing Department has 3 sub-ordinate Employee-Segment occurrences RAKESH, RAVI and RAJESH. Finance Department has 2 sub-ordinate Employee Segment-occurrences ROMEO and ROY.

One root segment-occurrence e.g. HR plus all the segment-occurrences sub-ordinate to it for example RAM and RAJ, together constitute one Database-Record. Thus, here there are 3 database-records, one for each root segment-occurrence. In all, there are 10 segment-occurrences in this IMS Database. Q. What are dependent, parent and Child and twin Segments?
All the segments in an IMS Hierarchical DB, other than the Root-Segment are called Dependent-Segments. DEPARTMENT Segment is called Parent-Segment and EMPLOYEE Segment is its Child-Segment. The term Twin segments is applicable to Segment-Occurrences. Two children with same parent segment-occurrence are called twins. For example, RAKESH and RAVI are child of the same parent segment occurrence Marketing Department, so they are called Twin-Segments.

Q. How data is accessed in an IMS Hierarchical Database? Data can be accessed in two-ways from an IMS-Database Sequential and Random mode of access. When you access data from IMS DB Sequentially, you read it record-by-record. Within each record, the segments are accessed in the following general pattern : Top-to-Bottom, Left-to-Right. First, a root segment-occurrence is retrieved. Then, IMS DB digs as far deep as possible, right at the bottom, until it reaches the lowest level SegmentOccurrence. It then retrieves all the twin segment-occurrences at that level. Once, all the Twin Segments have been fetched, IMS moves back up in the hierarchy
IMS Page 3

Once, all the Twin Segments have been fetched, IMS moves back up in the hierarchy and retrieves any twins of the Parent. This process continues, till all the Database Records have been retrieved. So, the sequence in which the Data is fetched is HR-RAM-RAJ, MARKETING-RAKESH-RAVI-RAJESH and FINANCE-ROMEO-ROY.

Random-Access to Data in a Hierarchical-Database is possible by supplying a concatenated-Key. Every Segment can have a Key-Field(or Sequence Field). For example, DEPARTMENT-ID may be a Key-Field of DEPARTMENT Segment. EMPLOYEE-ID would be Key-Field of Employee-Segment. A Concatenated-Key is formed by combining the Key-Fields of different segment-types e.g.(DEPARTMENT-ID,EMPLOYEE-ID). This way you can jump or skip directly to any particular Segment-Occurrence under any Database Record.

IMS Page 4

Segment Search Arguments(SSA)


25 April 2013 19:01

Segment Search Arguments(SSA)


Q. Is it easy to search for Data in an IMS Database?

y computer keeps crashing, these days. I make a phone-call to the Computer

Technician in my vicinity, and ask him to pay a visit. I have got to search, "What's the Phone number of the Technician guy?" I pull out my Yellow-Pages Directory to find out. Its remarkably easy to look-up the Yellow-pages, coz the business contacts are organized in alphabetical order. I don't need to read the entries from first page, one-by-one sequentially till I reach the desired entry! Under the Alphabet 'C', I just jump to the "Computer Technician's Section", and voila! I have before me, a List of the phone number's of all computer repair shops. Had it not been for the Yellow-Pages Directory, find the phone-number of the Computer guy would be like finding a needle in a haystack.
Just like the Yellow-Pages directory, an IMS Database also keeps things in a tidy order. The data in an IMS Database is sorted. Searching an IMS Database is a piece of cake! If would like to search in particular for something in the IMS Database, there's no need to run a scan on the database sequentially...

Q. What is an SSA(Segment Search Argument)? An SSA(Segment Search Argument) answers the question, "What are you looking for in the IMS Database?" While performing a search on the Database, IMS-DB System looks at SSA to determine, what data you need? For example in the Inventory Database containing Vendors, Items and Stock-Locations data, you may like to confine your search just to Vendors. Or your supervisor wants to search only for Items. One may decide to search for only those Items whose Price is greater than > 500 rupees. While searching an IMS Database, you may supply extraparameters to be more precise.

IMS Page 5

If you supply an SSA on an IMS-DB Call, the SSA will be taken into consideration, during execution and fetching the results. Only those results that satisfy the SSA, and pass through its filter criterion shall be present in the final solution.
Q. How to build(construct) a simple SSA?

First, you must construct or build the COBOL Definition of the SSA. You can then use this SSA on an IMS-DB Call. The simplest form of an SSA, that you can build is an Unqualified SSA. An Unqualified SSA just contains the segment-name you wish to process. A picture of an unqualified SSA is shown below. Unqualified SSA always contains the segmentname in the first 8-Bytes, followed by one Blank Space.

First declare all the SSA's you intend to use under the Working-Storage Section of the COBOL Program. This is how, you'd declare an Unqualified SSA in a COBOLProgram.

"

I want to search for Vendors Data in my IMS Database."

Suppose, you would like to search only for Vendor data in an IMS Database. In the Inventory IMS Database, the Vendors Data is represented by the VENDRSEG SegmentType. So, I would store the segment-name 'VENDRSEG' in the Unqualified SSA. A picture of it is shown below.

Q. Can I supply two SSA's? How does it work? The Inventory-Database has three Segments : VENDRSEG, ITEMSSEG and STLOCSEG. The root segment type VENDRSEG at Level 01, represents the Vendors Data. Vendors manufacture or produce Items. ITEMSSEG Segment at Level 02, represents the Lineitems that are supplied by a Vendor. Each Item may be stocked at different locations like Mumbai, Delhi, Chennai etc. STLOCSEG Segment at Level 03, represents the warehouse-locations at which the stock of an Item is kept.(stored). The Database Structure is shown in the figure below.
IMS Page 6

kept.(stored). The Database Structure is shown in the figure below.

Now, what if you dont want to search for Vendors, but rather you'd like to search for the Items Data, under these Vendors. In IMS, you are allowed to supply an SSA, at each hierarchical-level in the IMS Database. This implies, you can specify one SSA at the VENDRSEG Segment-level, and a second SSA at the ITEMSSEG Segment-Level.

In the above picture, I have constructed two SSA's VENDR-USSA(Vendor Unqualified SSA) and ITEMS-USSA(Items Unqualified SSA). When you supply two SSA's like this, it indicates to IMS Search only for ITEMS Data, under the VENDOR Data.

On the same lines, if you would like to search only for Stock-Data in the IMS Database, you would have supply three SSA's one at VENDRSEG Level 01, second at ITEMSSEG Level 02 and third at STLOCSEG Level 03. This indicates to IMS Search only for STOCK Data, under the ITEMS Data which is under the VENDORS Data.
In general, the thumb-rule is that, the last-level SSA determines which segment the IMS-DB System will process. Q. What is a Qualified SSA?

A Qualified SSA allows you to specify a particular occurrence of a Segment-Type. The format of the Qualified SSA, is illustrated in the snapshot below.

IMS Page 7

The Qualified SSA is composed of an Eight-Bytes Segment-Name. This is followed by the Field-name, the relational operator, and the search-value. The Field-name, operator and value are enclosed in round-brackets(parenthesis).
PRINT NOGEN DBD NAME=INVDBD,ACCESS=HIDAM DATASET DD1=INDD,DEVICE=3390 *---------------------------------------------------------------* SEGM NAME=VENDRSEG,PARENT=0,POINTER=TB,BYTES=131 *---------------------------------------------------------------* LCHILD NAME=(INPXPNTR,INPXDBD),POINTER=INDX FIELD NAME=(VENDRCOD,SEQ),BYTES=3,START=1,TYPE=C FIELD NAME=VENDRNAM,BYTES=30,START=4,TYPE=C FIELD NAME=VENDRADR,BYTES=30,START=34,TYPE=C FIELD NAME=VENDRCIT,BYTES=17,START=64,TYPE=C FIELD NAME=VENDRSTA,BYTES=02,START=81,TYPE=C FIELD NAME=VENDRZIP,BYTES=09,START=83,TYPE=C FIELD NAME=VENDRTEL,BYTES=10,START=92,TYPE=C FIELD NAME=VENDRCON,BYTES=30,START=102,TYPE=C *---------------------------------------------------------------* SEGM NAME=ITEMSSEG,PARENT=VENDRSEG,BYTES=48 *---------------------------------------------------------------* FIELD NAME=(ITEMNAME,SEQ),START=1,BYTES=5,TYPE=C FIELD NAME=ITEMSDES,BYTES=35,START=06,TYPE=C FIELD NAME=ITEMSPRC,BYTES=04,START=41,TYPE=P FIELD NAME=ITEMSCST,BYTES=04,START=45,TYPE=P *---------------------------------------------------------------* SEGM NAME=STLOCSEG,PARENT=ITEMSSEG,BYTES=21 *---------------------------------------------------------------* FIELD NAME=(STLOCLOC,SEQ),BYTES=3,START=1,TYPE=C FIELD NAME=STLOCONH,BYTES=04,START=04,TYPE=P FIELD NAME=STLOCROP,BYTES=04,START=08,TYPE=P FIELD NAME=STLOCONO,BYTES=04,START=12,TYPE=P FIELD NAME=STLOCDAT,BYTES=06,START=16,TYPE=P DBDGEN FINISH END
Pasted from <https://docs.google.com/document/pub?id=1rk6KUTmc6ddDdqNLpvJ2gsYUdrEhedquCSicuzBAOlk&embedded=true>

The Database Descriptor DBD for the Inventory Database System is shown above. There are three Segments VENDRSEG, ITEMSSEG and STLOCSEG. Each segment-type has several fields.

About the author

Quasar Chunawalla is an author, blogger from Pune, India. He works as a technology guy. He has a passion for teaching and helps other aspiring
IMS Page 8

technology guy. He has a passion for teaching and helps other aspiring developers build their skills. He is a movie addict, likes to travel and is a connoiseur of good food.
WANNA-BE PROGRAMMERS Main page Learn Mainframe programming Prepare for interviews
Re-usable JCLs

TUTORIALS What on earth is Mainframes? Cobol application programming Writing Cics transactions A look inside Db2 IMS, the old and faithful Assembler for speed IBM utilities The power of SORT
JCL, the lingua franca of mainframes

A crash-course on VSAM Rexx and ISPF HERCULES AND MVS Download MVS Turnkey Install MVS 3.8j IPL your beast
Login to TSO

MISCALLANEOUS CA-7 scheduler Editing files with File-aid Debugging with xpediter QMF utility
THE LODGE

Join the Mainframes 360 Google Group The Facebook page THE CLOSET
My Letters and Notes

Inserted from <http://www.mainframes360.com/2011/03/segment-search-argumentsssa.html>

IMS Page 9

Creating a new IMS Database - MAINFRAME, IBM MAINFRAMES TUTORIALS, JCL TUTORIALS, VSAM TUTORIALS, COBOL TUTORIALS, DB2 TUTORIALS, CICS TUTORIALS, IMS/DB TUTORIALS, REXX, MAINFRAME INTERVIEW QUESTIONS, MAINFRAME JOBS
25 April 2013 19:25

Whats new at MAINFRAMES 360

Last publication: January 15, 2013

To many people who are thrown to work at a mainframe computer on their first job, they feel lost. The hardware is a complete mystery. Programmers work on green screens. Mainframe people seem to speak a completely different language and that doesn't make life easy. What's more, the books and manuals are incredibly hard to comprehend. "What on earth is a Mainframe?" is an absolute beginner's guide to mainframe computers. We'll introduce you to the hardware and peripherals. We'll talk about the operating system, the software installed on a mainframe. We'll also talk about the different people who work on a mainframe. In a nutshell, we'll de-mystify the mainframe. Readers based in India, can buy the e-book for Rs. 50 only or the print book. International readers based in the US and other countries can click here to purchase the e-book.

Saturday, November 6, 2010


Creating a new IMS Database
Q. How do COBOL Programs access Data using IMS/DB Software?

COBOL-Programs use READ and WRITE Instructions to access Data from Files. This invokes or calls a helper-program called Access-Method. The Access-Method Software actually knows the details of how the data is organized, and the location(place) where the record is stored physically on the big DASD-Disk. The Access-Method actually gets the Data from the File, in units of raw Blocks like 0001HARRYPOTTER1000MUMBAIINDIA. But, the access-method has no knowledge about the Record's format or structure what are the fields in the Record. The Data fetched would be useless, or of little value if you dont know its structure or Format. In an H2O water-Molecule, it is the Atomic-Structure that is important. On the same lines, Data is meaningful and can be processed, if you know its structure like (EMPID,FNAME,LNAME,SALARY,CITY,COUNTRY). In simple COBOL-File IO Programs, this format, structure or File-Layout, that I am stressing on, is hard-coded or embedded in the COBOL-Program. The COBOL-Program sees the same record-format, as that of the actual-record in the File on the Disk. By contrast, when data is stored and managed by the IMS/DB Software(one more layer added to the Onion on the right), the COBOL-Program is now unaware of the Structure or record-format. The COBOL-Program talks with the IMS/DB Software which stores structure-details. The complicated details of the record-format and Structure are now taken care of by IMS/DB Software, and the COBOL-Program is
IMS Page 10

Structure are now taken care of by IMS/DB Software, and the COBOL-Program is spared and relieved from this botheration. The IMS DB/Software in turn, calls the Access-Method Software to actually GET the Data from the Disk-Dataset. The IMS/DBSoftware Interface in return presents this Data to the COBOL-Program in the form of Segments. The IMS/DB Software does provides an Abstraction.

Q. How do you create a fresh New Database-File to store Data? Do I go to ISPF Menu Option 3.2?
Say that, you wanna store the data about your Shopping-List the list of items that you want to buy from the Super-Market, in a Mainframe-File, and you want IMS/DB Software to help you manage your Shopping List. This means, if you want to add an item to the Shopping-List, remove an item from the Shopping-List, or take a Print of all the Items in the Shopping-List, you are gonna ask IMS/DB Software to do it for you.

The sad part is, IMS/DB Software can't read Sequential-Files. IMS/DB Software has the ability to read and write data to VSAM-ESDS Files. Hence, if you plan to use IMS/DB Software to manage your data, better create blank(empty) VSAM-ESDS Files to hold your valuable-Data. I have created an Empty New VSAM ESDS File IMS810.INVENDB by running the free IBM-Software Tool IDCAMS.

I'd use this Empty VSAM Database-File created newly, load my data into it, and then ask IMS/DB Software to manage this data in the future.

Q. What are Control-Blocks? Whenever a COBOL Program, sends requests to the IMS-DB Software, to access data from the VSAM Database-File, IMS-DB Software cannot directly service it. To support the request, the IMS-DB Software needs (i) The Blue-print of the Database and (ii)the database privileges, the program has. These details are stored in specialized Load-Modules called Control-Blocks. IMS-DB Software uses the Control-Blocks as a ready-reckoner, and constantly refers to them, for any requests that come along.
Q. What is DBD Control-Block? The DataBase Descriptor or DBD Control-Block, contains the Database-Structure details what are the different segments in this data, what are the fields in this segment etc. The DBD Control-Block contains the design of the database, it's a blue-print.

IMS Page 11

Every Database must have a DBD Control-Block. Say if, there are two hierarchical databases X and Y, theres got to be two DBDs.

Q. What is PSB Control-Block? The Program Specification Block or PSB Control-Block contains details about, the Database Privileges granted to a COBOL-Program. The PSB will specify, what database-segments the program is allowed to access, the type of access(Get, Insert, Update, Delete). The IMS-DB Software uses the PSB Control-Block, to prevent unauthorized access and enforce security. If the Program attempts to access a segment in the database, which is not allowed in the PSB Control-Block, it is a security violation and the IMS-DB Software restricts it. Every Program must have a PSB Control-Block. Say, if there are two Programs, there's got to be two PSBs. Moreover, a Program's PSB internally contains a PCB(Program Control Block). For each database accessed by the Program, there is one PCB in the PSB Control-Block.

In the above picture, the firstprogram can access both Database-X and Database-Y, but the the second-program is only allowed to access the Database-X.

Q. Who creates the Control-Blocks? How do you write or code a new Control-Block? You first write the Source-Code of the Control-Block in Assembler Language. But, the Mainframe-Computer doesn't understand Assembler. It knows only Binary Machine Language 0's and 1's. So, after writing the Source-Code, you Assemble-Link it to produce a Binary Load-Module for the Control-Block. IMS/DB Software shall always refer to these Control-Block Load Modules(containing Database structure-details), while storing or retrieving Data from the Database-File.
You go about creating two control-blocks - (i) DBD Control Block and (ii) PSB Control-Block.

Q. How do you write the Source-Code of the DBD Control-Block? The secret to writing Source-code for DBD-Control Block, is youve got to think, "What's the Structure of the Data, that you are going to store in the VSAM-ESDS Database-File?" Say for example, I want to generate DBD Control-Block for the Inventory-Database. A pictorial representation of the Inventory-Database Structure is given below.

Here's a brief description of the Inventory-Database. The Inventory-Database has three segments Vendor, Item and Stock-Location. When you begin to write Assembly Language Source-Code for the DBD Control-Block, ask yourself, "What are the
IMS Page 12

Language Source-Code for the DBD Control-Block, ask yourself, "What are the segments in this Database"? For each segment, you code a SEGM Macro. This is how the skeleton of the Source-Code looks like. Code 3 SEGM Macros, one for VENDRSEG, one for ITEMSSEG and the last for STLOCSEG. The PARENT Attribute on the SEGM Macro tells, "who's the Parent of this Segment"? Since, Vendor Segment is the root, I coded PARENT=0 on it. On ITEMSSEG, I coded PARENT=VENDRSEG and likewise on STLOCSEG, I coded PARENT=ITEMSSEG. For each Segment, the BYTES Attribute indicates the total Sum-Length of all the Fields in that Segment. Ill revisit this attribute a little later.

Now, every Segment VENDRSEG, ITEMSSEG and STLOCSEG can have many fields. Code the FIELD Macro once, for each Field. FIELD Macros go under the appropriate SEGM Macros. I am gonna explode each segment one-by-one, and show you how to code its Fields. Vendor Segment is the list of the Vendors, which supply Raw-Materials. Every Vendor has a 3-Character Alphanumeric Code-Number, a name, an address, city, state and Zip-Code where the Vendor is located and Telephone-Number and Contact-No. The BYTES Attribute indicates the length of the Field. The START Attribute indicates the Starting-Position or Offset(Displacement) of the Field. Let me elaborate it : VENDRNAM is 30 Bytes in Length, and starts from Position 34. It implies VENDRNAM spans from Position 34 to Position 63(30 Bytes). Consequently, the next successive Field VENDRADR will start from Position 64 and so on. An easy formula to remember this is Starting Position = (Previous Field's Start + Previous Field's Length). Moreover, the TYPE Attribute indicate the type of data. Alphanumeric or PIC X Fields have TYPE=C. Numeric Fields(PIC 99) have TYPE=Z. Packed Decimal( PIC S9(05)V99 COMP-3) have TYPE=P. If you sum-up the field-lengths of VENDRCOD, VENDRNAM, VENDRADR, VENDRCIT , VENDRSTA, VENDRZIP, VENDRTEL and VENDRCON = (3+30+30+17+02+09+10+30) = 131 Bytes. It means the One Vendor's data will be 131 Bytes in size. So, you code BYTES=131 on the Vendor Segment's SEGM Macro.

When you write a COBOL-Program to fetch the Vendor-Data from the IMS-Database, the Vendor-Data received from the IMS/DB Software into the COBOL-Program needs to be stored or kept somewhere. You need COBOL-Variables corresponding to each of these VENDRSEG Fields that will store or hold the data in the COBOL-Program, when it received from the IMS Vendor Segment. Here, is the COBOL Copy-Book(a separate Mainframe File) containing the COBOL Variables corresponding these VENDRSEG FIELDs.

IMS Page 13

One Vendor may supply several Items. Item Segment represents the list of the Items, which a Vendor supplies. Every Item has an Item-Name, a short description, unit-price or cost of the Item and the average cost of the Items. Heres the DBD Source-code for the ITEMSSEG Segment.

The COBOL Copy-Book Layout(a Separate Mainframe File) corresponding to the Above ITEMSSEG, is shown below.

One Item may be stocked or stored at multiple-locations or warehouses. Stock-Location segment represents the list of the locations, where an item is stored or stocked. Each Location is identified by a 3-character alphanumeric code. At every location, important-details about the inventory such as what is the quantity-on-hand, what is reorder-point, what is the quantity-on-order, and the last re-order date is recorded. This picture shows, how I wrote the DBD Source-Code for the Stock-Location Segment.

The COBOL Copy-Book Layout(A Separate Mainframe File) corresponding to the above Stock-Location Fields, is in the snap below.

Q. How do I assemble and Link the above DBD Macros? I have the following setup at my shop. I have created a Library(PDS) for storing the DBD Macro Source-Codes called IMS810.DBDSRC. I have keyed in my DBD Sourcecode in a Member INVDBD, under the Source Library. I have another Library(PDS), which will contain the corresponding DBD Control-Blocks Load Modules, which are produced after assembling the source-code. My DBD Load-Library is IMS810.DBDLIB. Before you run the assemble-link job, you should have your own personal DBD-Source and Load-Libraries setup.

IMS Page 14

To Assemble and Link your DBD-Code, you run the Assembler-Software (EXEC PGM=ASMA90) first and followed by the Linker-Software(EXEC PGM=IEWL). So, you write a simple two-step Assemble-Link job. You can download this JCL by clicking here. This is how it looks.

There are four-variables that you need to set. The DBDNAME Parameter is the name of the DBD. The SRCLIB Variable is the DBD Source-Library. The MACLIB Variable is the IMS Macro-Library. You should ask the System Programmers at your shop and find out, the name of the IMS Macro Library. Last, the DBDLIB is the name of the DBD Load-Library. Q. How do you write the PSB Macro Source Code? A PSB Control-Block is like a Entry Pass(Ticket). The PSB helps prevent any unauthorized Access to the Data. IMS/DB Software checks PSB Control-Block to enforce Access-Control.
Every COBOL Program that accesses IMS/DB Database, has its own PSB(Entry Pass). In fact, it is customary to have the PSB-Name same as the Program-Name. Inside each PSB, there are several PCBs. Suppose there are two Databases Employee Database EMPDBD and Inventory Database INVDBD, that the program needs access to. You code a PCB-Macro for each Database, that the program accesses. The PCB Macro, essentially tells the Processing Options PROCOPT=G. PROCOPT Parameter is damn important and indicates the Access-Privilege. For example, to authorize the program to only read the data from the Database, code PROCOPT=G. On the other hand, for a Program to initially load data into the the Database, coding a PROCOPT=LS is necessary, and so on..

Look, how I have written the Source-Code for the a simple PSB which has one-PCB for the Inventory-Database. If a Program uses this PSB, the program will only be able to access Inventory Database(and not Customer Database). You may also download this Source-Code by clicking here.

Following the PCB-Macro, you may code the SENSEG or Segment Sensitivity Macros. You code one SENSEG Macro for each Segment. The NAME Parameter indicates the name of the Segment. I have coded three SENSEG Macros for VENDRSEG, ITEMSSEG and STLOCSEG. Q. How do I assemble and link the above PSB Macros?
I have the following setup at my end. I have created a Library(PDS) for storing my PSB Macro Source-Codes IMS810.PSBSRC. I have keyed in my PSB Source-Code in a Member INVPSB under the Source-Library. I have another Load Library or PDS IMS810.PSBLIB, which will contain the PSB Control-Blocks LoadModules, produced on assembling the Source-Code. My advise to you is, go ahead and first setup your Own personal PSB Source-Library and Load-Library before you run the Assemble-Link Job.

Just like the DBDGEN Job, I have written a PSBGEN Job to Assemble-and-Link the PSB Code. See below how the PSBGEN Job looks. You may also download this JCL Code by clicking here.
IMS Page 15

clicking here.

There are four variables, that you need to set. PSBNAME is the name of the PSB. SRCLIB is the Source-Library containing the PSB Macros Source-Code. MACLIB is the IMS Macro Library. PSBLIB is the Load-Library where the PSB Control-Blocks reside.

About the author

Quasar Chunawalla is an author, blogger from Pune, India. He works as a technology guy. He has a passion for teaching and helps other aspiring developers build their skills. He is a movie addict, likes to travel and is a connoiseur of good food.
WANNA-BE PROGRAMMERS

Main page
Learn Mainframe programming

Prepare for interviews Re-usable JCLs TUTORIALS


What on earth is Mainframes?

Cobol application programming


Writing Cics transactions A look inside Db2

IMS, the old and faithful


Assembler for speed

IBM utilities
The power of SORT

JCL, the lingua franca of mainframes


A crash-course on VSAM Rexx and ISPF HERCULES AND MVS

Download MVS Turnkey


Install MVS 3.8j IPL your beast

Login to TSO MISCALLANEOUS


CA-7 scheduler

IMS Page 16

CA-7 scheduler

Editing files with File-aid


Debugging with xpediter

QMF utility
THE LODGE

Join the Mainframes 360 Google Group


The Facebook page THE CLOSET

My Letters and Notes

Inserted from <http://www.mainframes360.com/2010/11/creating-new-ims-database.html>

IMS Page 17

Preparing a COBOL-IMS Program 25 April 2013 19:26

Preparing a COBOL-IMS Program


Q. What's the Skeleton of a COBOL-IMS Program? To write a COBOL-IMS Program and win the battle, you must be armed with two heavy-duty tools ENTRY and GOBACK Statements in COBOL. In the IMS Environment, its the IMS/DB Software that is the supreme Commander -in-Chief. The IMS/DB Software will call your COBOL Program. Your COBOL Program is a sub-program to the IMS/DB Software. The control is transferred to the COBOL Program. ENTRY statement indicates the ENTRY-Point into the COBOL-Program, the position from where the COBOL Program begins to run. The COBOL Program runs, processes data, and generates Output Results. As soon as the GOBACK Statement is encountered, the COBOL Program completes, the control is returned(GOes) BACK to the IMS/DB Software, and the IMS/DB Software again takes over.
This is what any COBOL-IMS Program would have the ENTRY and GOBACK Statements.

First, IMS/DB Software loads the DBD(database structure information) and the PCB Control-Blocks into Memory. It then sends down the address of the DBD and the PCB Control Blocks to your COBOL Program, and then runs your COBOL Program. These PCB Control-Blocks reside outside the COBOL-Program. Then how does the COBOL Program get access to them, see what's inside these Control Blocks? What you do is, you provide a definition of the PCB in the LINKAGE SECTION of the COBOL Program. The LINKAGE SECTION Definition of the PCB is called PCB-Mask. Via These masks in the COBOL Program, you can access the actual PCB's in Storage. You should list these masks on the ENTRY Statement. The above picture shows, how I've coded the ENTRY Statement. It specifies 'DLITCBL' as its entry point. And the USING Clause lists the names of the masks in the LINKAGE SECTION. Q. How do you issue an IMS/DB CALL? Whenever you would like to perform any operation in IMS, say read the data, update the data etc. you issue a CALL to the IMS/DB Software. This is how you code IMS/DB CALLs.

You issue an IMS/DB CALL, by coding CALL 'CBLTDLI'. You supply additional
IMS Page 18

You issue an IMS/DB CALL, by coding CALL 'CBLTDLI'. You supply additional parameters on the CALL. I shall broadly describe them here -

1)The DLI function It is the first Input-Parameter to the IMS/DB Software. The DLI-Function indicates to IMS, the operation to be performed on the data, and is a 4 -Bytes Code. To add new data to the Database 'ISRT'(Insert) DLI-Function is used. To update data, 'REPL'(Replace) DLI-Function, to erase data, the 'DLET' (Delete) DLI-Function and so on, are used.

2)The PCB-Mask The second parameter on the IMS/DB CALL is the PCB-Mask. PCB-Mask is a common shared communication-area between IMS/DB Software and the COBOL Program. IMS/DB Software returns-back(communicates) important information to the COBOL Program through the PCB Mask. After an IMS/DB CALL Executes, how do you know, what's the result of the IMS/DB CALL? Was it successful, or did it fail? After every IMS CALL, the IMS/DB Software sets a 2-Digit Status code, to indicate the success or failure of the operation. The Status Code ' '(SPACES) indicates the IMS CALL was successful. A non-Blank status code like 'GE', indicates that the IMS CALL failed due to some reason. IMS/DB Software stores the two-digit status code in the PCB-Mask.
Here's the picture of the PCB-Mask sent-back to the COBOL Program, after the IMS/DB CALL Executes. As you can see IMS/DB has stored important details in the PCB-Mask. The Status-Code Field is Blank(Spaces), this means the CALL was successful.

Initially before the IMS/DB CALL, the PCB-Mask is Empty. You send the PCB-Mask to the IMS/DB Software. After the IMS/DB CALL executes, IMS/DB Software stores details such as Status-Code etc. in the PCB-Mask.
3)The Segment Input-Output Area
IMS Page 19

3)The Segment Input-Output Area After execution of the IMS/DB CALL, the data-result retrieved from IMS-Database needs to received and stored in some COBOL working-storage field, for processing. While inserting, the data to added to IMS-Database needs to be first stored in some COBOL-Variable, from where it will be sent to IMS. The Segment I-O Area is this Input-Output COBOL-Variable, used for either receiving the Data, when reading from the IMS Database or to send the data, when writing to IMS Database. I have coded an IMS/DB CALL to ISRT(Insert) Items-Data into the IMS-Database. Look, how I have stored the Item-data(00011 SODIUM PALMITATE ...) that I want to insert into the Database in the COBOL-Variable SEGMENT-IO-AREA(a 131-Byte Field).

4)Optional SSA's(Segment-search Arguments). Optionally, you may supply additional Segment Search Arguments(SSA's). As you know, an IMS/DB Database is made of several segments e.g. VENDRSEG, ITEMSSEG and STLOCSEG, and every segment has several instances. While fetching data from the IMS database, suppose you would like to filter-out the data. You would like to retrieve only Vendors Data(VENDRSEG). Or you want to fetch only ITEMSSEG(Items) Data. SSA's are used to search or filter data. While inserting, SSA's tell what data are you adding - Vendor Data, Items Data or Stock-Location Data. SSA's are in a way similar to the WHERE Clause of SQL. In the above picture, see how I have specified the SSA('ITEMSSEG ') to indicate, that it is Items-Data, that I am inserting.

Q. What are the different DLI Functions that you can perform on an IMS Database?
Every IMS/DB CALL performs an operation or function on the Database. The DLI Function is the first parameter you code on an IMS/DB CALL. Here is a list of the important DLI Functions, you would use in time to come.

IMS Page 20

Let me first describe the GU(Get Unique) and GN(Get Next) Functions. The GU(Get Unique) Function is used for Random-Retrieval of Data. Say for example, you want to know what is the price for particular Item Code 00012. You can directly jump to this Item Segment Occurrence by doing a GU. It is like the Standard COBOL READ Statement for Random access. The GN(Get Next) function is used for the Sequential-Retrieval of Data. Say for example, you would like to traverse through the entire database. You can browse the segment occurrences in sequential(Hierarchical) order one-by-one by executing GN CALLs. It is like the Standard COBOL READ Statement for Sequential Access.

The GNP(Get Next in Parent) function is used to retrieve segment-occurrences sequentially, but under a pre-established Parent. First, you fix the Parent Segment Occurrence. Then you can retrieve all the segment-occurrences under it one-by-one by executing GNP CALLs.
The other three function-codes contain 'H' or Hold. The GHU(Get Hold Unique), the GHN(Get Hold Next) and GHNP(Get Hold Next in Parent) functions are the counterparts of GN, GU and GNP CALLs, which are used to express intent of update. Suppose you are going to update a segment occurrence. First you should retrieve it using a GHN, GHU or GHNP CALL. When you retrieve segment-occurrences with the intent of updating them, you use the Hold CALLs. The ISRT(Insert) Function, REPL(Replace) Function and DLET(Delete) Function are used to add new Segment Occurrence, update a Segment-Occurrence, or deleting Segment-Occurrence from the Database. Q. Why code the PCB Mask? Also, how to code the PCB Mask in COBOL? The second parameter that you supply on the IMS/DB CALL, is the PCB-Mask. The PCB-Mask is the Linkage-Section Definition of the PCB Control-Block. The PCB-Mask has a number of uses. 1. Let's say, a Program accesses three different databases db-1 db-2 and db-3. The Program's PSB would therefore contain three PCB-Macro Statements : pcb-1, pcb-2 and pcb-3, one for each database. Suppose you write an GN(Get Next) CALL Like this -

CALL 'CBLTDLI' USING DLI-GN PCB-2 SEGMENT-IO-AREA Since, you have coded PCB-2 on the GN(Get Next) CALL, it implies that the next segment-occurrence in Sequential(Hierarchical) order would be fetched from db -2. Thus, the PCB that you supply on the IMS/DB Call, tells you the database on which the CALL is executed.
2. There are other uses of the PCB-Mask : it is the link between your COBOL Program and the IMS/DB Software. The IMS/DB Software stores a 2-digit status code in the PCB-Mask, to indicate the success or failure of the IMS/DB CALL.

Take a look below, on how to write the COBOL Code for the PCB-Mask. Remember,
IMS Page 21

Take a look below, on how to write the COBOL Code for the PCB-Mask. Remember, this goes into the LINKAGE SECTION. Its a good idea to maintain a separate Mainframe File(Copy-Book) for the PCB-Mask. I have created a Copy-book INVENPCB that contains the COBOL Code for the Inventory Database PCB. I shall use this PCB Mask, during all IMS/DB CALLs that I execute on the Inventory Database.

Let me reiterate the fact, that after executing the IMS/DB CALL, IMS/DB Software stores important information in the PCB-Mask. These details are : Database Name : The first field in the PCB-Mask is the name of the Database, that is being processed. It is an 8-Byte Alphanumeric Field. Imagine, executing the GN(Get Next) CALL on the Inventory Database. After execution of the CALL, the Field IPCB-DBD-NAME will contain the value 'INVDBD' the name of the database(DBD). Segment-Level : The next field in the PCB-Mask is the hierarchical Level-no of the Segment Occurrence Processed. This is a 2-Byte Alphanumeric Field. After execution of a CALL, stores the Level-Number of the Segment Occurrence processed. For example, if a VENDRSEG(Vendor Data) occurrence is processed, 00 is stored, if a ITEMSSEG(Items Data) occurrence is processed, 01 is stored, and if a STLOCSEG(Stock Data) occurrence is processed, 02 is stored in IPCB -SEGMENT-LEVEL Field. Status Code : The third field in the PCB-Mask is the Two-Digit Status Code. After a successful call, IMS Software stores the Status-Code in this field. If the CALL is successful, IMS stores SPACES in the Status Code Field. Processing Options : The fourth field in the PCB-Mask is Processing-Options, a 4Byte Alphanumeric Field. This field indicates the privileges the program has, what processing is it allowed to do on the Database. The Field Value is populated from the Program's PSB. The next field in the PCB-Mask is a 4-Byte Filler. Defined as S9(05) COMP, it is reserved for IMS Software. Segment Name : The next field in the PCB-Mask is the Segment-Name, an 8-Byte Alpha-numeric Field. After a successful CALL, IMS Stores the name of the segment type last processed in this field. For example, upon executing GN CALL, Items Data is retrieved, then 'ITEMSSEG' value will be stored in IPCB-SEGMENT-NAME. Key-Length : The next field is the Key-Length, a 4-Byte Field. After a successful ISRT or Get CALL, IMS Software stores the Concatenated-Key of the Segment-Occurrence processed in the Key Feedback-Area. The Length of this Key, is placed in this 4Byte Field. Key-Feedback Area : The Key-Feedback Area is a variable-length Field. The Programmer must define the Key-Feedback field large enough to hold any Concatenated-Key, of the Segment processed. The Concatenated-Key of the SegmentOccurrence, is the concatenation of the Key-Value of all the Segment-Occurrences, along the Hierarchical path, starting from the Root-Segment leading to the Segment-Processed.
Q. What's the importance of Segment Input-Output Area in IMS? What should be the size of the Input-Output Area?

The third Parameter that you must supply on the IMS/DB CALL, is the Segment Input-Output Area. It is the COBOL-Variable or Data-Warehouse, used to hold and store the Segment-data received from IMS, or for keeping data that needs to be sent and inserted into IMS.
The size of this COBOL Variable should be large enough to accommodate the
IMS Page 22

The size of this COBOL Variable should be large enough to accommodate the Segment-Data. How to judge(decide) the size of Input-Output Area?
The Inventory-Database is made of three Segments VENDRSEG(Vendor Data), ITEMSSEG(Item Data) and STLOCSEG(Stock Location Data). Here's a snapshot, of the COBOL-Definition of the VENDRSEG(Vendor Segment). It is 131-Bytes large. The data for one Vendor Segment-Occurrence is of Length 131-Bytes.

The COBOL-Definition of the ITEMSSEG(Item Segment) is shown in the Picture below. The data for one Item Segment-Occurrence is of Length 48-Bytes.

The COBOL-Definition of the STLOCSEG(Stock Location Segment) is shown in the Picture below. The data for one Stock-Location Segment-Occurrence is of Length 21-Bytes.

By comparison, the Largest Segment is the Vendor-Segment. Generally, the thumbrule followed is, the size of the Segment I-O Area should be equal to the size of the largest Segment(in this case it is the VENDRSEG(Vendor) Segment). Look how, I have coded the SEGMENT-IO-AREA in my COBOL-Program as a 131-Byte Alphanumeric Field.

Inserted from <http://www.mainframes360.com/2010/12/preparing-cobol-ims-program.html>

IMS Page 23

Get Next CALL Sequential Retrieval of Data 25 April 2013 19:26

Get Next CALL Sequential Retrieval of Data


Q. What is meant by Hierarchical Sequential Order? An IMS Database has a sequence of records. The sample Inventory-Database that we've been working with, is loaded with the following data-records.

Pasted from <http://lh4.ggpht.com/_sQvdFWqMlMg/TWUDWvqwg-I/AAAAAAAAEH4/GjGNLvcwcIs/s1600-h/image%5B15%5D.png>

Scanning all the records in an IMS Database, and traversing through the entire database is done in a peculiar order. This order is called Hierarchical-Sequential Order or Pre-order. The HierarchicalSequential method of reading is like reading the Chinese language. You read it in a top-to-bottom, left-to-right fashion. The dotted arrows in blue, show the direction of traversal. The list of the Data-Items in Hierarchical-Sequence in Inventory-Database is shown below..
001 | 00011 DEL | MUM | 00012 CHN | 002 | 00021 BAN | GUR | KOL | 00022 INDUS CHEMICALS | PETERS ROAD,ROYAPETTAH | CHENNAI | TN | 600001 | 4466004332 | 8097415095 | SODIUM, PALMITATE | 15500.00 | 4600.00 1500 | 300 | 450 | 160204 1000 | 200 | 400 | 230510 | METHYL ORANGE | 17255.00 | 3230.00 1750 | 350 | 650 | 140106 AMAR PHARMACEUTICALS | CARTER ROAD,BANDRA | MUMBAI | MH | 400103 | 2228941365 | 9821065010 | ACETIC ACID | 10500.00 | 4600.00 2500 | 350 | 850 | 120507 2750 | 950 | 685 | 170306 3600 | 550 | 900 | 050301 | TINCTURE IODINE | 12500.00 | 6800.00

Pasted from <https://docs.google.com/document/pub?id=18tfhyGeXdSXE-WOEztYw_hCCcQ5RhEpEUPgJtSSULoc&embedded=true>

Q. What happens when you issue an IMS-DB GN(Get Next) CALL?


When you issue a single Get-Next GN Call, how to determine, which segment-occurrence is fetched from IMS Database? To be able to answer this, you need to understand the Database-Position. At all times, a marker or pointer is maintained in the IMS Database, that is set to your current-position in the Database. This current Database-Position serves as a reference-point, as a base-line for the next IMS-DB Call. Let's assume, that your position in the Database, is at the STLOCSEG Occurrence [MUM 1000 200 400 230510]. Observe the Marker or Pointer, in the IMS Database in the picture below.

IMS Page 24

After the COBOL Program issues an IMS-DB Get-Next GN Call, the marker or Pointer in the IMS Database is incremented, it moves one position forward in the database, from its reference-point. As a result, the Marker or Pointer advances to the next occurrence [00012 METHYL ORANGE 17255.00 3230.00] in hierarchical sequential order. This occurrence [00012 METHYL ORANGE 17255.00 3230.00] is the result of the execution of the GetNext GN Call, and will now be returned back as result to the CALL'er COBOL Program.

Q. How do I use the GN Calls to scan through the IMS Database? How to detect the end-of-database? You can use the Get-Next GN Calls to retrieve the Segment-Occurrences sequentially. To begin with, the pointer or marker in the IMS Database points to NULL.

When you issue the first IMS-DB Get-Next Call, the marker or pointer advances one position ahead to the segment-occurrence [001 INDUS CHEMICALS ...], and this segment-occurrence is fetched.

When you issue the second IMS-DB Get-Next Call, the marker or pointer advances one position ahead to the Segment-Occurrence [00011 SODIUM PALMITATE ...], and this segment-occurrence is fetched.

IMS Page 25

Likewise, when you issue subsequent IMS-DB Get-Next Calls, each time the marker or pointer in the IMS Database advances one step forward from its previous position, and the corresponding segmentoccurrence is fetched. Counting in this fashion, how many IMS-DB Get-Next Calls is it gonna take to reach the end? How to detect the end of the database? The Program should be smart enough to figure out this, and halt processing, and GO BACK. Let's find out, how its done! Let's fast-forward to the twelfth IMS-DB Get-Next Call. The Marker or Pointer in the IMS Database, advances from its previous position [KOL 3600 550 ...] one step ahead and gets fixed at [00022 TINCTURE IODINE].

When you issue the thirteenth IMS-DB Get-Next Call, the marker or the pointer in the IMS Database, moves one step ahead. But, there are no more segment-occurrences left to go to. The marker or pointer, has gone past the last segment-occurrence. This special condition is called End-Of-Database. The IMSDB Software sets a Two-digit Status Code = 'GB' in the PCB Control Block to indicate to the COBOL Program, the end of the Database.

Q. Could you illustrate a simple COBOL Program to retrieve data sequentially from the Inventory Database?
The algorithm to retrieve data sequentially from an IMS Database is quite simple. You run a loop, and keep issuing IMS-DB Get-Next Calls to fetch the segment-occurrences one-by-one, until IMS-DB sets a Status-Code='GB'. Pseudo-Code:
repeat until database-status = 'GB' begin get next seg-occurrence print seg-occurrence end
Pasted from <https://docs.google.com/document/pub?id=1BLsrW7Xty9fU8F-Kl7aDyMGwXOytqAiIJRfJo4u-iho&embedded=true>

How do you code the above algorithm in COBOL? First of all, on execution of the GN Call, the IMS-DB Software sets a two-digit status code in the PCB Block, indicating the success or failure of the Operation. The IPCB-STATUS-CODE COBOL Field stores this IMS-DB Status Code. I am going to run a Loop to fetch the segment-occurrences one-by-one from the database, until the IPCB-STATUS-CODE Field equals 'GB', and no more segment occurrences are left.
The data-result which is fetched from the IMS-Database, on execution of the GN Call, is stored in the Segment Input-Output Area. I would like to DISPLAY the data-results on the Mainframe Terminal, so I coded a DISPLAY SEGMENT-IO-AREA in my COBOL Source Program.

IMS Page 26

For those of you, who would like to try out and implement this Program at home, here is the complete Source Code of my COBOL Program, that retrieves the data sequentially from the IMS-Database and displays it on the screen.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-IDENTIFICATION DIVISION. PROGRAM-ID. IMSPGM02. *--------------------------------------------------------- * * PROGRAM : IMSPGM02 * * * * SYSTEM : ZOS DEMO PKG * * DESCRIPTION : This Program executes GN Calls on the * * Inventory Database until End-0f-database * * is reached. * *--------------------------------------------------------- * ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. *--------------------------------------------------------- * * FLAGS AND SWITCHES * *--------------------------------------------------------- * 01 FLAGS-AND-SWITCHES. 05 END-OF-DATABASE-SW PIC XX. 88 END-OF-DATABASE VALUE 'GB'. 88 NOT-AT-END VALUE ' '. *--------------------------------------------------------- * * DLI FUNCTION CODES * *--------------------------------------------------------- * 01 DLI-FUNCTION-CODES. 05 GN PIC X(04) VALUE 'GN '. *--------------------------------------------------------- * * COBOL SEGMENTS * *--------------------------------------------------------- * 01 SEGMENT-IO-AREA PIC X(131). *--------------------------------------------------------- * * COUNTERS * *--------------------------------------------------------- * 01 WS-COUNTERS. 05 WS-VENDR-RECS-CNT PIC S9(07) COMP-3 VALUE ZEROES. 05 WS-ITEMS-RECS-CNT PIC S9(07) COMP-3 VALUE ZEROES. 05 WS-STLOC-RECS-CNT PIC S9(07) COMP-3 VALUE ZEROES. *--------------------------------------------------------- * * MISCALLANEOUS * *--------------------------------------------------------- * 01 WS-PARA-NAME PIC X(20). LINKAGE SECTION. *--------------------------------------------------------- * * PCB MASKS * *--------------------------------------------------------- * COPY INVENPCB. *01 INVENTORY-PCB-MASK PROCEDURE DIVISION. 000-MAIN. ENTRY 'DLITCBL' USING INVENTORY-PCB-MASK PERFORM UNTIL IPCB-STATUS-CODE = 'GB' INITIALIZE SEGMENT-IO-AREA *---------------------------------------------------------- * * Execute Get Next(GN) CALL, to fetch the next segment * * occurrence in hierarchical sequential order. * *---------------------------------------------------------- * CALL 'CBLTDLI' USING GN INVENTORY-PCB-MASK SEGMENT-IO-AREA DISPLAY SEGMENT-IO-AREA EVALUATE IPCB-SEGMENT-NAME WHEN 'VENDRSEG' ADD +1 TO WS-VENDR-RECS-CNT

IMS Page 27

ADD +1 TO WS-VENDR-RECS-CNT WHEN 'ITEMSSEG' ADD +1 TO WS-ITEMS-RECS-CNT WHEN 'STLOCSEG' ADD +1 TO WS-STLOC-RECS-CNT END-EVALUATE END-PERFORM PERFORM 700-DISPLAY-STATS THRU 700-DISPLAY-STATS-EXIT PERFORM 999-GOBACK. 700-DISPLAY-STATS. DISPLAY '* * * * * * * * * * * * * * * * * * * * * *' DISPLAY ' PROGRAM STATISTICS ' DISPLAY ' ' DISPLAY ' VENDOR RECORDS : ' WS-VENDR-RECS-CNT DISPLAY ' ITEM RECORDS : ' WS-ITEMS-RECS-CNT DISPLAY ' STOCK RECORDS : ' WS-STLOC-RECS-CNT DISPLAY '* * * * * * * * * * * * * * * * * * * * * *'. 700-DISPLAY-STATS-EXIT. EXIT. 999-GOBACK. GOBACK.
Pasted from <https://docs.google.com/document/pub?id=1cCPkmTkJZy5QnVRsqIiLyGB0KrVVqb9nLmakpZX4Vgo&embedded=true >

IMS Page 28

Potrebbero piacerti anche